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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
|
# Copyright 2009 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Test Packageset features."""
from zope.component import getUtility
from canonical.testing.layers import LaunchpadZopelessLayer
from lp.registry.interfaces.distribution import IDistributionSet
from lp.registry.interfaces.series import SeriesStatus
from lp.soyuz.interfaces.packageset import (
DuplicatePackagesetName,
IPackagesetSet,
)
from lp.testing import TestCaseWithFactory
class TestPackagesetSet(TestCaseWithFactory):
layer = LaunchpadZopelessLayer
def setUp(self):
"""Setup a distribution with multiple distroseries."""
super(TestPackagesetSet, self).setUp()
self.distribution = getUtility(IDistributionSet).getByName(
'ubuntu')
self.distroseries_current = self.distribution.currentseries
self.distroseries_experimental = self.factory.makeDistroRelease(
distribution = self.distribution, name="experimental",
status=SeriesStatus.EXPERIMENTAL)
self.person1 = self.factory.makePerson(
name='hacker', displayname=u'Happy Hacker')
self.packageset_set = getUtility(IPackagesetSet)
def test_new_defaults_to_current_distroseries(self):
# If the distroseries is not provided, the current development
# distroseries will be assumed.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
self.failUnlessEqual(
self.distroseries_current, packageset.distroseries)
def test_new_with_specified_distroseries(self):
# A distroseries can be provided when creating a package set.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1,
distroseries=self.distroseries_experimental)
self.failUnlessEqual(
self.distroseries_experimental, packageset.distroseries)
def test_new_creates_new_packageset_group(self):
# Creating a new packageset should also create a new packageset
# group with the same owner.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1,
distroseries=self.distroseries_experimental)
self.failUnlessEqual(
self.person1, packageset.packagesetgroup.owner)
def test_new_duplicate_name_for_same_distroseries(self):
# Creating a packageset with a duplicate name for the
# given distroseries will fail.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1,
distroseries=self.distroseries_experimental)
self.failUnlessRaises(
DuplicatePackagesetName, self.packageset_set.new,
u'kernel', u'A packageset with a duplicate name', self.person1,
distroseries=self.distroseries_experimental)
def test_new_duplicate_name_for_different_distroseries(self):
# Creating a packageset with a duplicate name but for a different
# series is no problem.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
packageset2 = self.packageset_set.new(
u'kernel', u'A packageset with a duplicate name', self.person1,
distroseries=self.distroseries_experimental)
self.assertEqual(packageset.name, packageset2.name)
def test_new_related_packageset(self):
# Creating a new package set while specifying a `related_set` should
# have the effect that the former ends up in the same group as the
# latter.
pset1 = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
pset2 = self.packageset_set.new(
u'kernel', u'A related package set.', self.person1,
distroseries=self.distroseries_experimental, related_set=pset1)
self.assertEqual(pset1.packagesetgroup, pset2.packagesetgroup)
def test_get_by_name_in_current_distroseries(self):
# IPackagesetSet.getByName() will return the package set in the
# current distroseries if the optional `distroseries` parameter is
# omitted.
pset1 = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
pset2 = self.packageset_set.new(
u'kernel', u'A related package set.', self.person1,
distroseries=self.distroseries_experimental, related_set=pset1)
pset_found = getUtility(IPackagesetSet).getByName('kernel')
self.assertEqual(pset1, pset_found)
def test_get_by_name_in_specified_distroseries(self):
# IPackagesetSet.getByName() will return the package set in the
# specified distroseries.
pset1 = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
pset2 = self.packageset_set.new(
u'kernel', u'A related package set.', self.person1,
distroseries=self.distroseries_experimental, related_set=pset1)
pset_found = getUtility(IPackagesetSet).getByName(
'kernel', distroseries=self.distroseries_experimental)
self.assertEqual(pset2, pset_found)
def test_get_by_distroseries(self):
# IPackagesetSet.getBySeries() will return those package sets
# associated with the given distroseries.
pset1 = self.packageset_set.new(
u'timmy', u'Timmy Mallett', self.person1)
pset2 = self.packageset_set.new(
u'savile', u'Jimmy Savile', self.person1)
self.packageset_set.new(
u'hoskins', u'Bob Hoskins', self.person1,
distroseries=self.distroseries_experimental)
self.assertContentEqual(
[pset1, pset2],
self.packageset_set.getBySeries(self.distroseries_current))
class TestPackageset(TestCaseWithFactory):
layer = LaunchpadZopelessLayer
def setUp(self):
"""Setup a distribution with multiple distroseries."""
super(TestPackageset, self).setUp()
self.distribution = getUtility(IDistributionSet).getByName(
'ubuntu')
self.distroseries_current = self.distribution.currentseries
self.distroseries_experimental = self.factory.makeDistroRelease(
distribution = self.distribution, name="experimental",
status=SeriesStatus.EXPERIMENTAL)
self.distroseries_experimental2 = self.factory.makeDistroRelease(
distribution = self.distribution, name="experimental2",
status=SeriesStatus.EXPERIMENTAL)
self.person1 = self.factory.makePerson(
name='hacker', displayname=u'Happy Hacker')
self.packageset_set = getUtility(IPackagesetSet)
def test_no_related_sets(self):
# If the package set is the only one in the group the result set
# returned by relatedSets() is empty.
packageset = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
self.failUnlessEqual(packageset.relatedSets().count(), 0)
def test_related_set_found(self):
# Creating a new package set while specifying a `related_set` should
# have the effect that the former ends up in the same group as the
# latter.
# The original package set.
pset1 = self.packageset_set.new(
u'kernel', u'Contains all OS kernel packages', self.person1)
# A related package set.
pset2 = self.packageset_set.new(
u'kernel', u'A related package set.', self.person1,
distroseries=self.distroseries_experimental, related_set=pset1)
self.assertEqual(pset1.packagesetgroup, pset2.packagesetgroup)
# An unrelated package set with the same name.
pset3 = self.packageset_set.new(
u'kernel', u'Unrelated package set.', self.person1,
distroseries=self.distroseries_experimental2)
self.assertNotEqual(pset2.packagesetgroup, pset3.packagesetgroup)
# Make sure 'pset2' is related to 'pset1'.
related = pset1.relatedSets()
self.assertEqual(related.count(), 1)
self.assertEqual(related[0], pset2)
# And the other way around ..
related = pset2.relatedSets()
self.assertEqual(related.count(), 1)
self.assertEqual(related[0], pset1)
# Unsurprisingly, the unrelated package set is not associated with any
# other package set.
self.failUnlessEqual(pset3.relatedSets().count(), 0)
|