Merge lp:~rockstar/launchpad/ihasrecipes into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Brad Crittenden
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/ihasrecipes
Merge into: lp:launchpad
Prerequisite: lp:~abentley/launchpad/recipe-index
Diff against target: 152 lines (+76/-5)
6 files modified
lib/lp/code/configure.zcml (+3/-2)
lib/lp/code/interfaces/branch.py (+3/-1)
lib/lp/code/interfaces/hasrecipes.py (+19/-0)
lib/lp/code/interfaces/sourcepackagerecipe.py (+1/-2)
lib/lp/code/model/branch.py (+12/-0)
lib/lp/code/model/tests/test_hasrecipes.py (+38/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/ihasrecipes
Reviewer Review Type Date Requested Status
Brad Crittenden (community) code Approve
Review via email: mp+22890@code.launchpad.net

Description of the change

This branch creates an IHasRecipes interface and implements it for IBranch. This is needed for the recipe listing that exist in a followup branch. It's pretty straightforward, and small for a reason.

To post a comment you must log in.
Revision history for this message
Brad Crittenden (bac) wrote :

Nice branch Paul. Looks like you have one c-n-p error:

s/test_branch_implements_hasbranches/test_branch_implements_hasrecipes/

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added directory 'lib/canonical/launchpad/apidoc'
=== modified file 'lib/lp/code/configure.zcml'
--- lib/lp/code/configure.zcml 2010-04-06 21:21:01 +0000
+++ lib/lp/code/configure.zcml 2010-04-06 21:21:07 +0000
@@ -496,11 +496,12 @@
496 getUpgradeFormat496 getUpgradeFormat
497 isBranchMergeable497 isBranchMergeable
498 visibleByUser498 visibleByUser
499 getRecipes
499 "/>500 "/>
500 <require501 <require
501 permission="launchpad.Edit"502 permission="launchpad.Edit"
502 attributes="destroySelf destroySelfBreakReferences setPrivate 503 attributes="destroySelf destroySelfBreakReferences setPrivate
503 setOwner setTarget requestUpgrade"504 setOwner setTarget requestUpgrade"
504 set_attributes="name url mirror_status_message505 set_attributes="name url mirror_status_message
505 description lifecycle_status506 description lifecycle_status
506 last_mirrored last_mirrored_id last_mirror_attempt507 last_mirrored last_mirrored_id last_mirror_attempt
507508
=== modified file 'lib/lp/code/interfaces/branch.py'
--- lib/lp/code/interfaces/branch.py 2010-03-25 02:21:15 +0000
+++ lib/lp/code/interfaces/branch.py 2010-04-06 21:21:07 +0000
@@ -70,6 +70,7 @@
70from lp.code.interfaces.branchlookup import IBranchLookup70from lp.code.interfaces.branchlookup import IBranchLookup
71from lp.code.interfaces.branchtarget import IHasBranchTarget71from lp.code.interfaces.branchtarget import IHasBranchTarget
72from lp.code.interfaces.hasbranches import IHasMergeProposals72from lp.code.interfaces.hasbranches import IHasMergeProposals
73from lp.code.interfaces.hasrecipes import IHasRecipes
73from canonical.launchpad.interfaces.launchpad import (74from canonical.launchpad.interfaces.launchpad import (
74 ILaunchpadCelebrities, IPrivacy)75 ILaunchpadCelebrities, IPrivacy)
75from lp.registry.interfaces.role import IHasOwner76from lp.registry.interfaces.role import IHasOwner
@@ -309,7 +310,8 @@
309 """A marker interface to indicate the need to show the branch menu."""310 """A marker interface to indicate the need to show the branch menu."""
310311
311312
312class IBranch(IHasOwner, IPrivacy, IHasBranchTarget, IHasMergeProposals):313class IBranch(IHasOwner, IPrivacy, IHasBranchTarget, IHasMergeProposals,
314 IHasRecipes):
313 """A Bazaar branch."""315 """A Bazaar branch."""
314316
315 # Mark branches as exported entries for the Launchpad API.317 # Mark branches as exported entries for the Launchpad API.
316318
=== added file 'lib/lp/code/interfaces/hasrecipes.py'
--- lib/lp/code/interfaces/hasrecipes.py 1970-01-01 00:00:00 +0000
+++ lib/lp/code/interfaces/hasrecipes.py 2010-04-06 21:21:07 +0000
@@ -0,0 +1,19 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Interface definitions for IHasRecipes."""
5
6__metaclass__ = type
7__all__ = [
8 'IHasRecipes',
9 ]
10
11
12from zope.interface import Attribute, Interface
13
14
15class IHasRecipes(Interface):
16 """An object that has recipes."""
17
18 def getRecipes():
19 """Returns all recipes associated with the object."""
020
=== modified file 'lib/lp/code/interfaces/sourcepackagerecipe.py'
--- lib/lp/code/interfaces/sourcepackagerecipe.py 2010-04-06 21:21:01 +0000
+++ lib/lp/code/interfaces/sourcepackagerecipe.py 2010-04-06 21:21:07 +0000
@@ -3,7 +3,6 @@
33
4# pylint: disable-msg=E0211,E02134# pylint: disable-msg=E0211,E0213
55
6
7"""Interface of the `SourcePackageRecipe` content type."""6"""Interface of the `SourcePackageRecipe` content type."""
87
98
@@ -22,7 +21,7 @@
22from lazr.restful.fields import CollectionField, Reference21from lazr.restful.fields import CollectionField, Reference
2322
24from zope.interface import Attribute, Interface23from zope.interface import Attribute, Interface
25from zope.schema import Bool, Datetime, Object, TextLine, Text24from zope.schema import Bool, Datetime, Object, Text, TextLine
2625
27from canonical.launchpad import _26from canonical.launchpad import _
28from canonical.launchpad.validators.name import name_validator27from canonical.launchpad.validators.name import name_validator
2928
=== modified file 'lib/lp/code/model/branch.py'
--- lib/lp/code/model/branch.py 2010-03-11 14:29:15 +0000
+++ lib/lp/code/model/branch.py 2010-04-06 21:21:07 +0000
@@ -1065,6 +1065,18 @@
1065 user, checked_branches)1065 user, checked_branches)
1066 return can_access1066 return can_access
10671067
1068 def getRecipes(self):
1069 """See `IHasRecipes`."""
1070 from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
1071 from lp.code.model.sourcepackagerecipedata import (
1072 SourcePackageRecipeData)
1073 store = Store.of(self)
1074 return store.find(
1075 SourcePackageRecipe,
1076 SourcePackageRecipe.id ==
1077 SourcePackageRecipeData.sourcepackage_recipe_id,
1078 SourcePackageRecipeData.base_branch == self)
1079
10681080
1069class DeletionOperation:1081class DeletionOperation:
1070 """Represent an operation to perform as part of branch deletion."""1082 """Represent an operation to perform as part of branch deletion."""
10711083
=== added file 'lib/lp/code/model/tests/test_hasrecipes.py'
--- lib/lp/code/model/tests/test_hasrecipes.py 1970-01-01 00:00:00 +0000
+++ lib/lp/code/model/tests/test_hasrecipes.py 2010-04-06 21:21:07 +0000
@@ -0,0 +1,38 @@
1# Copyright 2010 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).
3
4"""Tests for classes that implement IHasRecipes."""
5
6__metaclass__ = type
7
8import unittest
9
10from canonical.testing import DatabaseFunctionalLayer
11from lp.code.interfaces.hasrecipes import IHasRecipes
12from lp.testing import TestCaseWithFactory
13
14
15class TestIHasRecipes(TestCaseWithFactory):
16 """Test that the correct objects implement the interface."""
17
18 layer = DatabaseFunctionalLayer
19
20 def test_branch_implements_hasrecipes(self):
21 # Branches should implement IHasRecipes.
22 branch = self.factory.makeBranch()
23 self.assertProvides(branch, IHasRecipes)
24
25 def test_branch_getRecipes(self):
26 # IBranch.recipes should provide all the SourcePackageRecipes attached
27 # to that branch.
28 base_branch = self.factory.makeBranch()
29 recipe1 = self.factory.makeSourcePackageRecipe(
30 None, None, None, None, None, None, base_branch)
31 recipe2 = self.factory.makeSourcePackageRecipe(
32 None, None, None, None, None, None, base_branch)
33 recipe_ignored = self.factory.makeSourcePackageRecipe()
34 self.assertEqual(2, base_branch.getRecipes().count())
35
36
37def test_suite():
38 return unittest.TestLoader().loadTestsFromName(__name__)