Hi Brad,
Thanks for the review. Here are the added tests.
=== modified file 'lib/lp/registry/tests/test_sourcepackage.py' --- lib/lp/registry/tests/test_sourcepackage.py 2009-12-13 11:55:40 +0000 +++ lib/lp/registry/tests/test_sourcepackage.py 2010-02-24 03:06:12 +0000 @@ -22,6 +22,7 @@ from lp.code.interfaces.seriessourcepackagebranch import ( IMakeOfficialBranchLinks) from lp.testing import TestCaseWithFactory +from lp.testing.views import create_initialized_view from canonical.testing.layers import DatabaseFunctionalLayer
@@ -238,5 +239,79 @@ Unauthorized, sourcepackage.setBranch, pocket, branch, registrant)
+class TestSourcePackageViews(TestCaseWithFactory): + """Tests for source package view classes.""" + + layer = DatabaseFunctionalLayer + + def setUp(self): + TestCaseWithFactory.setUp(self) + self.owner = self.factory.makePerson() + self.product = self.factory.makeProduct( + name='bonkers', displayname='Bonkers', owner=self.owner) + + self.obsolete_productseries = self.factory.makeProductSeries( + name='obsolete', product=self.product) + self.obsolete_productseries.status = SeriesStatus.OBSOLETE + + self.dev_productseries = self.factory.makeProductSeries( + name='current', product=self.product) + self.dev_productseries.status = SeriesStatus.DEVELOPMENT + + self.distribution = self.factory.makeDistribution( + name='youbuntu', displayname='Youbuntu', owner=self.owner) + self.distroseries = self.factory.makeDistroRelease(name='busy', + distribution=self.distribution) + self.sourcepackagename = self.factory.makeSourcePackageName( + name='bonkers') + self.package = self.factory.makeSourcePackage( + sourcepackagename=self.sourcepackagename, + distroseries=self.distroseries) + + def test_editpackaging_obsolete_series_in_vocabulary(self): + # The sourcepackage's current product series is included in + # the vocabulary even if it is obsolete. + self.package.setPackaging(self.obsolete_productseries, self.owner) + form = { + 'field.product': 'bonkers', + 'field.actions.continue': 'Continue', + 'field.__visited_steps__': 'sourcepackage_change_upstream_step1', + } + view = create_initialized_view( + self.package, name='+edit-packaging', form=form, + principal=self.owner) + self.assertEqual([], view.view.errors) + self.assertEqual( + self.obsolete_productseries, + view.view.form_fields['productseries'].field.default, + "The form's default productseries must be the current one.") + options = [term.token + for term in view.view.widgets['productseries'].vocabulary] + self.assertEqual( + ['trunk', 'current', 'obsolete'], options, + "The obsolete series must be in the vocabulary.") + + def test_editpackaging_obsolete_series_not_in_vocabulary(self): + # Obsolete productseries are normally not in the vocabulary. + form = { + 'field.product': 'bonkers', + 'field.actions.continue': 'Continue', + 'field.__visited_steps__': 'sourcepackage_change_upstream_step1', + } + view = create_initialized_view( + self.package, name='+edit-packaging', form=form, + principal=self.owner) + self.assertEqual([], view.view.errors) + self.assertEqual( + None, + view.view.form_fields['productseries'].field.default, + "The form's default productseries must be None.") + options = [term.token + for term in view.view.widgets['productseries'].vocabulary] + self.assertEqual( + ['trunk', 'current'], options, + "The obsolete series must NOT be in the vocabulary.") + + def test_suite(): return unittest.TestLoader().loadTestsFromName(__name__)
« Back to merge proposal
Hi Brad,
Thanks for the review. Here are the added tests.
=== modified file 'lib/lp/ registry/ tests/test_ sourcepackage. py' registry/ tests/test_ sourcepackage. py 2009-12-13 11:55:40 +0000 registry/ tests/test_ sourcepackage. py 2010-02-24 03:06:12 +0000 interfaces. seriessourcepac kagebranch import ( ialBranchLinks) initialized_ view testing. layers import DatabaseFunctio nalLayer
--- lib/lp/
+++ lib/lp/
@@ -22,6 +22,7 @@
from lp.code.
IMakeOffic
from lp.testing import TestCaseWithFactory
+from lp.testing.views import create_
from canonical.
@@ -238,5 +239,79 @@
Unauthori zed, sourcepackage. setBranch, pocket, branch, registrant)
+class TestSourcePacka geViews( TestCaseWithFac tory): nalLayer tory.setUp( self) makePerson( ) makeProduct( 'Bonkers' , owner=self.owner) productseries = self.factory. makeProductSeri es( self.product) productseries. status = SeriesStatus. OBSOLETE productseries = self.factory. makeProductSeri es( self.product) productseries. status = SeriesStatus. DEVELOPMENT makeDistributio n( 'Youbuntu' , owner=self.owner) makeDistroRelea se(name= 'busy', self.distributi on) agename = self.factory. makeSourcePacka geName( makeSourcePacka ge( me=self. sourcepackagena me, self.distroseri es) ing_obsolete_ series_ in_vocabulary( self): setPackaging( self.obsolete_ productseries, self.owner) actions. continue' : 'Continue', __visited_ steps__ ': 'sourcepackage_ change_ upstream_ step1', initialized_ view( edit-packaging' , form=form, self.owner) l([], view.view.errors) productseries, form_fields[ 'productseries' ].field. default, widgets[ 'productseries' ].vocabulary] ing_obsolete_ series_ not_in_ vocabulary( self): actions. continue' : 'Continue', __visited_ steps__ ': 'sourcepackage_ change_ upstream_ step1', initialized_ view( edit-packaging' , form=form, self.owner) l([], view.view.errors) form_fields[ 'productseries' ].field. default, widgets[ 'productseries' ].vocabulary] TestLoader( ).loadTestsFrom Name(__ name__)
+ """Tests for source package view classes."""
+
+ layer = DatabaseFunctio
+
+ def setUp(self):
+ TestCaseWithFac
+ self.owner = self.factory.
+ self.product = self.factory.
+ name='bonkers', displayname=
+
+ self.obsolete_
+ name='obsolete', product=
+ self.obsolete_
+
+ self.dev_
+ name='current', product=
+ self.dev_
+
+ self.distribution = self.factory.
+ name='youbuntu', displayname=
+ self.distroseries = self.factory.
+ distribution=
+ self.sourcepack
+ name='bonkers')
+ self.package = self.factory.
+ sourcepackagena
+ distroseries=
+
+ def test_editpackag
+ # The sourcepackage's current product series is included in
+ # the vocabulary even if it is obsolete.
+ self.package.
+ form = {
+ 'field.product': 'bonkers',
+ 'field.
+ 'field.
+ }
+ view = create_
+ self.package, name='+
+ principal=
+ self.assertEqua
+ self.assertEqual(
+ self.obsolete_
+ view.view.
+ "The form's default productseries must be the current one.")
+ options = [term.token
+ for term in view.view.
+ self.assertEqual(
+ ['trunk', 'current', 'obsolete'], options,
+ "The obsolete series must be in the vocabulary.")
+
+ def test_editpackag
+ # Obsolete productseries are normally not in the vocabulary.
+ form = {
+ 'field.product': 'bonkers',
+ 'field.
+ 'field.
+ }
+ view = create_
+ self.package, name='+
+ principal=
+ self.assertEqua
+ self.assertEqual(
+ None,
+ view.view.
+ "The form's default productseries must be None.")
+ options = [term.token
+ for term in view.view.
+ self.assertEqual(
+ ['trunk', 'current'], options,
+ "The obsolete series must NOT be in the vocabulary.")
+
+
def test_suite():
return unittest.