Merge lp:~leonardr/launchpad/add-mutators into lp:launchpad/db-devel

Proposed by Leonard Richardson
Status: Merged
Merged at revision: not available
Proposed branch: lp:~leonardr/launchpad/add-mutators
Merge into: lp:launchpad/db-devel
Diff against target: 62 lines (+30/-4)
2 files modified
lib/lp/code/interfaces/branch.py (+5/-4)
lib/lp/code/stories/webservice/xx-branch.txt (+25/-0)
To merge this branch: bzr merge lp:~leonardr/launchpad/add-mutators
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+21965@code.launchpad.net

Description of the change

By reading https://bugs.edge.launchpad.net/lazr.restful/+bug/336866/comments/46, I got the idea that two named operations of IBug should be made into mutators. I decided to do this quickly so as to avoid possible complications when we have multiple active versions of the web service.

However, it turns out those two named operations are already mutators, and are no longer listed on, eg., https://staging.launchpad.net/+apidoc/devel.html. But, I did discover that IBranch.setPrivate should be the mutator for IBranch.private, but isn't. This branch makes it a mutator and adds a test to show that the behavior of the named operation (present as a named operation in beta, not present in devel) is correct.

(This test is kind of stupid and I don't intend to do it every time I make an existing named operator a mutator, since the general behavior is well tested, but I figured it was good for the first time.)

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/interfaces/branch.py'
2--- lib/lp/code/interfaces/branch.py 2010-03-18 06:03:11 +0000
3+++ lib/lp/code/interfaces/branch.py 2010-03-23 18:36:40 +0000
4@@ -47,11 +47,11 @@
5
6 from lazr.restful.fields import CollectionField, Reference, ReferenceChoice
7 from lazr.restful.declarations import (
8- call_with, collection_default_content, export_as_webservice_collection,
9- export_as_webservice_entry, export_factory_operation,
10+ REQUEST_USER, call_with, collection_default_content,
11+ export_as_webservice_collection, export_as_webservice_entry,
12+ export_destructor_operation, export_factory_operation,
13 export_operation_as, export_read_operation, export_write_operation,
14- export_destructor_operation, exported, operation_parameters,
15- operation_returns_entry, REQUEST_USER)
16+ exported, mutator_for, operation_parameters, operation_returns_entry)
17
18 from canonical.config import config
19
20@@ -406,6 +406,7 @@
21 description=_(
22 "Make this branch visible only to its subscribers.")))
23
24+ @mutator_for(private)
25 @call_with(user=REQUEST_USER)
26 @operation_parameters(
27 private=Bool(title=_("Keep branch confidential")))
28
29=== modified file 'lib/lp/code/stories/webservice/xx-branch.txt'
30--- lib/lp/code/stories/webservice/xx-branch.txt 2010-03-17 01:18:32 +0000
31+++ lib/lp/code/stories/webservice/xx-branch.txt 2010-03-23 18:36:40 +0000
32@@ -244,6 +244,31 @@
33 >>> print_branches(webservice, '/widgets', ('Experimental'))
34 ~eric/fooix/feature-branch - Experimental
35
36+Differences between versions
37+============================
38+
39+In version 'beta', a branch can be made private or public by invoking
40+the named operation 'setPrivate'.
41+
42+ >>> branch = webservice.get(branch_url).jsonBody()
43+ >>> print branch['private']
44+ False
45+
46+ >>> response = webservice.named_post(
47+ ... branch_url, 'setPrivate', api_version='beta', private=True)
48+ >>> branch = webservice.get(branch_url).jsonBody()
49+ >>> print branch['private']
50+ True
51+
52+In subsequent versions, 'setPrivate' is gone; you have to set the
53+'private' field directly.
54+
55+ >>> print webservice.named_post(
56+ ... branch_url, 'setPrivate', api_version='devel', private=True)
57+ HTTP/1.1 400 Bad Request
58+ ...
59+ No such operation: setPrivate
60+
61 Removing branches
62 =================
63

Subscribers

People subscribed via source and target branches

to status/vote changes: