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