Example #1
0
 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)
Example #2
0
 def run(self):
     """See `IRunnableJob`."""
     logger = logging.getLogger()
     if not self.distroseries.distribution.official_packages:
         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)
Example #3
0
 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())
Example #4
0
 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())
Example #5
0
 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())
Example #6
0
    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_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)
     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' % (
         job.productseries.product.name, job.productseries.name,
         job.sourcepackagename.name, job.distroseries.name)
     self.assertEqual(
         merge_message +
         'INFO    Deleted POTMsgSets: 1.  TranslationMessages: 1.\n'
         'INFO    Merging template 1/2.\n'
         'INFO    Merging template 2/2.\n', stderr)
     self.assertEqual('', stdout)
     self.assertEqual(1, count_translations(job))
Example #8
0
 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())
Example #9
0
 def test_no_templates(self):
     """A Packaging with no templates is ignored."""
     self.makePackagingLink()
     self.assertContentEqual(
         [], TranslationMerger.findMergeablePackagings())
Example #10
0
 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()