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
=== modified file 'lib/lp/registry/browser/productseries.py'
--- lib/lp/registry/browser/productseries.py 2010-05-11 17:43:20 +0000
+++ lib/lp/registry/browser/productseries.py 2010-07-09 02:33:44 +0000
@@ -511,33 +511,25 @@
511 sourcepackagename = data.get('sourcepackagename', None)511 sourcepackagename = data.get('sourcepackagename', None)
512 distroseries = self._getSubmittedSeries(data)512 distroseries = self._getSubmittedSeries(data)
513513
514 if sourcepackagename == self.default_sourcepackagename:514 packaging_util = getUtility(IPackagingUtil)
515 # The data has not changed, so nothing else needs to be done.515 if packaging_util.packagingEntryExists(
516 productseries=productseries,
517 sourcepackagename=sourcepackagename,
518 distroseries=distroseries):
519 # The package already exists. Don't display an error. The
520 # action method will let this go by.
516 return521 return
517522
518 if sourcepackagename is None:
519 message = "You must choose the source package name."
520 self.setFieldError('sourcepackagename', message)
521 # Do not allow users to create links to unpublished Ubuntu packages.523 # Do not allow users to create links to unpublished Ubuntu packages.
522 elif distroseries.distribution.full_functionality:524 if (sourcepackagename is not None
525 and distroseries.distribution.full_functionality):
523 source_package = distroseries.getSourcePackage(sourcepackagename)526 source_package = distroseries.getSourcePackage(sourcepackagename)
524 if source_package.currentrelease is None:527 if source_package.currentrelease is None:
525 message = ("The source package is not published in %s." %528 message = ("The source package is not published in %s." %
526 distroseries.displayname)529 distroseries.displayname)
527 self.setFieldError('sourcepackagename', message)530 self.setFieldError('sourcepackagename', message)
528 else:531
529 pass
530 packaging_util = getUtility(IPackagingUtil)
531 if packaging_util.packagingEntryExists(532 if packaging_util.packagingEntryExists(
532 productseries=productseries,
533 sourcepackagename=sourcepackagename,
534 distroseries=distroseries):
535 # The series packaging conflicts with itself.
536 message = _(
537 "This series is already packaged in %s." %
538 distroseries.displayname)
539 self.setFieldError('sourcepackagename', message)
540 elif packaging_util.packagingEntryExists(
541 sourcepackagename=sourcepackagename,533 sourcepackagename=sourcepackagename,
542 distroseries=distroseries):534 distroseries=distroseries):
543 # The series package conflicts with another series.535 # The series package conflicts with another series.
@@ -550,10 +542,6 @@
550 sourcepackagename.name,542 sourcepackagename.name,
551 distroseries.displayname))543 distroseries.displayname))
552 self.setFieldError('sourcepackagename', message)544 self.setFieldError('sourcepackagename', message)
553 else:
554 # The distroseries and sourcepackagename are not already linked
555 # to this series, or any other series.
556 pass
557545
558 @action('Update', name='continue')546 @action('Update', name='continue')
559 def continue_action(self, action, data):547 def continue_action(self, action, data):
560548
=== modified file 'lib/lp/registry/browser/tests/test_packaging.py'
--- lib/lp/registry/browser/tests/test_packaging.py 2010-06-30 19:37:09 +0000
+++ lib/lp/registry/browser/tests/test_packaging.py 2010-07-09 02:33:44 +0000
@@ -10,7 +10,7 @@
10from zope.component import getUtility10from zope.component import getUtility
1111
12from lp.registry.interfaces.distribution import IDistributionSet12from lp.registry.interfaces.distribution import IDistributionSet
13from lp.registry.interfaces.packaging import IPackagingUtil13from lp.registry.interfaces.packaging import IPackagingUtil, PackagingType
14from lp.registry.interfaces.product import IProductSet14from lp.registry.interfaces.product import IProductSet
15from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet15from lp.registry.interfaces.sourcepackagename import ISourcePackageNameSet
16from lp.testing import TestCaseWithFactory16from lp.testing import TestCaseWithFactory
@@ -41,13 +41,30 @@
41 product=self.product, name='hotter')41 product=self.product, name='hotter')
42 self.packaging_util = getUtility(IPackagingUtil)42 self.packaging_util = getUtility(IPackagingUtil)
4343
44 def test_no_error_when_trying_to_readd_same_package(self):
45 # There is no reason to display an error when the user's action
46 # wouldn't cause a state change.
47 self.packaging_util.createPackaging(
48 productseries=self.productseries,
49 sourcepackagename=self.sourcepackagename,
50 distroseries=self.hoary, packaging=PackagingType.PRIME,
51 owner=self.product.owner)
52
53 form = {
54 'field.distroseries': self.hoary.name,
55 'field.sourcepackagename': self.sourcepackagename.name,
56 'field.actions.continue': 'Continue',
57 }
58 view = create_initialized_view(
59 self.productseries, '+ubuntupkg', form=form)
60 self.assertEqual([], view.errors)
61
44 def test_cannot_link_to_linked_package(self):62 def test_cannot_link_to_linked_package(self):
45 # Once a distro series sourcepackage is linked to a product series,63 # Once a distro series sourcepackage is linked to a product series,
46 # no other product series can link to it.64 # no other product series can link to it.
47 form = {65 form = {
48 'field.distroseries': 'hoary',66 'field.distroseries': 'hoary',
49 'field.sourcepackagename': 'hot',67 'field.sourcepackagename': 'hot',
50 'field.packaging': 'Primary Project',
51 'field.actions.continue': 'Continue',68 'field.actions.continue': 'Continue',
52 }69 }
53 view = create_initialized_view(70 view = create_initialized_view(
@@ -58,7 +75,6 @@
58 form = {75 form = {
59 'field.distroseries': 'hoary',76 'field.distroseries': 'hoary',
60 'field.sourcepackagename': 'hot',77 'field.sourcepackagename': 'hot',
61 'field.packaging': 'Primary Project',
62 'field.actions.continue': 'Continue',78 'field.actions.continue': 'Continue',
63 }79 }
64 view = create_initialized_view(80 view = create_initialized_view(
@@ -73,7 +89,6 @@
73 form = {89 form = {
74 'field.distroseries': 'hoary',90 'field.distroseries': 'hoary',
75 'field.sourcepackagename': '',91 'field.sourcepackagename': '',
76 'field.packaging': 'Primary Project',
77 'field.actions.continue': 'Continue',92 'field.actions.continue': 'Continue',
78 }93 }
79 view = create_initialized_view(94 view = create_initialized_view(
@@ -89,7 +104,6 @@
89 form = {104 form = {
90 'field.distroseries': 'hoary',105 'field.distroseries': 'hoary',
91 'field.sourcepackagename': 'vapor',106 'field.sourcepackagename': 'vapor',
92 'field.packaging': 'Primary Project',
93 'field.actions.continue': 'Continue',107 'field.actions.continue': 'Continue',
94 }108 }
95 view = create_initialized_view(109 view = create_initialized_view(
@@ -105,7 +119,6 @@
105 form = {119 form = {
106 'field.distroseries': 'warty',120 'field.distroseries': 'warty',
107 'field.sourcepackagename': 'hot',121 'field.sourcepackagename': 'hot',
108 'field.packaging': 'Primary Project',
109 'field.actions.continue': 'Continue',122 'field.actions.continue': 'Continue',
110 }123 }
111 view = create_initialized_view(124 view = create_initialized_view(