Merge lp:~edwin-grubbs/launchpad/bug-600876-ubuntupkg-integrity-error into lp:launchpad

Proposed by Edwin Grubbs
Status: Merged
Approved by: Curtis Hovey
Approved revision: no longer in the source branch.
Merged at revision: 11116
Proposed branch: lp:~edwin-grubbs/launchpad/bug-600876-ubuntupkg-integrity-error
Merge into: lp:launchpad
Diff against target: 135 lines (+29/-28)
2 files modified
lib/lp/registry/browser/productseries.py (+10/-22)
lib/lp/registry/browser/tests/test_packaging.py (+19/-6)
To merge this branch: bzr merge lp:~edwin-grubbs/launchpad/bug-600876-ubuntupkg-integrity-error
Reviewer Review Type Date Requested Status
Curtis Hovey (community) Approve
Review via email: mp+29499@code.launchpad.net

Description of the change

Summary
-------

thunderbird-locales has packaging links for:
  Maverick -> Mozilla Thunderbird 3.1 series
  Lucid -> Mozilla Thunderbird 3.0 series

https://edge.launchpad.net/ubuntu/+source/thunderbird-locales

If you go to
    https://edge.launchpad.net/thunderbird/3.1/+ubuntupkg
and try to create packaging for 'thunderbird-locales' and
the Lucid distroseries, the view class validate() stops
checking as soon as it finds out that the sourcepackagename
is the same as the existing package on the current distroseries,
which is maverick. The action handler tries to create the packaging
link, since it is only meant to ignore the links on the same
productseries.

Implementation details
----------------------

lib/lp/registry/browser/productseries.py
lib/lp/registry/browser/tests/test_packaging.py

Tests
-----

./bin/test -vv -t test_packaging

Demo and Q/A
------------

On Dev:
* Open https://launchpad.dev/netapplet/+packages
  * Remove the package for warty, since it is on the trunk distroseries.
* Open https://launchpad.dev/netapplet/+addseries
  * Create the series.
  * Click on "Link to Ubuntu package" on the new productseries page.
  * Link it to netapplet/Warty.
* Open https://launchpad.dev/netapplet/trunk/+ubuntupkg
  * Try to link it to netapplet/Warty.
  * You should get this error message instead of an oops:
    "The netapplet package in Warty is already linked to another series."

On Edge:
* https://edge.launchpad.net/thunderbird/3.1/+ubuntupkg
  * The sourcepackagename field should say "thunderbird-locales".
  * Select Lucid from the Series drop-down.
  * Click "Update".
  * You should get an error message instead of an oops.

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank for resolving the contradictory rules to return early when the packaging will be identical (a no change op).

I think the test step is weak (70-77). It looks like it is doing two state transitions. I think the test should directly create the package, then verify that the view return without error when the user attempts to create the identical packaging.

    self.packaging_util.createPackaging(
        productseries=productseries, sourcepackagename=sourcepackagename,
        distroseries=distroseries, packaging=Packaging.PRIMARY, self.product.owner)

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/productseries.py'
2--- lib/lp/registry/browser/productseries.py 2010-05-11 17:43:20 +0000
3+++ lib/lp/registry/browser/productseries.py 2010-07-09 02:33:44 +0000
4@@ -511,33 +511,25 @@
5 sourcepackagename = data.get('sourcepackagename', None)
6 distroseries = self._getSubmittedSeries(data)
7
8- if sourcepackagename == self.default_sourcepackagename:
9- # The data has not changed, so nothing else needs to be done.
10+ packaging_util = getUtility(IPackagingUtil)
11+ if packaging_util.packagingEntryExists(
12+ productseries=productseries,
13+ sourcepackagename=sourcepackagename,
14+ distroseries=distroseries):
15+ # The package already exists. Don't display an error. The
16+ # action method will let this go by.
17 return
18
19- if sourcepackagename is None:
20- message = "You must choose the source package name."
21- self.setFieldError('sourcepackagename', message)
22 # Do not allow users to create links to unpublished Ubuntu packages.
23- elif distroseries.distribution.full_functionality:
24+ if (sourcepackagename is not None
25+ and distroseries.distribution.full_functionality):
26 source_package = distroseries.getSourcePackage(sourcepackagename)
27 if source_package.currentrelease is None:
28 message = ("The source package is not published in %s." %
29 distroseries.displayname)
30 self.setFieldError('sourcepackagename', message)
31- else:
32- pass
33- packaging_util = getUtility(IPackagingUtil)
34+
35 if packaging_util.packagingEntryExists(
36- productseries=productseries,
37- sourcepackagename=sourcepackagename,
38- distroseries=distroseries):
39- # The series packaging conflicts with itself.
40- message = _(
41- "This series is already packaged in %s." %
42- distroseries.displayname)
43- self.setFieldError('sourcepackagename', message)
44- elif packaging_util.packagingEntryExists(
45 sourcepackagename=sourcepackagename,
46 distroseries=distroseries):
47 # The series package conflicts with another series.
48@@ -550,10 +542,6 @@
49 sourcepackagename.name,
50 distroseries.displayname))
51 self.setFieldError('sourcepackagename', message)
52- else:
53- # The distroseries and sourcepackagename are not already linked
54- # to this series, or any other series.
55- pass
56
57 @action('Update', name='continue')
58 def continue_action(self, action, data):
59
60=== modified file 'lib/lp/registry/browser/tests/test_packaging.py'
61--- lib/lp/registry/browser/tests/test_packaging.py 2010-06-30 19:37:09 +0000
62+++ lib/lp/registry/browser/tests/test_packaging.py 2010-07-09 02:33:44 +0000
63@@ -10,7 +10,7 @@
64 from zope.component import getUtility
65
66 from lp.registry.interfaces.distribution import IDistributionSet
67-from lp.registry.interfaces.packaging import IPackagingUtil
68+from lp.registry.interfaces.packaging import IPackagingUtil, PackagingType
69 from lp.registry.interfaces.product import IProductSet
70 from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
71 from lp.testing import TestCaseWithFactory
72@@ -41,13 +41,30 @@
73 product=self.product, name='hotter')
74 self.packaging_util = getUtility(IPackagingUtil)
75
76+ def test_no_error_when_trying_to_readd_same_package(self):
77+ # There is no reason to display an error when the user's action
78+ # wouldn't cause a state change.
79+ self.packaging_util.createPackaging(
80+ productseries=self.productseries,
81+ sourcepackagename=self.sourcepackagename,
82+ distroseries=self.hoary, packaging=PackagingType.PRIME,
83+ owner=self.product.owner)
84+
85+ form = {
86+ 'field.distroseries': self.hoary.name,
87+ 'field.sourcepackagename': self.sourcepackagename.name,
88+ 'field.actions.continue': 'Continue',
89+ }
90+ view = create_initialized_view(
91+ self.productseries, '+ubuntupkg', form=form)
92+ self.assertEqual([], view.errors)
93+
94 def test_cannot_link_to_linked_package(self):
95 # Once a distro series sourcepackage is linked to a product series,
96 # no other product series can link to it.
97 form = {
98 'field.distroseries': 'hoary',
99 'field.sourcepackagename': 'hot',
100- 'field.packaging': 'Primary Project',
101 'field.actions.continue': 'Continue',
102 }
103 view = create_initialized_view(
104@@ -58,7 +75,6 @@
105 form = {
106 'field.distroseries': 'hoary',
107 'field.sourcepackagename': 'hot',
108- 'field.packaging': 'Primary Project',
109 'field.actions.continue': 'Continue',
110 }
111 view = create_initialized_view(
112@@ -73,7 +89,6 @@
113 form = {
114 'field.distroseries': 'hoary',
115 'field.sourcepackagename': '',
116- 'field.packaging': 'Primary Project',
117 'field.actions.continue': 'Continue',
118 }
119 view = create_initialized_view(
120@@ -89,7 +104,6 @@
121 form = {
122 'field.distroseries': 'hoary',
123 'field.sourcepackagename': 'vapor',
124- 'field.packaging': 'Primary Project',
125 'field.actions.continue': 'Continue',
126 }
127 view = create_initialized_view(
128@@ -105,7 +119,6 @@
129 form = {
130 'field.distroseries': 'warty',
131 'field.sourcepackagename': 'hot',
132- 'field.packaging': 'Primary Project',
133 'field.actions.continue': 'Continue',
134 }
135 view = create_initialized_view(