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

Proposed by Guilherme Salgado on 2010-11-29
Status: Merged
Approved by: Aaron Bentley on 2010-11-29
Approved revision: 12001
Merged at revision: 12001
Proposed branch: lp:~salgado/launchpad/expose-blueprint-dependencies
Merge into: lp:launchpad
Diff against target: 109 lines (+29/-8)
4 files modified
lib/canonical/launchpad/interfaces/_schema_circular_imports.py (+3/-0)
lib/lp/blueprints/interfaces/specification.py (+11/-2)
lib/lp/blueprints/tests/test_hasspecifications.py (+1/-1)
lib/lp/blueprints/tests/test_webservice.py (+14/-5)
To merge this branch: bzr merge lp:~salgado/launchpad/expose-blueprint-dependencies
Reviewer Review Type Date Requested Status
Aaron Bentley (community) 2010-11-29 Approve on 2010-11-29
Review via email: mp+42145@code.launchpad.net

Commit Message

[r=abentley][ui=none][bug=682757]

Description of the Change

Expose ISpecification.dependencies on the webservice API.

To post a comment you must log in.
11999. By Guilherme Salgado on 2010-11-29

merge test refactoring from other branch

12000. By Guilherme Salgado on 2010-11-29

Merge trunk

12001. By Guilherme Salgado on 2010-11-29

Tweak some tests to use assertContentEqual instead of sorting their lists manually

Aaron Bentley (abentley) wrote :

At 23, the import should be multi-line. Also, you should consider using lp.testing.ws_object rather than getSpecOnWebservice, because it is more general.

review: Approve
12002. By Guilherme Salgado on 2010-11-29

Use multi-line imports when importing multiple names

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-11-25 13:03:16 +0000
3+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2010-11-29 19:13:18 +0000
4@@ -521,6 +521,9 @@
5 # IProductSeries
6 patch_reference_property(IProductSeries, 'product', IProduct)
7
8+# ISpecification
9+patch_collection_property(ISpecification, 'dependencies', ISpecification)
10+
11 # ISpecificationTarget
12 patch_entry_return_type(
13 ISpecificationTarget, 'getSpecification', ISpecification)
14
15=== modified file 'lib/lp/blueprints/interfaces/specification.py'
16--- lib/lp/blueprints/interfaces/specification.py 2010-11-26 18:04:53 +0000
17+++ lib/lp/blueprints/interfaces/specification.py 2010-11-29 19:13:18 +0000
18@@ -23,7 +23,11 @@
19 exported,
20 export_as_webservice_entry,
21 )
22-from lazr.restful.fields import ReferenceChoice
23+from lazr.restful.fields import (
24+ CollectionField,
25+ Reference,
26+ ReferenceChoice,
27+ )
28
29 from zope.component import getUtility
30 from zope.interface import (
31@@ -382,7 +386,12 @@
32 sprints = Attribute('The sprints at which this spec is discussed.')
33 sprint_links = Attribute('The entries that link this spec to sprints.')
34 feedbackrequests = Attribute('The set of feedback requests queued.')
35- dependencies = Attribute('Specs on which this spec depends.')
36+ dependencies = exported(
37+ CollectionField(
38+ title=_('Specs on which this one depends.'),
39+ value_type=Reference(schema=Interface), # ISpecification, really.
40+ readonly=True),
41+ ('devel', dict(exported=True)), exported=False)
42 blocked_specs = Attribute('Specs for which this spec is a dependency.')
43 all_deps = Attribute(
44 "All the dependencies, including dependencies of dependencies.")
45
46=== modified file 'lib/lp/blueprints/tests/test_hasspecifications.py'
47--- lib/lp/blueprints/tests/test_hasspecifications.py 2010-11-29 16:16:18 +0000
48+++ lib/lp/blueprints/tests/test_hasspecifications.py 2010-11-29 19:13:18 +0000
49@@ -19,7 +19,7 @@
50
51 def assertNamesOfSpecificationsAre(self, expected_names, specifications):
52 names = [s.name for s in specifications]
53- self.assertEqual(sorted(expected_names), sorted(names))
54+ self.assertContentEqual(expected_names, names)
55
56 def test_product_all_specifications(self):
57 product = self.factory.makeProduct()
58
59=== modified file 'lib/lp/blueprints/tests/test_webservice.py'
60--- lib/lp/blueprints/tests/test_webservice.py 2010-11-29 16:16:18 +0000
61+++ lib/lp/blueprints/tests/test_webservice.py 2010-11-29 19:13:18 +0000
62@@ -11,7 +11,9 @@
63 SpecificationDefinitionStatus,
64 )
65 from lp.testing import (
66- launchpadlib_for, TestCaseWithFactory)
67+ launchpadlib_for,
68+ TestCaseWithFactory,
69+ )
70
71
72 class SpecificationWebserviceTestCase(TestCaseWithFactory):
73@@ -46,10 +48,9 @@
74 webservice = webservice_for_person(user)
75 response = webservice.get(
76 '/%s/+spec/%s' % (spec.product.name, spec.name))
77- expected_keys = sorted(
78- [u'self_link', u'http_etag', u'resource_type_link'])
79+ expected_keys = [u'self_link', u'http_etag', u'resource_type_link']
80 self.assertEqual(response.status, 200)
81- self.assertEqual(sorted(response.jsonBody().keys()), expected_keys)
82+ self.assertContentEqual(expected_keys, response.jsonBody().keys())
83
84 def test_representation_contains_name(self):
85 spec = self.factory.makeSpecification()
86@@ -141,6 +142,14 @@
87 spec = self.getSpecOnWebservice(spec_object)
88 self.assertEqual("1.0", spec.milestone.name)
89
90+ def test_representation_contains_dependencies(self):
91+ spec = self.factory.makeSpecification()
92+ spec2 = self.factory.makeSpecification()
93+ spec.createDependency(spec2)
94+ spec_webservice = self.getSpecOnWebservice(spec)
95+ self.assertEqual(1, spec_webservice.dependencies.total_size)
96+ self.assertEqual(spec2.name, spec_webservice.dependencies[0].name)
97+
98
99 class SpecificationTargetTests(SpecificationWebserviceTestCase):
100 """Tests for accessing specifications via their targets."""
101@@ -204,7 +213,7 @@
102
103 def assertNamesOfSpecificationsAre(self, expected_names, specifications):
104 names = [s.name for s in specifications]
105- self.assertEqual(sorted(expected_names), sorted(names))
106+ self.assertContentEqual(expected_names, names)
107
108 def test_product_all_specifications(self):
109 product = self.factory.makeProduct()