def testObsoleteDistroseriesWorks(self):
        """Make sure the required publications are obsoleted."""
        obsoleter = self.getObsoleter()
        self.warty.status = SeriesStatus.OBSOLETE

        # Get all the published sources in warty.
        published_sources, published_binaries = (
            self.getPublicationsForDistroseries())

        # Assert that none of them is obsolete yet:
        self.assertFalse(published_sources.is_empty())
        self.assertFalse(published_binaries.is_empty())
        for source in published_sources:
            self.assertTrue(source.status == PackagePublishingStatus.PUBLISHED)
            self.assertTrue(source.scheduleddeletiondate is None)
        for binary in published_binaries:
            self.assertTrue(binary.status == PackagePublishingStatus.PUBLISHED)
            self.assertTrue(binary.scheduleddeletiondate is None)

        # Keep their DB IDs for later.
        source_ids = [source.id for source in published_sources]
        binary_ids = [binary.id for binary in published_binaries]

        # Make them obsolete.
        obsoleter.mainTask()
        self.layer.txn.commit()

        # Now see if the modified publications have been correctly obsoleted.
        # We need to re-fetch the published_sources and published_binaries
        # because the existing objects are not valid through a transaction.
        for id in source_ids:
            source = SourcePackagePublishingHistory.get(id)
            self.assertTrue(source.status == PackagePublishingStatus.OBSOLETE)
            self.assertTrue(source.scheduleddeletiondate is not None)
        for id in binary_ids:
            binary = BinaryPackagePublishingHistory.get(id)
            self.assertTrue(binary.status == PackagePublishingStatus.OBSOLETE)
            self.assertTrue(binary.scheduleddeletiondate is not None)

        # Make sure nothing else was obsoleted.  Subtract the set of
        # known OBSOLETE IDs from the set of all the IDs and assert that
        # the remainder are not OBSOLETE.
        all_sources = SourcePackagePublishingHistory.select(True)
        all_binaries = BinaryPackagePublishingHistory.select(True)
        all_source_ids = [source.id for source in all_sources]
        all_binary_ids = [binary.id for binary in all_binaries]

        remaining_source_ids = set(all_source_ids) - set(source_ids)
        remaining_binary_ids = set(all_binary_ids) - set(binary_ids)

        for id in remaining_source_ids:
            source = SourcePackagePublishingHistory.get(id)
            self.assertTrue(source.status != PackagePublishingStatus.OBSOLETE)
        for id in remaining_binary_ids:
            binary = BinaryPackagePublishingHistory.get(id)
            self.assertTrue(binary.status != PackagePublishingStatus.OBSOLETE)
 def probePublishingStatus(self, pubrec_ids, status):
     """Check if all source publishing records match the given status."""
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertEqual(
             spph.status, status, "ID %s -> %s (expected %s)" % (
             spph.id, spph.status.title, status.title))
 def probeNotRemoved(self, pubrec_ids):
     """Check if all source publishing records were not removed."""
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertTrue(
             spph.dateremoved is None,
             "ID %s -> removed" % (spph.id))
Exemple #4
0
 def probeRemoved(self, pubrec_ids):
     """Check if all source publishing records were removed."""
     right_now = datetime.datetime.now(pytz.timezone('UTC'))
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertTrue(spph.dateremoved < right_now,
                         "ID %s -> not removed" % (spph.id))
Exemple #5
0
 def probePublishingStatus(self, pubrec_ids, status):
     """Check if all source publishing records match the given status."""
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertEqual(
             spph.status, status, "ID %s -> %s (expected %s)" %
             (spph.id, spph.status.title, status.title))
 def probeRemoved(self, pubrec_ids):
     """Check if all source publishing records were removed."""
     right_now = datetime.datetime.now(pytz.timezone('UTC'))
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertTrue(
             spph.dateremoved < right_now,
             "ID %s -> not removed" % (spph.id))
Exemple #7
0
 def probeNotRemoved(self, pubrec_ids):
     """Check if all source publishing records were not removed."""
     for pubrec_id in pubrec_ids:
         spph = SourcePackagePublishingHistory.get(pubrec_id)
         self.assertTrue(spph.dateremoved is None,
                         "ID %s -> removed" % (spph.id))
    def testObsoleteDistroseriesWorks(self):
        """Make sure the required publications are obsoleted."""
        obsoleter = self.getObsoleter()
        self.warty.status = SeriesStatus.OBSOLETE

        # Get all the published sources in warty.
        published_sources, published_binaries = (
            self.getPublicationsForDistroseries())

        # Assert that none of them is obsolete yet:
        self.assertFalse(published_sources.is_empty())
        self.assertFalse(published_binaries.is_empty())
        for source in published_sources:
            self.assertTrue(
                source.status == PackagePublishingStatus.PUBLISHED)
            self.assertTrue(source.scheduleddeletiondate is None)
        for binary in published_binaries:
            self.assertTrue(
                binary.status == PackagePublishingStatus.PUBLISHED)
            self.assertTrue(binary.scheduleddeletiondate is None)

        # Keep their DB IDs for later.
        source_ids = [source.id for source in published_sources]
        binary_ids = [binary.id for binary in published_binaries]

        # Make them obsolete.
        obsoleter.mainTask()
        self.layer.txn.commit()

        # Now see if the modified publications have been correctly obsoleted.
        # We need to re-fetch the published_sources and published_binaries
        # because the existing objects are not valid through a transaction.
        for id in source_ids:
            source = SourcePackagePublishingHistory.get(id)
            self.assertTrue(
                source.status == PackagePublishingStatus.OBSOLETE)
            self.assertTrue(source.scheduleddeletiondate is not None)
        for id in binary_ids:
            binary = BinaryPackagePublishingHistory.get(id)
            self.assertTrue(
                binary.status == PackagePublishingStatus.OBSOLETE)
            self.assertTrue(binary.scheduleddeletiondate is not None)

        # Make sure nothing else was obsoleted.  Subtract the set of
        # known OBSOLETE IDs from the set of all the IDs and assert that
        # the remainder are not OBSOLETE.
        all_sources = SourcePackagePublishingHistory.select(True)
        all_binaries = BinaryPackagePublishingHistory.select(True)
        all_source_ids = [source.id for source in all_sources]
        all_binary_ids = [binary.id for binary in all_binaries]

        remaining_source_ids = set(all_source_ids) - set(source_ids)
        remaining_binary_ids = set(all_binary_ids) - set(binary_ids)

        for id in remaining_source_ids:
            source = SourcePackagePublishingHistory.get(id)
            self.assertTrue(
                source.status != PackagePublishingStatus.OBSOLETE)
        for id in remaining_binary_ids:
            binary = BinaryPackagePublishingHistory.get(id)
            self.assertTrue(
                binary.status != PackagePublishingStatus.OBSOLETE)