1
# Copyright 2011 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests for adapters."""
8
from canonical.testing.layers import DatabaseFunctionalLayer
9
from lp.registry.model.pillaraffiliation import IHasAffiliation
10
from lp.testing import TestCaseWithFactory
13
class TestPillarAffiliation(TestCaseWithFactory):
15
layer = DatabaseFunctionalLayer
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")
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")