Merge lp:~adeuring/launchpad/bug-746460-productseries into lp:launchpad

Proposed by Abel Deuring
Status: Merged
Approved by: Abel Deuring
Approved revision: no longer in the source branch.
Merged at revision: 12832
Proposed branch: lp:~adeuring/launchpad/bug-746460-productseries
Merge into: lp:launchpad
Diff against target: 220 lines (+102/-17)
3 files modified
lib/lp/registry/browser/tests/packaging-views.txt (+19/-8)
lib/lp/registry/model/productseries.py (+4/-9)
lib/lp/registry/tests/test_productseries.py (+79/-0)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-746460-productseries
Reviewer Review Type Date Requested Status
j.c.sackett (community) Approve
Review via email: mp+57685@code.launchpad.net

Commit message

[bug=760699] [r=jcsackett] ProductSeries.setPackaging() does no longer change existing packaging records, if the distroseries passed as a parameter matches the distroseries attribue of an existing packaging record that points to another sourcepackage.

Description of the change

This branch fixes bug 760699: ProductSeries.setPackaging() should not change existing records

It also ensures that ProductSeries.setPackaging() and SourcePacjage.setPackaging() behave identical.

The fix is quite straightforward: I deleted those lines in ProductSeries.setPackaging() that change an existing packaging record.

test: ./bin/test -vvt lp.registry.tests.test_productseries.TestProductSeriesSetPackaging

no lint

To post a comment you must log in.
Revision history for this message
j.c.sackett (jcsackett) wrote :

This looks fine.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/registry/browser/tests/packaging-views.txt'
2--- lib/lp/registry/browser/tests/packaging-views.txt 2011-04-11 16:00:53 +0000
3+++ lib/lp/registry/browser/tests/packaging-views.txt 2011-04-14 14:04:14 +0000
4@@ -157,10 +157,13 @@
5 >>> view.errors
6 []
7
8+We now have two source packages linked to our productseries.
9+
10 >>> for packaging in view.ubuntu_history:
11 ... print packaging.distroseries.name
12 ... print packaging.sourcepackagename.name
13 hoary thunderbird
14+ hoary hot
15
16 It is not an error to submit the same sourcepackagename information, the
17 action is ignored because there is no change
18@@ -178,6 +181,7 @@
19 ... print packaging.distroseries.name
20 ... print packaging.sourcepackagename.name
21 hoary thunderbird
22+ hoary hot
23
24 When the current Ubuntu series changes, the sourcepackagename is not known,
25 and a new entry can be added to the packaging history.
26@@ -213,6 +217,7 @@
27 ... print packaging.sourcepackagename.name
28 grumpy hot
29 hoary thunderbird
30+ hoary hot
31
32
33 Product packages view
34@@ -230,12 +235,15 @@
35 ... for series in view.series_batch.batch:
36 ... print series.name
37 ... for package in series.packagings:
38- ... print ' Package:', package.distroseries.name
39+ ... print ' Package %s: %s' % (
40+ ... package.sourcepackagename.name,
41+ ... package.distroseries.name)
42 >>> print_packages(view)
43 trunk
44 hotter
45- Package: grumpy
46- Package: hoary
47+ Package hot: grumpy
48+ Package thunderbird: hoary
49+ Package hot: hoary
50 cold
51
52 The view provides the distro_packaging property that is a list of
53@@ -254,7 +262,8 @@
54 >>> [hoary_package] = [
55 ... package for series in view.series_batch.batch
56 ... for package in series.packagings
57- ... if package.distroseries.name == 'hoary']
58+ ... if package.distroseries.name == 'hoary' and
59+ ... package.sourcepackagename.name == 'thunderbird']
60 >>> login_person(hoary_package.sourcepackage.currentrelease.maintainer)
61 >>> view = create_initialized_view(
62 ... product, name='+packages',
63@@ -262,8 +271,9 @@
64 >>> print_packages(view)
65 trunk
66 hotter
67- Package: grumpy
68- Package: hoary
69+ Package hot: grumpy
70+ Package thunderbird: hoary
71+ Package hot: hoary
72 cold
73
74 # There are links to the +remove-packaging page.
75@@ -285,7 +295,8 @@
76 >>> print_packages(view)
77 trunk
78 hotter
79- Package: grumpy
80+ Package hot: grumpy
81+ Package hot: hoary
82 cold
83
84
85@@ -319,6 +330,7 @@
86 ... print packaging.sourcepackagename.name
87 netapplet
88 evolution
89+ hot
90
91
92 Distro series +needs-packaging view
93@@ -351,5 +363,4 @@
94 cnews
95 libstdc++
96 linux-source-2.6.15
97- hot
98 thunderbird
99
100=== modified file 'lib/lp/registry/model/productseries.py'
101--- lib/lp/registry/model/productseries.py 2011-04-12 06:21:39 +0000
102+++ lib/lp/registry/model/productseries.py 2011-04-14 14:04:14 +0000
103@@ -497,16 +497,10 @@
104 "The source package is not published in %s." %
105 distroseries.displayname)
106 for pkg in self.packagings:
107- if pkg.distroseries == distroseries:
108+ if (pkg.distroseries == distroseries and
109+ pkg.sourcepackagename == sourcepackagename):
110 # we have found a matching Packaging record
111- if pkg.sourcepackagename == sourcepackagename:
112- # and it has the same source package name
113- return pkg
114- # ok, we need to update this pkging record
115- pkg.sourcepackagename = sourcepackagename
116- pkg.owner = owner
117- pkg.datecreated = UTC_NOW
118- pkg.sync() # convert UTC_NOW to actual datetime
119+ # and it has the same source package name
120 return pkg
121
122 # ok, we didn't find a packaging record that matches, let's go ahead
123@@ -672,6 +666,7 @@
124 """
125 seriesID = self.id
126 productID = self.productID
127+
128 def weight_function(bugtask):
129 if bugtask.productseriesID == seriesID:
130 return OrderedBugTask(1, bugtask.id, bugtask)
131
132=== modified file 'lib/lp/registry/tests/test_productseries.py'
133--- lib/lp/registry/tests/test_productseries.py 2011-03-21 09:56:49 +0000
134+++ lib/lp/registry/tests/test_productseries.py 2011-04-14 14:04:14 +0000
135@@ -81,6 +81,85 @@
136 self.product_series.setPackaging(
137 self.debian_series, self.sourcepackagename, self.person)
138
139+ def makeSourcePackage(self):
140+ # Create a published sourcepackage for self.ubuntu_series.
141+ sourcepackage = self.factory.makeSourcePackage(
142+ distroseries=self.ubuntu_series)
143+ self.factory.makeSourcePackagePublishingHistory(
144+ sourcepackagename=sourcepackage.sourcepackagename,
145+ distroseries=self.ubuntu_series)
146+ return sourcepackage
147+
148+ def test_setPackaging_two_packagings(self):
149+ # More than one sourcepackage from the same distroseries
150+ # can be linked to a productseries.
151+ sourcepackage_a = self.makeSourcePackage()
152+ sourcepackage_b = self.makeSourcePackage()
153+ packaging_a = self.product_series.setPackaging(
154+ distroseries=self.ubuntu_series,
155+ sourcepackagename=sourcepackage_a.sourcepackagename,
156+ owner=self.factory.makePerson())
157+ packaging_b = self.product_series.setPackaging(
158+ distroseries=self.ubuntu_series,
159+ sourcepackagename=sourcepackage_b.sourcepackagename,
160+ owner=self.factory.makePerson())
161+ self.assertEqual(
162+ [packaging_b, packaging_a], list(self.product_series.packagings))
163+
164+ def test_setPackaging_called_for_existing_multiple_packagings(self):
165+ # Calling setPackaging for already existing packagings
166+ # does not have any effect.
167+ sourcepackage_a = self.makeSourcePackage()
168+ sourcepackage_b = self.makeSourcePackage()
169+ packaging_a = self.product_series.setPackaging(
170+ distroseries=self.ubuntu_series,
171+ sourcepackagename=sourcepackage_a.sourcepackagename,
172+ owner=self.factory.makePerson())
173+ packaging_b = self.product_series.setPackaging(
174+ distroseries=self.ubuntu_series,
175+ sourcepackagename=sourcepackage_b.sourcepackagename,
176+ owner=self.factory.makePerson())
177+ self.assertEqual(
178+ packaging_b,
179+ self.product_series.setPackaging(
180+ distroseries=self.ubuntu_series,
181+ sourcepackagename=sourcepackage_b.sourcepackagename,
182+ owner=self.factory.makePerson()))
183+ self.assertEqual(
184+ packaging_a,
185+ self.product_series.setPackaging(
186+ distroseries=self.ubuntu_series,
187+ sourcepackagename=sourcepackage_a.sourcepackagename,
188+ owner=self.factory.makePerson()))
189+ self.assertEqual(
190+ [packaging_b, packaging_a], list(self.product_series.packagings))
191+
192+ def test_setPackaging__packagings_created_by_sourcepackage(self):
193+ # Calling setPackaging for already existing packagings
194+ # created by SourcePackage.setPackaging() does not have any effect.
195+ sourcepackage_a = self.makeSourcePackage()
196+ sourcepackage_b = self.makeSourcePackage()
197+ sourcepackage_a.setPackaging(
198+ self.product_series, owner=self.factory.makePerson())
199+ sourcepackage_b.setPackaging(
200+ self.product_series, owner=self.factory.makePerson())
201+ packaging_a = sourcepackage_a.packaging
202+ packaging_b = sourcepackage_b.packaging
203+ self.assertEqual(
204+ packaging_b,
205+ self.product_series.setPackaging(
206+ distroseries=self.ubuntu_series,
207+ sourcepackagename=sourcepackage_b.sourcepackagename,
208+ owner=self.factory.makePerson()))
209+ self.assertEqual(
210+ packaging_a,
211+ self.product_series.setPackaging(
212+ distroseries=self.ubuntu_series,
213+ sourcepackagename=sourcepackage_a.sourcepackagename,
214+ owner=self.factory.makePerson()))
215+ self.assertEqual(
216+ [packaging_b, packaging_a], list(self.product_series.packagings))
217+
218
219 class TestProductSeriesGetUbuntuTranslationFocusPackage(TestCaseWithFactory):
220 """Test for ProductSeries.getUbuntuTranslationFocusPackage."""