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

Proposed by Paul Hummer
Status: Merged
Approved by: Aaron Bentley
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/ihasrecipes-person
Merge into: lp:launchpad
Prerequisite: lp:~rockstar/launchpad/ihasrecipes
Diff against target: 133 lines (+56/-2)
5 files modified
lib/lp/code/model/tests/test_hasrecipes.py (+31/-0)
lib/lp/registry/interfaces/person.py (+2/-1)
lib/lp/registry/interfaces/product.py (+2/-1)
lib/lp/registry/model/person.py (+8/-0)
lib/lp/registry/model/product.py (+13/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/ihasrecipes-person
Reviewer Review Type Date Requested Status
Aaron Bentley (community) Approve
Review via email: mp+23045@code.launchpad.net

Description of the change

This branch adds IHasRecipes to IPerson and IProduct. It also, initially,
added it to IDistroSeries, but I can't think of a sane reason why you'd ever
want to see all the recipes for a DistroSeries, and the circular imports were
more trouble than it was worth.

To test:
  bin/test -vvt lp.code.model.tests.test_hasrecipes

To post a comment you must log in.
Revision history for this message
Aaron Bentley (abentley) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/model/tests/test_hasrecipes.py'
2--- lib/lp/code/model/tests/test_hasrecipes.py 2010-04-06 21:17:28 +0000
3+++ lib/lp/code/model/tests/test_hasrecipes.py 2010-04-08 19:54:40 +0000
4@@ -33,6 +33,37 @@
5 recipe_ignored = self.factory.makeSourcePackageRecipe()
6 self.assertEqual(2, base_branch.getRecipes().count())
7
8+ def test_person_implements_hasrecipes(self):
9+ # Person should implement IHasRecipes.
10+ person = self.factory.makeBranch()
11+ self.assertProvides(person, IHasRecipes)
12+
13+ def test_person_getRecipes(self):
14+ # IPerson.getRecipes should provide all the SourcePackageRecipes
15+ # owned by that person.
16+ person = self.factory.makePerson()
17+ recipe1 = self.factory.makeSourcePackageRecipe(owner=person)
18+ recipe2 = self.factory.makeSourcePackageRecipe(owner=person)
19+ recipe_ignored = self.factory.makeSourcePackageRecipe()
20+ self.assertEqual(2, person.getRecipes().count())
21+
22+ def test_product_implements_hasrecipes(self):
23+ # Product should implement IHasRecipes.
24+ product = self.factory.makeProduct()
25+ self.assertProvides(product, IHasRecipes)
26+
27+ def test_product_getRecipes(self):
28+ # IProduct.recipes should provide all the SourcePackageRecipes attached
29+ # to that product's branches.
30+ product = self.factory.makeProduct()
31+ branch = self.factory.makeBranch(product=product)
32+ recipe1 = self.factory.makeSourcePackageRecipe(
33+ None, None, None, None, None, None, branch)
34+ recipe2 = self.factory.makeSourcePackageRecipe(
35+ None, None, None, None, None, None, branch)
36+ recipe_ignored = self.factory.makeSourcePackageRecipe()
37+ self.assertEqual(2, product.getRecipes().count())
38+
39
40 def test_suite():
41 return unittest.TestLoader().loadTestsFromName(__name__)
42
43=== modified file 'lib/lp/registry/interfaces/person.py'
44--- lib/lp/registry/interfaces/person.py 2010-04-06 20:17:04 +0000
45+++ lib/lp/registry/interfaces/person.py 2010-04-08 19:54:40 +0000
46@@ -82,6 +82,7 @@
47 from lp.bugs.interfaces.bugtarget import IHasBugs
48 from lp.code.interfaces.hasbranches import (
49 IHasBranches, IHasMergeProposals, IHasRequestedReviews)
50+from lp.code.interfaces.hasrecipes import IHasRecipes
51 from lp.registry.interfaces.gpg import IGPGKey
52 from lp.registry.interfaces.irc import IIrcID
53 from lp.registry.interfaces.jabber import IJabberID
54@@ -457,7 +458,7 @@
55 class IPersonPublic(IHasBranches, IHasSpecifications, IHasMentoringOffers,
56 IHasMergeProposals, IHasLogo, IHasMugshot, IHasIcon,
57 IHasLocation, IHasRequestedReviews, IObjectWithLocation,
58- IPrivacy, IHasBugs):
59+ IPrivacy, IHasBugs, IHasRecipes):
60 """Public attributes for a Person."""
61
62 id = Int(title=_('ID'), required=True, readonly=True)
63
64=== modified file 'lib/lp/registry/interfaces/product.py'
65--- lib/lp/registry/interfaces/product.py 2010-03-24 14:29:12 +0000
66+++ lib/lp/registry/interfaces/product.py 2010-04-08 19:54:40 +0000
67@@ -44,6 +44,7 @@
68 from lp.code.interfaces.branchvisibilitypolicy import (
69 IHasBranchVisibilityPolicy)
70 from lp.code.interfaces.hasbranches import IHasBranches, IHasMergeProposals
71+from lp.code.interfaces.hasrecipes import IHasRecipes
72 from lp.bugs.interfaces.bugtarget import (
73 IBugTarget, IOfficialBugTagTargetPublic, IOfficialBugTagTargetRestricted)
74 from lp.registry.interfaces.karma import IKarmaContext
75@@ -338,7 +339,7 @@
76 IHasLogo, IHasMentoringOffers, IHasMergeProposals, IHasMilestones,
77 IHasMugshot, IHasOwner, IHasSecurityContact, IHasSprints,
78 ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
79- IOfficialBugTagTargetPublic, IPillar, ISpecificationTarget):
80+ IOfficialBugTagTargetPublic, IPillar, ISpecificationTarget, IHasRecipes):
81 """Public IProduct properties."""
82
83 # XXX Mark Shuttleworth 2004-10-12: Let's get rid of ID's in interfaces
84
85=== modified file 'lib/lp/registry/model/person.py'
86--- lib/lp/registry/model/person.py 2010-04-06 20:17:04 +0000
87+++ lib/lp/registry/model/person.py 2010-04-08 19:54:40 +0000
88@@ -2366,6 +2366,14 @@
89 from lp.hardwaredb.model.hwdb import HWSubmissionSet
90 return HWSubmissionSet().search(owner=self)
91
92+ def getRecipes(self):
93+ """See `IHasRecipes`."""
94+ from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
95+ store = Store.of(self)
96+ return store.find(
97+ SourcePackageRecipe,
98+ SourcePackageRecipe.owner == self)
99+
100
101 class PersonSet:
102 """The set of persons."""
103
104=== modified file 'lib/lp/registry/model/product.py'
105--- lib/lp/registry/model/product.py 2010-04-03 17:07:26 +0000
106+++ lib/lp/registry/model/product.py 2010-04-08 19:54:40 +0000
107@@ -34,6 +34,8 @@
108 from lp.code.model.branchvisibilitypolicy import (
109 BranchVisibilityPolicyMixin)
110 from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin
111+from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
112+from lp.code.model.sourcepackagerecipedata import SourcePackageRecipeData
113 from lp.bugs.interfaces.bugtarget import IHasBugHeat
114 from lp.bugs.model.bug import (
115 BugSet, get_bug_tags, get_bug_tags_open_count)
116@@ -1018,6 +1020,17 @@
117 if include_inactive or series.active or
118 series == self.development_focus]
119
120+ def getRecipes(self):
121+ """See `IHasRecipes`."""
122+ from lp.code.model.branch import Branch
123+ store = Store.of(self)
124+ return store.find(
125+ SourcePackageRecipe,
126+ SourcePackageRecipe.id ==
127+ SourcePackageRecipeData.sourcepackage_recipe_id,
128+ SourcePackageRecipeData.base_branch == Branch.id,
129+ Branch.product == self)
130+
131
132 class ProductSet:
133 implements(IProductSet)