162
162
"""Domination asserts for non-empty input list."""
163
163
package = self.factory.makeBinaryPackageName()
164
164
dominator = Dominator(self.logger, self.ubuntutest.main_archive)
165
dominator.mapPackages = FakeMethod({package.name: []})
165
dominator._sortPackages = FakeMethod({package.name: []})
166
166
# This isn't a really good exception. It should probably be
167
167
# something more indicative of bad input.
168
168
self.assertRaises(
175
175
"""Domination asserts for non-empty input list."""
176
176
package = self.factory.makeSourcePackageName()
177
177
dominator = Dominator(self.logger, self.ubuntutest.main_archive)
178
dominator.mapPackages = FakeMethod({package.name: []})
178
dominator._sortPackages = FakeMethod({package.name: []})
179
179
# This isn't a really good exception. It should probably be
180
180
# something more indicative of bad input.
181
181
self.assertRaises(
414
414
archive = das.distroseries.main_archive
415
415
pocket = factory.getAnyPocket()
417
factory.makeBinaryPackageRelease(binarypackagename=bpn)
417
factory.makeBinaryPackageRelease(
418
binarypackagename=bpn, version=version)
418
419
for version in versions]
420
421
factory.makeBinaryPackagePublishingHistory(
1115
1116
spphs[0].distroseries, spphs[0].pocket))
1119
def make_publications_arch_specific(pubs, arch_specific=True):
1120
"""Set the `architecturespecific` attribute for given SPPHs.
1122
:param pubs: An iterable of `BinaryPackagePublishingHistory`.
1123
:param arch_specific: Whether the binary package releases published
1124
by `pubs` are to be architecture-specific. If not, they will be
1125
treated as being for the "all" architecture.
1128
bpr = removeSecurityProxy(pub).binarypackagerelease
1129
bpr.architecturespecific = arch_specific
1118
1132
class TestLivenessFunctions(TestCaseWithFactory):
1119
1133
"""Tests for the functions that say which versions are live."""
1124
1138
spphs = make_spphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1125
1139
self.assertEqual(['1.0'], find_live_source_versions(spphs))
1127
# XXX: First make those bpphs architecture-specific!
1128
1141
def test_find_live_binary_versions_first_pass_blesses_latest(self):
1129
1142
bpphs = make_bpphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1143
make_publications_arch_specific(bpphs)
1130
1144
self.assertEqual(['1.0'], find_live_binary_versions_first_pass(bpphs))
1132
1146
def test_find_live_binary_versions_first_pass_blesses_arch_all(self):
1133
bpphs = make_bpphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1134
bpphs[-1].binarypackagerelease.architecturespecific = False
1147
versions = ['1.%d' % version for version in range(3)]
1148
bpphs = make_bpphs_for_versions(self.factory, versions)
1150
# All of these publications are architecture-specific, except
1151
# the last one. This would happen if the binary package had
1152
# just changed from being architecture-specific to being
1153
# architecture-independent.
1154
make_publications_arch_specific(bpphs, True)
1155
make_publications_arch_specific(bpphs[-1:], False)
1135
1156
self.assertEqual(
1136
['1.0', '1.2'], find_live_binary_versions_first_pass(bpphs))
1157
versions[:1] + versions[-1:],
1158
find_live_binary_versions_first_pass(bpphs))
1138
1160
def test_find_live_binary_versions_second_pass_blesses_latest(self):
1139
1161
bpphs = make_bpphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1162
make_publications_arch_specific(bpphs, False)
1140
1163
self.assertEqual(
1141
1164
['1.0'], find_live_binary_versions_second_pass(bpphs))
1166
def test_find_live_binary_versions_second_pass_blesses_arch_specific(
1168
versions = ['1.%d' % version for version in range(3)]
1169
bpphs = make_bpphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1170
make_publications_arch_specific(bpphs)
1172
versions, find_live_binary_versions_second_pass(bpphs))
1143
1174
def test_find_live_binary_versions_second_pass_reprieves_arch_all(self):
1175
bpphs = make_bpphs_for_versions(self.factory, ['1.0', '1.1', '1.2'])
1176
make_publications_arch_specific(bpphs)
1144
1177
self.assertTrue(False) # XXX: Test