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
=== modified file 'lib/lp/code/model/tests/test_hasrecipes.py'
--- lib/lp/code/model/tests/test_hasrecipes.py 2010-04-06 21:17:28 +0000
+++ lib/lp/code/model/tests/test_hasrecipes.py 2010-04-08 19:54:40 +0000
@@ -33,6 +33,37 @@
33 recipe_ignored = self.factory.makeSourcePackageRecipe()33 recipe_ignored = self.factory.makeSourcePackageRecipe()
34 self.assertEqual(2, base_branch.getRecipes().count())34 self.assertEqual(2, base_branch.getRecipes().count())
3535
36 def test_person_implements_hasrecipes(self):
37 # Person should implement IHasRecipes.
38 person = self.factory.makeBranch()
39 self.assertProvides(person, IHasRecipes)
40
41 def test_person_getRecipes(self):
42 # IPerson.getRecipes should provide all the SourcePackageRecipes
43 # owned by that person.
44 person = self.factory.makePerson()
45 recipe1 = self.factory.makeSourcePackageRecipe(owner=person)
46 recipe2 = self.factory.makeSourcePackageRecipe(owner=person)
47 recipe_ignored = self.factory.makeSourcePackageRecipe()
48 self.assertEqual(2, person.getRecipes().count())
49
50 def test_product_implements_hasrecipes(self):
51 # Product should implement IHasRecipes.
52 product = self.factory.makeProduct()
53 self.assertProvides(product, IHasRecipes)
54
55 def test_product_getRecipes(self):
56 # IProduct.recipes should provide all the SourcePackageRecipes attached
57 # to that product's branches.
58 product = self.factory.makeProduct()
59 branch = self.factory.makeBranch(product=product)
60 recipe1 = self.factory.makeSourcePackageRecipe(
61 None, None, None, None, None, None, branch)
62 recipe2 = self.factory.makeSourcePackageRecipe(
63 None, None, None, None, None, None, branch)
64 recipe_ignored = self.factory.makeSourcePackageRecipe()
65 self.assertEqual(2, product.getRecipes().count())
66
3667
37def test_suite():68def test_suite():
38 return unittest.TestLoader().loadTestsFromName(__name__)69 return unittest.TestLoader().loadTestsFromName(__name__)
3970
=== modified file 'lib/lp/registry/interfaces/person.py'
--- lib/lp/registry/interfaces/person.py 2010-04-06 20:17:04 +0000
+++ lib/lp/registry/interfaces/person.py 2010-04-08 19:54:40 +0000
@@ -82,6 +82,7 @@
82from lp.bugs.interfaces.bugtarget import IHasBugs82from lp.bugs.interfaces.bugtarget import IHasBugs
83from lp.code.interfaces.hasbranches import (83from lp.code.interfaces.hasbranches import (
84 IHasBranches, IHasMergeProposals, IHasRequestedReviews)84 IHasBranches, IHasMergeProposals, IHasRequestedReviews)
85from lp.code.interfaces.hasrecipes import IHasRecipes
85from lp.registry.interfaces.gpg import IGPGKey86from lp.registry.interfaces.gpg import IGPGKey
86from lp.registry.interfaces.irc import IIrcID87from lp.registry.interfaces.irc import IIrcID
87from lp.registry.interfaces.jabber import IJabberID88from lp.registry.interfaces.jabber import IJabberID
@@ -457,7 +458,7 @@
457class IPersonPublic(IHasBranches, IHasSpecifications, IHasMentoringOffers,458class IPersonPublic(IHasBranches, IHasSpecifications, IHasMentoringOffers,
458 IHasMergeProposals, IHasLogo, IHasMugshot, IHasIcon,459 IHasMergeProposals, IHasLogo, IHasMugshot, IHasIcon,
459 IHasLocation, IHasRequestedReviews, IObjectWithLocation,460 IHasLocation, IHasRequestedReviews, IObjectWithLocation,
460 IPrivacy, IHasBugs):461 IPrivacy, IHasBugs, IHasRecipes):
461 """Public attributes for a Person."""462 """Public attributes for a Person."""
462463
463 id = Int(title=_('ID'), required=True, readonly=True)464 id = Int(title=_('ID'), required=True, readonly=True)
464465
=== modified file 'lib/lp/registry/interfaces/product.py'
--- lib/lp/registry/interfaces/product.py 2010-03-24 14:29:12 +0000
+++ lib/lp/registry/interfaces/product.py 2010-04-08 19:54:40 +0000
@@ -44,6 +44,7 @@
44from lp.code.interfaces.branchvisibilitypolicy import (44from lp.code.interfaces.branchvisibilitypolicy import (
45 IHasBranchVisibilityPolicy)45 IHasBranchVisibilityPolicy)
46from lp.code.interfaces.hasbranches import IHasBranches, IHasMergeProposals46from lp.code.interfaces.hasbranches import IHasBranches, IHasMergeProposals
47from lp.code.interfaces.hasrecipes import IHasRecipes
47from lp.bugs.interfaces.bugtarget import (48from lp.bugs.interfaces.bugtarget import (
48 IBugTarget, IOfficialBugTagTargetPublic, IOfficialBugTagTargetRestricted)49 IBugTarget, IOfficialBugTagTargetPublic, IOfficialBugTagTargetRestricted)
49from lp.registry.interfaces.karma import IKarmaContext50from lp.registry.interfaces.karma import IKarmaContext
@@ -338,7 +339,7 @@
338 IHasLogo, IHasMentoringOffers, IHasMergeProposals, IHasMilestones,339 IHasLogo, IHasMentoringOffers, IHasMergeProposals, IHasMilestones,
339 IHasMugshot, IHasOwner, IHasSecurityContact, IHasSprints,340 IHasMugshot, IHasOwner, IHasSecurityContact, IHasSprints,
340 ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,341 ITranslationPolicy, IKarmaContext, ILaunchpadUsage, IMakesAnnouncements,
341 IOfficialBugTagTargetPublic, IPillar, ISpecificationTarget):342 IOfficialBugTagTargetPublic, IPillar, ISpecificationTarget, IHasRecipes):
342 """Public IProduct properties."""343 """Public IProduct properties."""
343344
344 # XXX Mark Shuttleworth 2004-10-12: Let's get rid of ID's in interfaces345 # XXX Mark Shuttleworth 2004-10-12: Let's get rid of ID's in interfaces
345346
=== modified file 'lib/lp/registry/model/person.py'
--- lib/lp/registry/model/person.py 2010-04-06 20:17:04 +0000
+++ lib/lp/registry/model/person.py 2010-04-08 19:54:40 +0000
@@ -2366,6 +2366,14 @@
2366 from lp.hardwaredb.model.hwdb import HWSubmissionSet2366 from lp.hardwaredb.model.hwdb import HWSubmissionSet
2367 return HWSubmissionSet().search(owner=self)2367 return HWSubmissionSet().search(owner=self)
23682368
2369 def getRecipes(self):
2370 """See `IHasRecipes`."""
2371 from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
2372 store = Store.of(self)
2373 return store.find(
2374 SourcePackageRecipe,
2375 SourcePackageRecipe.owner == self)
2376
23692377
2370class PersonSet:2378class PersonSet:
2371 """The set of persons."""2379 """The set of persons."""
23722380
=== modified file 'lib/lp/registry/model/product.py'
--- lib/lp/registry/model/product.py 2010-04-03 17:07:26 +0000
+++ lib/lp/registry/model/product.py 2010-04-08 19:54:40 +0000
@@ -34,6 +34,8 @@
34from lp.code.model.branchvisibilitypolicy import (34from lp.code.model.branchvisibilitypolicy import (
35 BranchVisibilityPolicyMixin)35 BranchVisibilityPolicyMixin)
36from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin36from lp.code.model.hasbranches import HasBranchesMixin, HasMergeProposalsMixin
37from lp.code.model.sourcepackagerecipe import SourcePackageRecipe
38from lp.code.model.sourcepackagerecipedata import SourcePackageRecipeData
37from lp.bugs.interfaces.bugtarget import IHasBugHeat39from lp.bugs.interfaces.bugtarget import IHasBugHeat
38from lp.bugs.model.bug import (40from lp.bugs.model.bug import (
39 BugSet, get_bug_tags, get_bug_tags_open_count)41 BugSet, get_bug_tags, get_bug_tags_open_count)
@@ -1018,6 +1020,17 @@
1018 if include_inactive or series.active or1020 if include_inactive or series.active or
1019 series == self.development_focus]1021 series == self.development_focus]
10201022
1023 def getRecipes(self):
1024 """See `IHasRecipes`."""
1025 from lp.code.model.branch import Branch
1026 store = Store.of(self)
1027 return store.find(
1028 SourcePackageRecipe,
1029 SourcePackageRecipe.id ==
1030 SourcePackageRecipeData.sourcepackage_recipe_id,
1031 SourcePackageRecipeData.base_branch == Branch.id,
1032 Branch.product == self)
1033
10211034
1022class ProductSet:1035class ProductSet:
1023 implements(IProductSet)1036 implements(IProductSet)