コード例 #1
0
 def test_ubuntu_override_policy_sources(self):
     # The Ubuntu policy incorporates both the existing and the unknown
     # policy.
     universe = getUtility(IComponentSet)['universe']
     spns = [self.factory.makeSourcePackageName()]
     expected = [SourceOverride(spns[0], universe, None)]
     distroseries = self.factory.makeDistroSeries()
     pocket = self.factory.getAnyPocket()
     for i in xrange(8):
         spph = self.factory.makeSourcePackagePublishingHistory(
             distroseries=distroseries, archive=distroseries.main_archive,
             pocket=pocket)
         spns.append(spph.sourcepackagerelease.sourcepackagename)
         expected.append(
             SourceOverride(
                 spph.sourcepackagerelease.sourcepackagename,
                 spph.component, spph.section))
     spns.append(self.factory.makeSourcePackageName())
     expected.append(SourceOverride(spns[-1], universe, None))
     policy = UbuntuOverridePolicy()
     overrides = policy.calculateSourceOverrides(
         distroseries.main_archive, distroseries, pocket, spns)
     self.assertEqual(10, len(overrides))
     sorted_expected = sorted(
         expected, key=attrgetter("source_package_name.name"))
     sorted_overrides = sorted(
         overrides, key=attrgetter("source_package_name.name"))
     self.assertEqual(sorted_expected, sorted_overrides)
コード例 #2
0
 def test_ubuntu_override_policy_binaries(self):
     # The Ubuntu policy incorporates both the existing and the unknown
     # policy.
     universe = getUtility(IComponentSet)['universe']
     distroseries = self.factory.makeDistroSeries()
     pocket = self.factory.getAnyPocket()
     bpn = self.factory.makeBinaryPackageName()
     bpns = []
     expected = []
     for i in xrange(3):
         distroarchseries = self.factory.makeDistroArchSeries(
             distroseries=distroseries)
         bpb = self.factory.makeBinaryPackageBuild(
             distroarchseries=distroarchseries)
         bpr = self.factory.makeBinaryPackageRelease(
             build=bpb, binarypackagename=bpn,
             architecturespecific=True)
         bpph = self.factory.makeBinaryPackagePublishingHistory(
             binarypackagerelease=bpr, distroarchseries=distroarchseries,
             archive=distroseries.main_archive, pocket=pocket)
         bpns.append((bpn, distroarchseries.architecturetag))
         expected.append(
             BinaryOverride(
                 bpn, distroarchseries, bpph.component, bpph.section,
                 bpph.priority, None))
     for i in xrange(2):
         distroarchseries = self.factory.makeDistroArchSeries(
             distroseries=distroseries)
         bpns.append((bpn, distroarchseries.architecturetag))
         expected.append(
             BinaryOverride(
                 bpn, distroarchseries, universe, None, None, None))
     distroseries.nominatedarchindep = distroarchseries
     policy = UbuntuOverridePolicy()
     overrides = policy.calculateBinaryOverrides(
         distroseries.main_archive, distroseries, pocket, bpns)
     self.assertEqual(5, len(overrides))
     key = attrgetter("binary_package_name.name",
         "distro_arch_series.architecturetag",
         "component.name")
     sorted_expected = sorted(expected, key=key)
     sorted_overrides = sorted(overrides, key=key)
     self.assertEqual(sorted_expected, sorted_overrides)
コード例 #3
0
 def test_phased_update_percentage(self):
     # A policy with a phased_update_percentage applies it to new binary
     # overrides.
     universe = getUtility(IComponentSet)['universe']
     distroseries = self.factory.makeDistroSeries()
     pocket = self.factory.getAnyPocket()
     bpn = self.factory.makeBinaryPackageName()
     bpns = []
     expected = []
     distroarchseries = self.factory.makeDistroArchSeries(
         distroseries=distroseries)
     bpb = self.factory.makeBinaryPackageBuild(
         distroarchseries=distroarchseries)
     bpr = self.factory.makeBinaryPackageRelease(
         build=bpb, binarypackagename=bpn, architecturespecific=True)
     bpph = self.factory.makeBinaryPackagePublishingHistory(
         binarypackagerelease=bpr, distroarchseries=distroarchseries,
         archive=distroseries.main_archive, pocket=pocket)
     bpns.append((bpn, distroarchseries.architecturetag))
     expected.append(
         BinaryOverride(
             bpn, distroarchseries, bpph.component, bpph.section,
             bpph.priority, 50))
     distroarchseries = self.factory.makeDistroArchSeries(
         distroseries=distroseries)
     bpns.append((bpn, distroarchseries.architecturetag))
     expected.append(
         BinaryOverride(bpn, distroarchseries, universe, None, None, 50))
     distroseries.nominatedarchindep = distroarchseries
     policy = UbuntuOverridePolicy(phased_update_percentage=50)
     overrides = policy.calculateBinaryOverrides(
         distroseries.main_archive, distroseries, pocket, bpns)
     self.assertEqual(2, len(overrides))
     key = attrgetter("binary_package_name.name",
         "distro_arch_series.architecturetag",
         "component.name")
     sorted_expected = sorted(expected, key=key)
     sorted_overrides = sorted(overrides, key=key)
     self.assertEqual(sorted_expected, sorted_overrides)