← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~james-w/launchpad/export-specification-bug-links into lp:launchpad

 

James Westby has proposed merging lp:~james-w/launchpad/export-specification-bug-links into lp:launchpad.

Requested reviews:
  Linaro Infrastructure (linaro-infrastructure): informational
  Launchpad code reviewers (launchpad-reviewers)


Hi,

Here is a small branch to export specification/bug links, which is the
last thing required to get the Ubuntu work items tracker using the API
for blueprints, rather than screen-scraping.

I'm not entirely sure that List->CollectionField doesn't change other
behavior, but lazr.restful doesn't do the right thing with List.

Also, I needed to add the inheritance to have lazr.restful add the bugs
property to the specifications. Previously the model just had
implements(IBugLinkTarget). I don't know if there is another way to achieve
that.

Thanks,

James

-- 
https://code.launchpad.net/~james-w/launchpad/export-specification-bug-links/+merge/42426
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~james-w/launchpad/export-specification-bug-links into lp:launchpad.
=== modified file 'lib/lp/blueprints/interfaces/specification.py'
--- lib/lp/blueprints/interfaces/specification.py	2010-12-01 12:54:42 +0000
+++ lib/lp/blueprints/interfaces/specification.py	2010-12-01 22:24:03 +0000
@@ -58,6 +58,7 @@
     IHasSpecifications,
     ISpecificationTarget,
     )
+from lp.bugs.interfaces.buglink import IBugLinkTarget
 from lp.blueprints.interfaces.sprint import ISprint
 from lp.code.interfaces.branchlink import IHasLinkedBranches
 from lp.registry.interfaces.milestone import IMilestone
@@ -529,7 +530,8 @@
         """Return the SpecificationBranch link for the branch, or None."""
 
 
-class ISpecification(ISpecificationPublic, ISpecificationEditRestricted):
+class ISpecification(ISpecificationPublic, ISpecificationEditRestricted,
+                     IBugLinkTarget):
     """A Specification."""
 
     export_as_webservice_entry()

=== modified file 'lib/lp/blueprints/tests/test_webservice.py'
--- lib/lp/blueprints/tests/test_webservice.py	2010-12-01 12:54:42 +0000
+++ lib/lp/blueprints/tests/test_webservice.py	2010-12-01 22:24:03 +0000
@@ -14,7 +14,11 @@
     )
 from lp.testing import (
     launchpadlib_for,
+<<<<<<< TREE
     launchpadlib_for_anonymous,
+=======
+    person_logged_in,
+>>>>>>> MERGE-SOURCE
     TestCaseWithFactory,
     ws_object,
     )
@@ -154,6 +158,16 @@
         self.assertEqual(1, spec_webservice.dependencies.total_size)
         self.assertEqual(spec2.name, spec_webservice.dependencies[0].name)
 
+    def test_representation_contains_bug_links(self):
+        spec = self.factory.makeSpecification()
+        bug = self.factory.makeBug()
+        person = self.factory.makePerson()
+        with person_logged_in(person):
+            spec.linkBug(bug)
+        spec_webservice = self.getSpecOnWebservice(spec)
+        self.assertEqual(1, spec_webservice.bugs.total_size)
+        self.assertEqual(bug.id, spec_webservice.bugs[0].id)
+
 
 class SpecificationTargetTests(SpecificationWebserviceTestCase):
     """Tests for accessing specifications via their targets."""

=== modified file 'lib/lp/bugs/interfaces/buglink.py'
--- lib/lp/bugs/interfaces/buglink.py	2010-08-20 20:31:18 +0000
+++ lib/lp/bugs/interfaces/buglink.py	2010-12-01 22:24:03 +0000
@@ -14,6 +14,13 @@
     'IUnlinkBugsForm',
     ]
 
+from lazr.restful.declarations import (
+    export_as_webservice_entry,
+    exported,
+    )
+from lazr.restful.fields import (
+    CollectionField,
+    )
 from zope.interface import (
     implements,
     Interface,
@@ -52,9 +59,10 @@
 
     Examples include an IQuestion, and an ICve.
     """
+    export_as_webservice_entry()
 
-    bugs = List(title=_("Bugs related to this object."),
-                value_type=Object(schema=IBug), readonly=True)
+    bugs = exported(CollectionField(title=_("Bugs related to this object."),
+                value_type=Object(schema=IBug), readonly=True))
     bug_links = List(title=_("The links between bugs and this object."),
                      value_type=Object(schema=IBugLink), readonly=True)
 

=== modified file 'lib/lp/bugs/interfaces/webservice.py'
--- lib/lp/bugs/interfaces/webservice.py	2010-11-09 16:25:22 +0000
+++ lib/lp/bugs/interfaces/webservice.py	2010-12-01 22:24:03 +0000
@@ -17,6 +17,7 @@
     'IBugActivity',
     'IBugAttachment',
     'IBugBranch',
+    'IBugLinkTarget',
     'IBugNomination',
     'IBugSubscription',
     'IBugTarget',
@@ -48,6 +49,7 @@
 from lp.bugs.interfaces.bugactivity import IBugActivity
 from lp.bugs.interfaces.bugattachment import IBugAttachment
 from lp.bugs.interfaces.bugbranch import IBugBranch
+from lp.bugs.interfaces.buglink import IBugLinkTarget
 from lp.bugs.interfaces.malone import IMaloneApplication
 from lp.bugs.interfaces.bugnomination import (
     BugNominationStatusError,


Follow ups