Merge lp:~al-maisan/launchpad/relsets-463195 into lp:launchpad/db-devel

Proposed by Muharem Hrnjadovic
Status: Merged
Merged at revision: not available
Proposed branch: lp:~al-maisan/launchpad/relsets-463195
Merge into: lp:launchpad/db-devel
Diff against target: 143 lines
4 files modified
lib/canonical/launchpad/interfaces/_schema_circular_imports.py (+2/-0)
lib/lp/soyuz/interfaces/packageset.py (+10/-0)
lib/lp/soyuz/model/packageset.py (+9/-0)
lib/lp/soyuz/tests/test_packageset.py (+68/-2)
To merge this branch: bzr merge lp:~al-maisan/launchpad/relsets-463195
Reviewer Review Type Date Requested Status
Abel Deuring (community) code Approve
Review via email: mp+14169@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Muharem Hrnjadovic (al-maisan) wrote :

Hello there!

The branch at hand enables a user to find related package sets. The added IPackageset.relatedSets() method returns (for a given package set P) a collection of package sets to which P is related by way of a shared package set group.

Tests to run:

    bin/test -vvt packageset

Revision history for this message
Abel Deuring (adeuring) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/canonical/launchpad/interfaces/_schema_circular_imports.py'
--- lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2009-10-13 14:46:17 +0000
+++ lib/canonical/launchpad/interfaces/_schema_circular_imports.py 2009-10-29 14:30:26 +0000
@@ -277,6 +277,8 @@
277 IPackageset, 'getSourcesSharedBy', 'other_package_set', IPackageset)277 IPackageset, 'getSourcesSharedBy', 'other_package_set', IPackageset)
278patch_plain_parameter_type(278patch_plain_parameter_type(
279 IPackageset, 'getSourcesNotSharedBy', 'other_package_set', IPackageset)279 IPackageset, 'getSourcesNotSharedBy', 'other_package_set', IPackageset)
280patch_collection_return_type(
281 IPackageset, 'relatedSets', IPackageset)
280282
281# IPackageUpload283# IPackageUpload
282IPackageUpload['pocket'].vocabulary = PackagePublishingPocket284IPackageUpload['pocket'].vocabulary = PackagePublishingPocket
283285
=== modified file 'lib/lp/soyuz/interfaces/packageset.py'
--- lib/lp/soyuz/interfaces/packageset.py 2009-10-27 23:40:24 +0000
+++ lib/lp/soyuz/interfaces/packageset.py 2009-10-29 14:30:26 +0000
@@ -217,6 +217,16 @@
217 names.217 names.
218 """218 """
219219
220 @operation_returns_collection_of(Interface)
221 @export_read_operation()
222 def relatedSets():
223 """Get all package sets related to this one.
224
225 Return all package sets that are related to this one.
226
227 :return: A (potentially empty) sequence of `IPackageset` instances.
228 """
229
220230
221class IPackagesetEdit(Interface):231class IPackagesetEdit(Interface):
222 """A writeable interface for package sets."""232 """A writeable interface for package sets."""
223233
=== modified file 'lib/lp/soyuz/model/packageset.py'
--- lib/lp/soyuz/model/packageset.py 2009-10-27 15:42:04 +0000
+++ lib/lp/soyuz/model/packageset.py 2009-10-29 14:30:26 +0000
@@ -295,6 +295,15 @@
295 clauses = (Packageset, In(Packageset.name, names))295 clauses = (Packageset, In(Packageset.name, names))
296 self._api_add_or_remove(clauses, self._removeDirectSuccessors)296 self._api_add_or_remove(clauses, self._removeDirectSuccessors)
297297
298 def relatedSets(self):
299 """See `IPackageset`."""
300 store = IStore(Packageset)
301 result_set = store.find(
302 Packageset,
303 Packageset.packagesetgroup == self.packagesetgroup,
304 Packageset.id != self.id)
305 return _order_result_set(result_set)
306
298307
299class PackagesetSet:308class PackagesetSet:
300 """See `IPackagesetSet`."""309 """See `IPackagesetSet`."""
301310
=== modified file 'lib/lp/soyuz/tests/test_packageset.py'
--- lib/lp/soyuz/tests/test_packageset.py 2009-10-27 22:27:52 +0000
+++ lib/lp/soyuz/tests/test_packageset.py 2009-10-29 14:30:26 +0000
@@ -14,13 +14,13 @@
14 DuplicatePackagesetName, IPackagesetSet)14 DuplicatePackagesetName, IPackagesetSet)
1515
1616
17class TestPackagesetSetNew(TestCaseWithFactory):17class TestPackagesetSet(TestCaseWithFactory):
1818
19 layer = LaunchpadZopelessLayer19 layer = LaunchpadZopelessLayer
2020
21 def setUp(self):21 def setUp(self):
22 """Setup a distribution with multiple distroseries."""22 """Setup a distribution with multiple distroseries."""
23 super(TestPackagesetSetNew, self).setUp()23 super(TestPackagesetSet, self).setUp()
24 self.distribution = getUtility(IDistributionSet).getByName(24 self.distribution = getUtility(IDistributionSet).getByName(
25 'ubuntu')25 'ubuntu')
26 self.distroseries_current = self.distribution.currentseries26 self.distroseries_current = self.distribution.currentseries
@@ -119,3 +119,69 @@
119 pset_found = getUtility(IPackagesetSet).getByName(119 pset_found = getUtility(IPackagesetSet).getByName(
120 'kernel', distroseries=self.distroseries_experimental)120 'kernel', distroseries=self.distroseries_experimental)
121 self.assertEqual(pset2, pset_found)121 self.assertEqual(pset2, pset_found)
122
123
124class TestPackageset(TestCaseWithFactory):
125
126 layer = LaunchpadZopelessLayer
127
128 def setUp(self):
129 """Setup a distribution with multiple distroseries."""
130 super(TestPackageset, self).setUp()
131 self.distribution = getUtility(IDistributionSet).getByName(
132 'ubuntu')
133 self.distroseries_current = self.distribution.currentseries
134 self.distroseries_experimental = self.factory.makeDistroRelease(
135 distribution = self.distribution, name="experimental",
136 status=DistroSeriesStatus.EXPERIMENTAL)
137 self.distroseries_experimental2 = self.factory.makeDistroRelease(
138 distribution = self.distribution, name="experimental2",
139 status=DistroSeriesStatus.EXPERIMENTAL)
140
141 self.person1 = self.factory.makePerson(
142 name='hacker', displayname=u'Happy Hacker')
143
144 self.packageset_set = getUtility(IPackagesetSet)
145
146 def test_no_related_sets(self):
147 # If the package set is the only one in the group the result set
148 # returned by relatedSets() is empty.
149 packageset = self.packageset_set.new(
150 u'kernel', u'Contains all OS kernel packages', self.person1)
151
152 self.failUnlessEqual(packageset.relatedSets().count(), 0)
153
154 def test_related_set_found(self):
155 # Creating a new package set while specifying a `related_set` should
156 # have the effect that the former ends up in the same group as the
157 # latter.
158
159 # The original package set.
160 pset1 = self.packageset_set.new(
161 u'kernel', u'Contains all OS kernel packages', self.person1)
162
163 # A related package set.
164 pset2 = self.packageset_set.new(
165 u'kernel', u'A related package set.', self.person1,
166 distroseries=self.distroseries_experimental, related_set=pset1)
167 self.assertEqual(pset1.packagesetgroup, pset2.packagesetgroup)
168
169 # An unrelated package set with the same name.
170 pset3 = self.packageset_set.new(
171 u'kernel', u'Unrelated package set.', self.person1,
172 distroseries=self.distroseries_experimental2)
173 self.assertNotEqual(pset2.packagesetgroup, pset3.packagesetgroup)
174
175 # Make sure 'pset2' is related to 'pset1'.
176 related = pset1.relatedSets()
177 self.assertEqual(related.count(), 1)
178 self.assertEqual(related[0], pset2)
179
180 # And the other way around ..
181 related = pset2.relatedSets()
182 self.assertEqual(related.count(), 1)
183 self.assertEqual(related[0], pset1)
184
185 # Unsurprisingly, the unrelated package set is not associated with any
186 # other package set.
187 self.failUnlessEqual(pset3.relatedSets().count(), 0)

Subscribers

People subscribed via source and target branches

to status/vote changes: