def run(self): """See `IRunnableJob`.""" logger = logging.getLogger() logger.info("Sanitizing translations for '%s'" % ( self.potemplate.displayname)) TranslationTemplateSplitter(self.potemplate).split() tm = TransactionManager(transaction.manager, False) TranslationMerger.mergeModifiedTemplates(self.potemplate, tm)
def run(self): """See `IRunnableJob`.""" logger = logging.getLogger() logger.info("Sanitizing translations for '%s'" % (self.potemplate.displayname)) TranslationTemplateSplitter(self.potemplate).split() tm = TransactionManager(transaction.manager, False) TranslationMerger.mergeModifiedTemplates(self.potemplate, tm)
def run(self): """See `IRunnableJob`.""" logger = logging.getLogger() if not self.distroseries.distribution.full_functionality: logger.info('Skipping merge for unsupported distroseries "%s".' % self.distroseries.displayname) return logger.info('Merging %s and %s', self.productseries.displayname, self.sourcepackage.displayname) tm = TransactionManager(transaction.manager, False) TranslationMerger.mergePackagingTemplates(self.productseries, self.sourcepackagename, self.distroseries, tm)
def run(self): """See `IRunnableJob`.""" logger = logging.getLogger() if not self.distroseries.distribution.full_functionality: logger.info( 'Skipping merge for unsupported distroseries "%s".' % self.distroseries.displayname) return logger.info( 'Merging %s and %s', self.productseries.displayname, self.sourcepackage.displayname) tm = TransactionManager(transaction.manager, False) TranslationMerger.mergePackagingTemplates( self.productseries, self.sourcepackagename, self.distroseries, tm)
def setUpProduct(self): self.product = self.factory.makeProduct() self.trunk = self.product.getSeries('trunk') self.stable = self.factory.makeProductSeries(product=self.product, owner=self.product.owner, name='stable') self.trunk_template = self.factory.makePOTemplate( productseries=self.trunk, name='template', owner=self.product.owner) self.stable_template = self.factory.makePOTemplate( productseries=self.stable, name='template', owner=self.product.owner) # Force trunk to be the "most representative" template. self.stable_template.iscurrent = False self.templates = [self.trunk_template, self.stable_template] self.script = MessageSharingMerge('tms-merging-test', test_args=[], logger=FakeLogger()) self.script.logger.setLevel(ERROR) tm = TransactionManager(self.script.txn, self.script.options.dry_run) self.merger = TranslationMerger(self.templates, tm)
def test_non_ubuntu(self): """A Packaging not for Ubuntu is ignored.""" packaging = self.makePackagingLink(non_ubuntu=True) self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual( [], TranslationMerger.findMergeablePackagings())
def test_both_templates(self): """A Packaging with product and package templates is included.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual( [packaging], TranslationMerger.findMergeablePackagings())
def test_non_ubuntu(self): """A Packaging not for Ubuntu is ignored.""" packaging = self.makePackagingLink(non_ubuntu=True) self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual([], TranslationMerger.findMergeablePackagings())
def test_both_templates(self): """A Packaging with product and package templates is included.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual([packaging], TranslationMerger.findMergeablePackagings())
def test_multiple_templates(self): """A Packaging with multiple templates appears only once.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual( [packaging], TranslationMerger.findMergeablePackagings())
def test_multiple_templates(self): """A Packaging with multiple templates appears only once.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(productseries=packaging.productseries) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.factory.makePOTemplate(sourcepackage=packaging.sourcepackage) self.assertContentEqual([packaging], TranslationMerger.findMergeablePackagings())
def test_merge_translations(self): """Running the script performs a translation merge.""" # Import here to avoid autodetection by test runner. for packaging in set(TranslationMerger.findMergeablePackagings()): with person_logged_in(packaging.owner): packaging.destroySelf() job = make_translation_merge_job(self.factory) packaging = self.factory.makePackagingLink(job.productseries, job.sourcepackagename, job.distroseries) self.assertEqual(2, count_translations(job)) transaction.commit() retcode, stdout, stderr = run_script( 'scripts/rosetta/merge-existing-packagings.py', [], expect_returncode=0) merge_message = 'INFO Merging %s/%s and %s/%s.\n' % ( packaging.productseries.product.name, packaging.productseries.name, packaging.sourcepackagename.name, packaging.distroseries.name) self.assertEqual( merge_message + 'INFO Deleted POTMsgSets: 1. TranslationMessages: 1.\n', stderr) self.assertEqual('', stdout) self.assertEqual(1, count_translations(job))
def test_no_package_template(self): """A Packaging with no sourcepackage templates is ignored.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.assertContentEqual( [], TranslationMerger.findMergeablePackagings())
def test_no_templates(self): """A Packaging with no templates is ignored.""" self.makePackagingLink() self.assertContentEqual( [], TranslationMerger.findMergeablePackagings())
def setUp(self): """Remove sample data to simplify tests.""" super(TestFindMergablePackagings, self).setUp() for packaging in set(TranslationMerger.findMergeablePackagings()): with person_logged_in(packaging.owner): packaging.destroySelf()
def test_no_package_template(self): """A Packaging with no sourcepackage templates is ignored.""" packaging = self.makePackagingLink() self.factory.makePOTemplate(productseries=packaging.productseries) self.assertContentEqual([], TranslationMerger.findMergeablePackagings())
def test_no_templates(self): """A Packaging with no templates is ignored.""" self.makePackagingLink() self.assertContentEqual([], TranslationMerger.findMergeablePackagings())