Merge lp:~leonardr/launchpad/publish-distro-series-for-recipe into lp:launchpad

Proposed by Tim Penhey on 2011-02-23
Status: Work in progress
Proposed branch: lp:~leonardr/launchpad/publish-distro-series-for-recipe
Merge into: lp:launchpad
Diff against target: 107 lines (+73/-4)
3 files modified
lib/lp/code/interfaces/sourcepackagerecipe.py (+25/-4)
lib/lp/code/model/sourcepackagerecipe.py (+8/-0)
lib/lp/code/tests/test_recipe_webservice.py (+40/-0)
To merge this branch: bzr merge lp:~leonardr/launchpad/publish-distro-series-for-recipe
Reviewer Review Type Date Requested Status
Launchpad code reviewers 2011-02-23 Pending
Review via email: mp+50996@code.launchpad.net
To post a comment you must log in.

Unmerged revisions

12444. By Leonard Richardson on 2011-02-23

Added fake implementations of addDistroSeries and removeDistroSeries.

12443. By Leonard Richardson on 2011-02-23

Published the distroseries in the web service starting in version devel.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
2--- lib/lp/code/interfaces/sourcepackagerecipe.py 2011-02-22 23:07:17 +0000
3+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2011-02-23 20:46:44 +0000
4@@ -179,10 +179,11 @@
5 vocabulary='UserTeamsParticipationPlusSelf',
6 description=_("The person or team who can edit this recipe.")))
7
8- distroseries = CollectionField(
9- Reference(IDistroSeries), title=_("The distroseries this recipe will"
10- " build a source package for"),
11- readonly=False)
12+ distroseries = exported(CollectionField(
13+ value_type=Reference(schema=IDistroSeries),
14+ title=_("This recipe will build a source package for these "
15+ "distroseries."),
16+ readonly=False), (("devel", dict(exported=True))), exported=False)
17 build_daily = exported(Bool(
18 title=_("Built daily"),
19 description=_("Automatically build each day, if the source has changed.")))
20@@ -203,6 +204,26 @@
21
22 is_stale = Bool(title=_('Recipe is stale.'))
23
24+ @operation_parameters(distro_series=Reference(schema=IDistroSeries))
25+ @export_write_operation()
26+ @operation_for_version("devel")
27+ def addDistroSeries(distro_series):
28+ """Start building source packages for an additional distro series.
29+
30+ :param distroseries: The distro series for which source
31+ packages should be built.
32+ """
33+
34+ @operation_parameters(distro_series=Reference(schema=IDistroSeries))
35+ @export_write_operation()
36+ @operation_for_version("devel")
37+ def removeDistroSeries(distro_series):
38+ """Stop building source packages for a given distro series.
39+
40+ :param distroseries: The distro series for which source
41+ packages should no longer be built.
42+ """
43+
44
45 class ISourcePackageRecipe(ISourcePackageRecipeData,
46 ISourcePackageRecipeEdit, ISourcePackageRecipeEditableAttributes,
47
48=== modified file 'lib/lp/code/model/sourcepackagerecipe.py'
49--- lib/lp/code/model/sourcepackagerecipe.py 2011-02-19 00:30:04 +0000
50+++ lib/lp/code/model/sourcepackagerecipe.py 2011-02-23 20:46:44 +0000
51@@ -342,3 +342,11 @@
52 return None
53 durations.sort(reverse=True)
54 return durations[len(durations) / 2]
55+
56+ def addDistroSeries(self, distro_series):
57+ """Add a distroseries to the list of series that get builds."""
58+ pass
59+
60+ def removeDistroSeries(self, distro_series):
61+ """Add a distroseries to the list of series that get builds."""
62+ pass
63
64=== added file 'lib/lp/code/tests/test_recipe_webservice.py'
65--- lib/lp/code/tests/test_recipe_webservice.py 1970-01-01 00:00:00 +0000
66+++ lib/lp/code/tests/test_recipe_webservice.py 2011-02-23 20:46:44 +0000
67@@ -0,0 +1,40 @@
68+# Copyright 2011 Canonical Ltd. This software is licensed under the
69+# GNU Affero General Public License version 3 (see the file LICENSE).
70+
71+__metaclass__ = type
72+
73+from canonical.testing.layers import DatabaseFunctionalLayer
74+from lp.testing import (
75+ launchpadlib_for,
76+ login_person,
77+ logout,
78+ TestCaseWithFactory,
79+ )
80+
81+
82+class TestRecipeDistroSeries(TestCaseWithFactory):
83+
84+ layer = DatabaseFunctionalLayer
85+
86+ def setUp(self):
87+ super(TestRecipeDistroSeries, self).setUp()
88+ recipe = self.factory.makeSourcePackageRecipe()
89+ self.recipe_name = recipe.name
90+ self.owner_name = recipe.owner.name
91+
92+ def test_distroseries_present_in_devel(self):
93+ lp = launchpadlib_for("test", self.owner_name, version="devel")
94+ recipe = lp.me.getRecipe(name=self.recipe_name)
95+ self.assertEqual(len(recipe.distroseries), 1)
96+
97+ def test_distroseries_not_present_in_10(self):
98+ lp = launchpadlib_for("test", self.owner_name, version="1.0")
99+ recipe_in_10 = lp.me.getRecipe(name=self.recipe_name)
100+ self.assertFalse(hasattr(recipe_in_10, 'distroseries'))
101+
102+ def test_add_distroseries(self):
103+ series = self.factory.makeSourcePackageRecipeDistroseries()
104+ lp = launchpadlib_for("test", self.owner_name, version="devel")
105+ recipe = lp.me.getRecipe(name=self.recipe_name)
106+ distro_series = lp.distributions['ubuntu'].getSeries(name_or_version='warty')
107+ recipe.addDistroSeries(distro_series=distro_series)