1
# Copyright 2009-2010 Canonical Ltd. This software is licensed under the
2
# GNU Affero General Public License version 3 (see the file LICENSE).
4
"""Tests related to bug nominations for an object with a bug supervisor."""
8
from canonical.launchpad.ftests import (
13
from canonical.testing.layers import DatabaseFunctionalLayer
15
from lp.bugs.interfaces.bugnomination import NominationError
16
from lp.testing import TestCaseWithFactory
19
class AddNominationTestMixin:
20
"""Test case mixin for IBug.addNomination."""
22
layer = DatabaseFunctionalLayer
25
super(AddNominationTestMixin, self).setUp()
26
login('foo.bar@canonical.com')
27
self.user = self.factory.makePerson(name='ordinary-user')
28
self.bug_supervisor = self.factory.makePerson(name='no-ordinary-user')
29
self.owner = self.factory.makePerson(name='extraordinary-user')
35
super(AddNominationTestMixin, self).tearDown()
37
def test_user_addNominationFor_series(self):
38
# A bug may not be nominated for a series of a product with an
39
# existing task by just anyone.
40
login_person(self.user)
41
self.assertRaises(NominationError,
42
self.bug.addNomination, self.user, self.series)
44
def test_bugsupervisor_addNominationFor_series(self):
45
# A bug may be nominated for a series of a product with an
46
# exisiting task by the product's bug supervisor.
47
login_person(self.bug_supervisor)
48
self.bug.addNomination(self.bug_supervisor, self.series)
49
self.assertTrue(len(self.bug.getNominations()), 1)
51
def test_owner_addNominationFor_series(self):
52
# A bug may be nominated for a series of a product with an
53
# exisiting task by the product's owner.
54
login_person(self.owner)
55
self.bug.addNomination(self.owner, self.series)
56
self.assertTrue(len(self.bug.getNominations()), 1)
59
class TestBugAddNominationProductSeries(
60
AddNominationTestMixin, TestCaseWithFactory):
61
"""Test IBug.addNomination for IProductSeries nominations."""
63
def setUpTarget(self):
64
self.product = self.factory.makeProduct(official_malone = True,
65
bug_supervisor=self.bug_supervisor,
67
self.series = self.factory.makeProductSeries(product=self.product)
68
self.bug = self.factory.makeBug(product=self.product)
69
self.milestone = self.factory.makeMilestone(productseries=self.series)
72
class TestBugAddNominationDistroSeries(
73
AddNominationTestMixin, TestCaseWithFactory):
74
"""Test IBug.addNomination for IDistroSeries nominations."""
76
def setUpTarget(self):
77
self.distro = self.factory.makeDistribution(
78
bug_supervisor=self.bug_supervisor,
80
self.series = self.factory.makeDistroRelease(distribution=self.distro)
81
# The factory can't create a distro bug directly.
82
self.bug = self.factory.makeBug()
83
self.bug.addTask(self.bug_supervisor, self.distro)
84
self.milestone = self.factory.makeMilestone(
85
distribution=self.distro)