~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/tests/test_pillaraffiliation.py

[r=sinzui][bug=669930] Enhance the person picker to display lp name,
        irc nick and affiliation badge for each person

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright 2011 Canonical Ltd.  This software is licensed under the
 
2
# GNU Affero General Public License version 3 (see the file LICENSE).
 
3
 
 
4
"""Tests for adapters."""
 
5
 
 
6
__metaclass__ = type
 
7
 
 
8
from canonical.testing.layers import DatabaseFunctionalLayer
 
9
from lp.registry.model.pillaraffiliation import IHasAffiliation
 
10
from lp.testing import TestCaseWithFactory
 
11
 
 
12
 
 
13
class TestPillarAffiliation(TestCaseWithFactory):
 
14
 
 
15
    layer = DatabaseFunctionalLayer
 
16
 
 
17
    def test_bugtask_distro_affiliation(self):
 
18
        # A person who owns a bugtask distro is affiliated.
 
19
        person = self.factory.makePerson()
 
20
        distro = self.factory.makeDistribution(owner=person)
 
21
        bugtask = self.factory.makeBugTask(target=distro)
 
22
        badge = IHasAffiliation(bugtask).getAffiliationBadge(person)
 
23
        self.assertEqual(badge, "distribution-badge")
 
24
 
 
25
    def test_bugtask_product_affiliation(self):
 
26
        # A person who owns a bugtask product is affiliated.
 
27
        person = self.factory.makePerson()
 
28
        product = self.factory.makeProduct(owner=person)
 
29
        bugtask = self.factory.makeBugTask(target=product)
 
30
        badge = IHasAffiliation(bugtask).getAffiliationBadge(person)
 
31
        self.assertEqual(badge, "product-badge")