def test_fromNames(self): # DistroBrancher.fromNames constructs a DistroBrancher from the names # of a distribution and two distroseries within it. distribution = self.factory.makeDistribution() distroseries1 = self.factory.makeDistroSeries(distribution=distribution) distroseries2 = self.factory.makeDistroSeries(distribution=distribution) brancher = DistroBrancher.fromNames(None, distribution.name, distroseries1.name, distroseries2.name) self.assertEqual([distroseries1, distroseries2], [brancher.old_distroseries, brancher.new_distroseries])
def test_makeNewBranches(self): # makeNewBranches calls makeOneNewBranch for each official branch in # the old distroseries. db_branch = self.makeOfficialPackageBranch() db_branch2 = self.makeOfficialPackageBranch(distroseries=db_branch.distroseries) new_distroseries = self.factory.makeDistroSeries(distribution=db_branch.distribution) brancher = DistroBrancher(BufferLogger(), db_branch.distroseries, new_distroseries) brancher.makeNewBranches() new_sourcepackage = new_distroseries.getSourcePackage(db_branch.sourcepackage.name) new_branch = new_sourcepackage.getBranch(RELEASE) new_sourcepackage2 = new_distroseries.getSourcePackage(db_branch2.sourcepackage.name) new_branch2 = new_sourcepackage2.getBranch(RELEASE) self.assertIsNot(None, new_branch) self.assertIsNot(None, new_branch2)
def test_fromNames(self): # DistroBrancher.fromNames constructs a DistroBrancher from the names # of a distribution and two distroseries within it. distribution = self.factory.makeDistribution() distroseries1 = self.factory.makeDistroSeries( distribution=distribution) distroseries2 = self.factory.makeDistroSeries( distribution=distribution) brancher = DistroBrancher.fromNames(None, distribution.name, distroseries1.name, distroseries2.name) self.assertEqual( [distroseries1, distroseries2], [brancher.old_distroseries, brancher.new_distroseries])
def makeNewSeriesAndBrancher(self, distroseries=None): """Make a DistroBrancher. Any messages logged by this DistroBrancher can be checked by calling `assertLogMessages` below. """ if distroseries is None: distroseries = self.factory.makeDistroSeries() self._log_file = StringIO() new_distroseries = self.factory.makeDistroSeries( distribution=distroseries.distribution) switch_dbuser('branch-distro') return DistroBrancher(FakeLogger(self._log_file), distroseries, new_distroseries)
def main(self): if len(self.args) != 3: self.parser.error("Wrong number of arguments.") brancher = DistroBrancher.fromNames(self.logger, *self.args) server = get_rw_server(direct_database=True) server.start_server() try: if self.options.check: if not brancher.checkNewBranches(): raise LaunchpadScriptFailure("Check failed") else: brancher.makeNewBranches() finally: server.stop_server()
def test_makeNewBranches(self): # makeNewBranches calls makeOneNewBranch for each official branch in # the old distroseries. db_branch = self.makeOfficialPackageBranch() db_branch2 = self.makeOfficialPackageBranch( distroseries=db_branch.distroseries) new_distroseries = self.factory.makeDistroSeries( distribution=db_branch.distribution) brancher = DistroBrancher(BufferLogger(), db_branch.distroseries, new_distroseries) brancher.makeNewBranches() new_sourcepackage = new_distroseries.getSourcePackage( db_branch.sourcepackage.name) new_branch = new_sourcepackage.getBranch(RELEASE) new_sourcepackage2 = new_distroseries.getSourcePackage( db_branch2.sourcepackage.name) new_branch2 = new_sourcepackage2.getBranch(RELEASE) self.assertIsNot(None, new_branch) self.assertIsNot(None, new_branch2)