← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~salgado/launchpad/expose-blueprint-dependencies into lp:launchpad

 

Guilherme Salgado has proposed merging lp:~salgado/launchpad/expose-blueprint-dependencies into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)


Expose ISpecification.dependencies on the webservice API.
-- 
https://code.launchpad.net/~salgado/launchpad/expose-blueprint-dependencies/+merge/42145
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~salgado/launchpad/expose-blueprint-dependencies into lp:launchpad.
=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py	2010-11-25 13:03:16 +0000
+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py	2010-11-29 16:51:55 +0000
@@ -521,6 +521,9 @@
 # IProductSeries
 patch_reference_property(IProductSeries, 'product', IProduct)
 
+# ISpecification
+patch_collection_property(ISpecification, 'dependencies', ISpecification)
+
 # ISpecificationTarget
 patch_entry_return_type(
     ISpecificationTarget, 'getSpecification', ISpecification)

=== modified file 'lib/lp/blueprints/interfaces/specification.py'
--- lib/lp/blueprints/interfaces/specification.py	2010-11-26 18:04:53 +0000
+++ lib/lp/blueprints/interfaces/specification.py	2010-11-29 16:51:55 +0000
@@ -23,7 +23,7 @@
     exported,
     export_as_webservice_entry,
     )
-from lazr.restful.fields import ReferenceChoice
+from lazr.restful.fields import CollectionField, Reference, ReferenceChoice
 
 from zope.component import getUtility
 from zope.interface import (
@@ -382,7 +382,12 @@
     sprints = Attribute('The sprints at which this spec is discussed.')
     sprint_links = Attribute('The entries that link this spec to sprints.')
     feedbackrequests = Attribute('The set of feedback requests queued.')
-    dependencies = Attribute('Specs on which this spec depends.')
+    dependencies = exported(
+        CollectionField(
+            title=_('Specs on which this one depends.'),
+            value_type=Reference(schema=Interface),  # ISpecification, really.
+            readonly=True),
+        ('devel', dict(exported=True)), exported=False)
     blocked_specs = Attribute('Specs for which this spec is a dependency.')
     all_deps = Attribute(
         "All the dependencies, including dependencies of dependencies.")

=== modified file 'lib/lp/blueprints/tests/test_webservice.py'
--- lib/lp/blueprints/tests/test_webservice.py	2010-11-26 18:04:53 +0000
+++ lib/lp/blueprints/tests/test_webservice.py	2010-11-29 16:51:55 +0000
@@ -141,6 +141,14 @@
         spec = self.getSpecOnWebservice(spec_object)
         self.assertEqual("1.0", spec.milestone.name)
 
+    def test_representation_contains_dependencies(self):
+        spec = self.factory.makeSpecification()
+        spec2 = self.factory.makeSpecification()
+        spec.createDependency(spec2)
+        spec_webservice = self.getSpecOnWebservice(spec)
+        self.assertEqual(1, spec_webservice.dependencies.total_size)
+        self.assertEqual(spec2.name, spec_webservice.dependencies[0].name)
+
 
 class SpecificationTargetTests(SpecificationWebserviceTestCase):
     """Tests for accessing specifications via their targets."""