Merge lp:~inspirated/launchpad/export-Person-getBugSubscriberPackages into lp:launchpad

Proposed by Kamran Riaz Khan
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: 11121
Proposed branch: lp:~inspirated/launchpad/export-Person-getBugSubscriberPackages
Merge into: lp:launchpad
Diff against target: 66 lines (+36/-0)
3 files modified
lib/canonical/launchpad/interfaces/_schema_circular_imports.py (+4/-0)
lib/lp/registry/interfaces/person.py (+2/-0)
lib/lp/registry/stories/webservice/xx-person.txt (+30/-0)
To merge this branch: bzr merge lp:~inspirated/launchpad/export-Person-getBugSubscriberPackages
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+27630@code.launchpad.net

This proposal supersedes a proposal from 2010-06-15.

Commit message

[ui=none][r=gmb][bug=331039,281443] Person.getBugSubscriberPackages() has been exported via the API.

Description of the change

Summary:
As part of my GSoC 2010 project, functionality is required in Arsenal to search all the bugs a team is subscribed to. This required an API call which would export all the source packages subscriptions of a team. Bug #281443 and Bug #331039 document other needs for this API call.

Proposed fix:
The method for searching a team's subscriptions is already present in lib/lp/registry/model/person.py as Person.getBugSubscriberPackages(). This branch just exports this method in the API.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) wrote : Posted in a previous version of this proposal

Hi Kamran,

Thanks for making this change. Unfortunately before changes can be landed in Launchpad they must have tests to cover them. With your changes, the tests suite will at the moment almost certainly fail. You need to alter the existing tests to cover this change.

I haven't had time to run the whole test suite to check which tests fail, but you'll at least need to fix the tests in lib/lp/registry/stories/webservice/xx-person.txt (you can find out where the failures will be by running bin/test -cvvt xx-person from the root of your LP branch).

I'd be happy to help you with fixing the tests, just ping me in #launchpad-dev on Freenode and if I'm around I'll help you out.

review: Needs Fixing (code)
Revision history for this message
Kamran Riaz Khan (inspirated) wrote : Posted in a previous version of this proposal

Hi Graham,

Thanks for taking time out to review. Here are the results for person test suite:

$ bin/test -cvvt xx-person.txtRunning tests at level 1
Running canonical.testing.layers.PageTestLayer tests:
  Set up canonical.testing.layers.BaseLayer in 0.082 seconds.
  Set up canonical.testing.layers.DatabaseLayer in 1 minutes 3.481 seconds.
  Set up canonical.testing.layers.LibrarianLayer in 22.484 seconds.
  Set up canonical.testing.layers.MemcachedLayer in 0.308 seconds.
  Set up canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Set up canonical.testing.layers.FunctionalLayer in 11.257 seconds.
  Set up canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Set up canonical.testing.layers.GoogleServiceLayer in 5.759 seconds.
  Set up canonical.testing.layers.PageTestLayer in 0.012 seconds.
  Running:
 lib/lp/registry/tests/../stories/webservice/xx-person.txt
  Ran 52 tests with 0 failures and 0 errors in 1 minutes 12.426 seconds.
Tearing down left over layers:
  Tear down canonical.testing.layers.PageTestLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LibrarianLayer in 0.015 seconds.
  Tear down canonical.testing.layers.MemcachedLayer in 0.113 seconds.
  Tear down canonical.testing.layers.GoogleServiceLayer in 0.455 seconds.
  Tear down canonical.testing.layers.FunctionalLayer ... not supported
  Tear down canonical.testing.layers.DatabaseLayer in 0.190 seconds.
  Tear down canonical.testing.layers.BaseLayer in 0.000 seconds.

The tests do not introduce any regression (since the branch doesn't implement anything new in LP, it just exports a method that is already present).

Revision history for this message
Kamran Riaz Khan (inspirated) wrote : Posted in a previous version of this proposal

Added new doctest in revision #11012.

$ bin/test -cvvt xx-person.txt
Running tests at level 1
Running canonical.testing.layers.PageTestLayer tests:
  Set up canonical.testing.layers.BaseLayer in 0.033 seconds.
  Set up canonical.testing.layers.DatabaseLayer in 1.283 seconds.
  Set up canonical.testing.layers.LibrarianLayer in 14.543 seconds.
  Set up canonical.testing.layers.MemcachedLayer in 0.186 seconds.
  Set up canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Set up canonical.testing.layers.FunctionalLayer in 9.068 seconds.
  Set up canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Set up canonical.testing.layers.GoogleServiceLayer in 4.523 seconds.
  Set up canonical.testing.layers.PageTestLayer in 0.011 seconds.
  Running:
 lib/lp/registry/tests/../stories/webservice/xx-person.txt
  Ran 53 tests with 0 failures and 0 errors in 59.176 seconds.
Tearing down left over layers:
  Tear down canonical.testing.layers.PageTestLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LibrarianLayer in 0.006 seconds.
  Tear down canonical.testing.layers.MemcachedLayer in 0.103 seconds.
  Tear down canonical.testing.layers.GoogleServiceLayer in 0.312 seconds.
  Tear down canonical.testing.layers.FunctionalLayer ... not supported
  Tear down canonical.testing.layers.DatabaseLayer in 0.218 seconds.
  Tear down canonical.testing.layers.BaseLayer in 0.000 seconds.

Revision history for this message
Graham Binns (gmb) wrote : Posted in a previous version of this proposal

The new test tests the method directly, not through the webservice; it should be tested using webservice.named_get() as used elsewhere in xx-person.txt

review: Needs Fixing (code)
Revision history for this message
Kamran Riaz Khan (inspirated) wrote :

The new diff uses webservice.named_get to test the method. Test results:

$ bin/test -cvvt xx-person.txt
Running tests at level 1
Running canonical.testing.layers.PageTestLayer tests:
  Set up canonical.testing.layers.BaseLayer in 0.024 seconds.
  Set up canonical.testing.layers.DatabaseLayer in 1.479 seconds.
  Set up canonical.testing.layers.LibrarianLayer in 14.752 seconds.
  Set up canonical.testing.layers.MemcachedLayer in 0.175 seconds.
  Set up canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Set up canonical.testing.layers.FunctionalLayer in 9.167 seconds.
  Set up canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Set up canonical.testing.layers.GoogleServiceLayer in 3.470 seconds.
  Set up canonical.testing.layers.PageTestLayer in 0.011 seconds.
  Running:
 lib/lp/registry/tests/../stories/webservice/xx-person.txt
  Ran 54 tests with 0 failures and 0 errors in 51.925 seconds.
Tearing down left over layers:
  Tear down canonical.testing.layers.PageTestLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadFunctionalLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LaunchpadLayer in 0.000 seconds.
  Tear down canonical.testing.layers.LibrarianLayer in 0.007 seconds.
  Tear down canonical.testing.layers.MemcachedLayer in 0.110 seconds.
  Tear down canonical.testing.layers.GoogleServiceLayer in 0.282 seconds.
  Tear down canonical.testing.layers.FunctionalLayer ... not supported
  Tear down canonical.testing.layers.DatabaseLayer in 0.192 seconds.
  Tear down canonical.testing.layers.BaseLayer in 0.000 seconds.

Revision history for this message
Graham Binns (gmb) wrote :

I'm happy for this to land now. I see some test failures when I run the test locally, but they seem unconnected to your changes, so I'll run it through ec2 test for you and see what comes out the other side.

review: Approve (code)
Revision history for this message
Bryce Harrington (bryce) wrote :

kamran, small change needed to address a test failure:

=== modified file 'lib/lp/registry/stories/webservice/xx-person.txt'
--- a/lib/lp/registry/stories/webservice/xx-person.txt 2010-06-15 17:12:08 +0000
+++ b/lib/lp/registry/stories/webservice/xx-person.txt 2010-07-09 17:20:55 +0000
@@ -656,6 +656,7 @@
     start: 0
     total_size: 1
     ---
+ bug_reported_acknowledgement: None
     bug_reporting_guidelines: None
     display_name: u'...'
     distribution_link: u'...'

I attempted to land a branch of your branch with this fix added, but it wouldn't go; the branch has to be the one attached to the merge proposal. So if you could please apply this patch and update the branch, we can land it after that.

Revision history for this message
Kamran Riaz Khan (inspirated) wrote :

Thanks for the fix, Bryce. The bug_reported_acknowledgement field wasn't present at the time I last committed to this branch. Pushed in rev 11014.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
2--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-06-29 10:17:06 +0000
3+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-07-10 07:46:00 +0000
4@@ -425,5 +425,9 @@
5 # IPOTemplateSharingSubset
6 patch_reference_property(IPOTemplateSharingSubset, 'product', IProduct)
7
8+# IPerson
9+patch_collection_return_type(
10+ IPerson, 'getBugSubscriberPackages', IDistributionSourcePackage)
11+
12 # IProductSeries
13 patch_reference_property(IProductSeries, 'product', IProduct)
14
15=== modified file 'lib/lp/registry/interfaces/person.py'
16--- lib/lp/registry/interfaces/person.py 2010-07-09 14:58:42 +0000
17+++ lib/lp/registry/interfaces/person.py 2010-07-10 07:46:00 +0000
18@@ -904,6 +904,8 @@
19 The results are ordered using Person.sortingColumns.
20 """
21
22+ @operation_returns_collection_of(Interface)
23+ @export_read_operation()
24 def getBugSubscriberPackages():
25 """Return the packages for which this person is a bug subscriber.
26
27
28=== modified file 'lib/lp/registry/stories/webservice/xx-person.txt'
29--- lib/lp/registry/stories/webservice/xx-person.txt 2010-05-12 03:31:34 +0000
30+++ lib/lp/registry/stories/webservice/xx-person.txt 2010-07-10 07:46:00 +0000
31@@ -638,6 +638,36 @@
32
33 IPerson supports a bunch of operations.
34
35+Teams can subscribe to source packages:
36+
37+ >>> login('admin@canonical.com')
38+ >>> pythons_db = factory.makeTeam(name='pythons')
39+ >>> package_db = factory.makeDistributionSourcePackage(
40+ ... sourcepackagename="fooix")
41+ >>> ignored = package_db.addSubscription(None, pythons_db)
42+ >>> logout()
43+
44+Subscribed packages can be listed with getBugSubscriberPackages:
45+
46+ >>> from lazr.restful.testing.webservice import pprint_collection
47+ >>> subscriptions = webservice.named_get("/~pythons",
48+ ... "getBugSubscriberPackages").jsonBody()
49+ >>> pprint_collection(subscriptions)
50+ start: 0
51+ total_size: 1
52+ ---
53+ bug_reported_acknowledgement: None
54+ bug_reporting_guidelines: None
55+ display_name: u'...'
56+ distribution_link: u'...'
57+ name: u'fooix'
58+ official_bug_tags: []
59+ resource_type_link: u'...'
60+ self_link: u'...'
61+ title: u'...'
62+ upstream_product_link: None
63+ ---
64+
65
66 === Team membership operations ===
67