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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
__metaclass__ = type
import unittest
from zope.component import getUtility
from canonical.launchpad.webapp.publisher import canonical_url
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.testing import login_person
from lp.testing.breadcrumbs import BaseBreadcrumbTestCase
class TestDistroseriesBreadcrumb(BaseBreadcrumbTestCase):
"""Test breadcrumbs for an `IDistroseries`."""
def setUp(self):
super(TestDistroseriesBreadcrumb, self).setUp()
self.distribution = self.factory.makeDistribution(
name='youbuntu', displayname='Youbuntu')
self.distroseries = self.factory.makeDistroRelease(
name='groovy', version="1.06", distribution=self.distribution)
self.distroseries_url = canonical_url(self.distroseries)
def test_distroseries(self):
crumbs = self.getBreadcrumbsForObject(self.distroseries)
last_crumb = crumbs[-1]
self.assertEqual(self.distroseries.named_version, last_crumb.text)
class TestDistributionMirrorBreadcrumb(BaseBreadcrumbTestCase):
"""Test breadcrumbs for an `IDistributionMirror`."""
def setUp(self):
super(TestDistributionMirrorBreadcrumb, self).setUp()
self.distribution = getUtility(ILaunchpadCelebrities).ubuntu
def test_distributionmirror_withDisplayName(self):
# If a displayname is given, the breadcrumb text will be the
# displayname.
displayname = "Akbar and Jeff's Hut of Mirrors"
mirror = self.factory.makeMirror(
distribution=self.distribution,
displayname=displayname)
crumbs = self.getBreadcrumbsForObject(mirror)
last_crumb = crumbs[-1]
self.assertEqual(displayname, last_crumb.text)
def test_distributionmirror_withHttpUrl(self):
# If no displayname, the breadcrumb text will be the mirror name,
# which is derived from the URL.
http_url = "http://example.com/akbar"
mirror = self.factory.makeMirror(
distribution=self.distribution,
displayname=None,
http_url=http_url)
crumbs = self.getBreadcrumbsForObject(mirror)
last_crumb = crumbs[-1]
self.assertEqual(mirror.displayname, last_crumb.text)
def test_distributionmirror_withFtpUrl(self):
# If no displayname, the breadcrumb text will be the mirror name,
# which is derived from the URL.
ftp_url = "ftp://example.com/jeff"
mirror = self.factory.makeMirror(
distribution=self.distribution,
displayname=None,
ftp_url=ftp_url)
crumbs = self.getBreadcrumbsForObject(mirror)
last_crumb = crumbs[-1]
self.assertEqual(mirror.displayname, last_crumb.text)
class TestMilestoneBreadcrumb(BaseBreadcrumbTestCase):
"""Test the breadcrumbs for an `IMilestone`."""
def setUp(self):
super(TestMilestoneBreadcrumb, self).setUp()
self.project = self.factory.makeProduct()
self.series = self.factory.makeProductSeries(product=self.project)
self.milestone = self.factory.makeMilestone(
productseries=self.series, name="1.1")
self.milestone_url = canonical_url(self.milestone)
def test_milestone_without_code_name(self):
crumbs = self.getBreadcrumbsForObject(self.milestone)
last_crumb = crumbs[-1]
self.assertEqual(self.milestone.name, last_crumb.text)
def test_milestone_with_code_name(self):
login_person(self.milestone.productseries.product.owner)
self.milestone.code_name = "duck"
crumbs = self.getBreadcrumbsForObject(self.milestone)
last_crumb = crumbs[-1]
expected_text = '%s "%s"' % (
self.milestone.name, self.milestone.code_name)
self.assertEqual(expected_text, last_crumb.text)
def test_productrelease(self):
release = self.factory.makeProductRelease(milestone=self.milestone)
crumbs = self.getBreadcrumbsForObject(release)
last_crumb = crumbs[-1]
self.assertEqual(self.milestone.name, last_crumb.text)
class TestPollBreadcrumb(BaseBreadcrumbTestCase):
"""Test breadcrumbs for an `IPoll`."""
def setUp(self):
super(TestPollBreadcrumb, self).setUp()
self.team = self.factory.makeTeam(displayname="Poll Team")
name = "pollo-poll"
title = "Marco Pollo"
proposition = "Be mine"
self.poll = self.factory.makePoll(
team=self.team,
name=name,
title=title,
proposition=proposition)
def test_poll(self):
crumbs = self.getBreadcrumbsForObject(self.poll)
last_crumb = crumbs[-1]
self.assertEqual(self.poll.title, last_crumb.text)
from lp.registry.interfaces.nameblacklist import INameBlacklistSet
class TestNameblacklistBreadcrumb(BaseBreadcrumbTestCase):
"""Test breadcrumbs for +nameblacklist."""
def setUp(self):
super(TestNameblacklistBreadcrumb, self).setUp()
self.name_blacklist_set = getUtility(INameBlacklistSet)
self.registry_expert = self.factory.makeRegistryExpert()
login_person(self.registry_expert)
def test_nameblacklist(self):
expected = [('Name Blacklist', 'http://launchpad.dev/+nameblacklist')]
self.assertBreadcrumbs(expected, self.name_blacklist_set)
def test_nameblacklist_edit(self):
blacklist = self.name_blacklist_set.getByRegExp(u'blacklist')
expected = [
('Name Blacklist',
'http://launchpad.dev/+nameblacklist'),
('Edit a blacklist expression',
'http://launchpad.dev/+nameblacklist/1/+edit'),
]
self.assertBreadcrumbs(expected, blacklist, view_name='+edit')
def test_suite():
return unittest.TestLoader().loadTestsFromName(__name__)
|