~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/code/model/tests/test_hasrecipes.py

  • Committer: Ian Booth
  • Date: 2011-02-23 01:24:09 UTC
  • mto: This revision was merged to the branch mainline in revision 12459.
  • Revision ID: ian.booth@canonical.com-20110223012409-wici52rqbn1zxhtk
Change from using getter methods to properties for exported recipe and build accessors

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
 
8
8
__metaclass__ = type
9
9
 
10
 
import unittest
11
 
 
12
10
from canonical.testing.layers import DatabaseFunctionalLayer
13
11
from lp.code.interfaces.hasrecipes import IHasRecipes
14
12
from lp.testing import TestCaseWithFactory
24
22
        branch = self.factory.makeBranch()
25
23
        self.assertProvides(branch, IHasRecipes)
26
24
 
27
 
    def test_branch_getRecipes(self):
 
25
    def test_branch_recipes(self):
28
26
        # IBranch.recipes should provide all the SourcePackageRecipes attached
29
27
        # to that branch.
30
28
        base_branch = self.factory.makeBranch()
31
29
        recipe1 = self.factory.makeSourcePackageRecipe(branches=[base_branch])
32
30
        recipe2 = self.factory.makeSourcePackageRecipe(branches=[base_branch])
33
31
        recipe_ignored = self.factory.makeSourcePackageRecipe()
34
 
        self.assertEqual(2, base_branch.getRecipes().count())
 
32
        self.assertEqual(2, base_branch.recipes.count())
35
33
 
36
 
    def test_branch_getRecipes_nonbase(self):
 
34
    def test_branch_recipes_nonbase(self):
37
35
        # IBranch.recipes should provide all the SourcePackageRecipes
38
36
        # that refer to the branch, even as a non-base branch.
39
37
        base_branch = self.factory.makeBranch()
41
39
        recipe = self.factory.makeSourcePackageRecipe(
42
40
            branches=[base_branch, nonbase_branch])
43
41
        recipe_ignored = self.factory.makeSourcePackageRecipe()
44
 
        self.assertEqual(recipe, nonbase_branch.getRecipes().one())
 
42
        self.assertEqual(recipe, nonbase_branch.recipes.one())
45
43
 
46
44
    def test_person_implements_hasrecipes(self):
47
45
        # Person should implement IHasRecipes.
48
46
        person = self.factory.makeBranch()
49
47
        self.assertProvides(person, IHasRecipes)
50
48
 
51
 
    def test_person_getRecipes(self):
52
 
        # IPerson.getRecipes should provide all the SourcePackageRecipes
 
49
    def test_person_recipes(self):
 
50
        # IPerson.recipes should provide all the SourcePackageRecipes
53
51
        # owned by that person.
54
52
        person = self.factory.makePerson()
55
53
        recipe1 = self.factory.makeSourcePackageRecipe(owner=person)
56
54
        recipe2 = self.factory.makeSourcePackageRecipe(owner=person)
57
55
        recipe_ignored = self.factory.makeSourcePackageRecipe()
58
 
        self.assertEqual(2, person.getRecipes().count())
 
56
        self.assertEqual(2, person.recipes.count())
59
57
 
60
58
    def test_product_implements_hasrecipes(self):
61
59
        # Product should implement IHasRecipes.
62
60
        product = self.factory.makeProduct()
63
61
        self.assertProvides(product, IHasRecipes)
64
62
 
65
 
    def test_product_getRecipes(self):
 
63
    def test_product_recipes(self):
66
64
        # IProduct.recipes should provide all the SourcePackageRecipes
67
65
        # attached to that product's branches.
68
66
        product = self.factory.makeProduct()
70
68
        recipe1 = self.factory.makeSourcePackageRecipe(branches=[branch])
71
69
        recipe2 = self.factory.makeSourcePackageRecipe(branches=[branch])
72
70
        recipe_ignored = self.factory.makeSourcePackageRecipe()
73
 
        self.assertEqual(2, product.getRecipes().count())
74
 
 
75
 
 
76
 
def test_suite():
77
 
    return unittest.TestLoader().loadTestsFromName(__name__)
 
71
        self.assertEqual(2, product.recipes.count())