def listSuitesNeedingIndexes(self, distroseries):
        """Find suites in `distroseries` that need indexes created.

        Checks for the marker left by `markIndexCreationComplete`.
        """
        if distroseries.status != SeriesStatus.FROZEN:
            # DistroSeries are created in Frozen state.  If the series
            # is in any other state yet has not been marked as having
            # its indexes created, that's because it predates automatic
            # index creation.
            return []
        distro = distroseries.distribution
        publisher_config_set = getUtility(IPublisherConfigSet)
        if publisher_config_set.getByDistribution(distro) is None:
            # We won't be able to do a thing without a publisher config,
            # but that's alright: we have those for all distributions
            # that we want to publish.
            return []

        # May need indexes for this series.
        suites = [
            distroseries.getSuite(pocket)
            for pocket in pocketsuffix.iterkeys()
        ]
        return [
            suite for suite in suites
            if not file_exists(self.locateIndexesMarker(distro, suite))
        ]
Esempio n. 2
0
def get_marker_files(script, distroseries):
    """Return filesystem paths for all indexes markers for `distroseries`."""
    suites = [
        distroseries.getSuite(pocket) for pocket in pocketsuffix.iterkeys()
    ]
    distro = distroseries.distribution
    return [script.locateIndexesMarker(distro, suite) for suite in suites]
    def listSuitesNeedingIndexes(self, distroseries):
        """Find suites in `distroseries` that need indexes created.

        Checks for the marker left by `markIndexCreationComplete`.
        """
        if distroseries.status != SeriesStatus.FROZEN:
            # DistroSeries are created in Frozen state.  If the series
            # is in any other state yet has not been marked as having
            # its indexes created, that's because it predates automatic
            # index creation.
            return []
        distro = distroseries.distribution
        publisher_config_set = getUtility(IPublisherConfigSet)
        if publisher_config_set.getByDistribution(distro) is None:
            # We won't be able to do a thing without a publisher config,
            # but that's alright: we have those for all distributions
            # that we want to publish.
            return []

        # May need indexes for this series.
        suites = [
            distroseries.getSuite(pocket)
            for pocket in pocketsuffix.iterkeys()]
        return [
            suite for suite in suites
                if not file_exists(self.locateIndexesMarker(distro, suite))]
Esempio n. 4
0
 def test_listSuitesNeedingIndexes_initially_includes_entire_series(self):
     # If a series has not had any of its indexes created yet,
     # listSuitesNeedingIndexes returns all of its suites.
     series = self.makeDistroSeriesNeedingIndexes()
     script = self.makeScript(series.distribution)
     script.setUp()
     self.assertContentEqual(
         [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()],
         script.listSuitesNeedingIndexes(series))
 def test_listSuitesNeedingIndexes_initially_includes_entire_series(self):
     # If a series has not had any of its indexes created yet,
     # listSuitesNeedingIndexes returns all of its suites.
     series = self.makeDistroSeriesNeedingIndexes()
     script = self.makeScript(series.distribution)
     script.setUp()
     self.assertContentEqual(
         [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()],
         script.listSuitesNeedingIndexes(series))
Esempio n. 6
0
 def test_script_calls_createIndexes_for_new_series(self):
     # If the script's main() finds a distroseries that needs its
     # indexes created, it calls createIndexes on that distroseries,
     # passing it all of the series' suite names.
     distro = self.makeDistroWithPublishDirectory()
     series = self.makeDistroSeriesNeedingIndexes(distribution=distro)
     script = self.makeScript(distro)
     script.createIndexes = FakeMethod()
     script.main()
     [((given_distro, given_suites), kwargs)] = script.createIndexes.calls
     self.assertEqual(distro, given_distro)
     self.assertContentEqual(
         [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()],
         given_suites)
 def test_script_calls_createIndexes_for_new_series(self):
     # If the script's main() finds a distroseries that needs its
     # indexes created, it calls createIndexes on that distroseries,
     # passing it all of the series' suite names.
     distro = self.makeDistroWithPublishDirectory()
     series = self.makeDistroSeriesNeedingIndexes(distribution=distro)
     script = self.makeScript(distro)
     script.createIndexes = FakeMethod()
     script.main()
     [((given_distro, given_suites), kwargs)] = script.createIndexes.calls
     self.assertEqual(distro, given_distro)
     self.assertContentEqual(
         [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()],
         given_suites)
def get_marker_files(script, distroseries):
    """Return filesystem paths for all indexes markers for `distroseries`."""
    suites = [
        distroseries.getSuite(pocket) for pocket in pocketsuffix.iterkeys()]
    distro = distroseries.distribution
    return [script.locateIndexesMarker(distro, suite) for suite in suites]