def test_findShared_renamed(self):
        """Shared POTMsgSets are included for a renamed template."""
        template1, template2, shared_potmsgset = self.setUpSharingTemplates()

        splitter = TranslationTemplateSplitter(template2)
        self.assertContentEqual([], splitter.findShared())

        template2.name = 'renamed'
        self.assertContentEqual(
            [(shared_potmsgset, template1)],
            self.getPOTMsgSetAndTemplateToSplit(splitter))
    def test_findShared_moved_product(self):
        """Moving a template to a different product splits its messages."""
        template1, template2, shared_potmsgset = self.setUpSharingTemplates()

        splitter = TranslationTemplateSplitter(template2)
        self.assertContentEqual([], splitter.findShared())

        # Move the template to a different product entirely.
        template2.productseries = self.factory.makeProduct().development_focus
        template2.distroseries = None
        template2.sourcepackagename = None
        self.assertContentEqual(
            [(shared_potmsgset, template1)],
            self.getPOTMsgSetAndTemplateToSplit(splitter))
    def test_findShared_moved_sourcepackage(self):
        """Moving a template to a different source package gets it split."""
        template1, template2, shared_potmsgset = self.setUpSharingTemplates()

        splitter = TranslationTemplateSplitter(template2)
        self.assertContentEqual([], splitter.findShared())

        # Move the template to a different source package inside the
        # same distroseries.
        sourcepackage = self.factory.makeSourcePackage(
            distroseries=template2.distroseries)
        template2.sourcepackagename = sourcepackage.sourcepackagename
        self.assertContentEqual(
            [(shared_potmsgset, template1)],
            self.getPOTMsgSetAndTemplateToSplit(splitter))
    def test_findShared_moved_distribution(self):
        """Moving a template to a different distribution gets it split."""
        template1, template2, shared_potmsgset = self.setUpSharingTemplates()

        splitter = TranslationTemplateSplitter(template2)
        self.assertContentEqual([], splitter.findShared())

        # Move the template to a different distribution entirely.
        sourcepackage = self.factory.makeSourcePackage()
        template2.distroseries = sourcepackage.distroseries
        template2.sourcepackagename = sourcepackage.sourcepackagename
        template2.productseries = None
        self.assertContentEqual(
            [(shared_potmsgset, template1)],
            self.getPOTMsgSetAndTemplateToSplit(splitter))
Esempio n. 5
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)
    def test_split_messages(self):
        """Splitting messages works properly."""
        template1, template2, shared_potmsgset = self.setUpSharingTemplates()

        splitter = TranslationTemplateSplitter(template2)
        self.assertContentEqual([], splitter.findShared())

        # Move the template to a different product entirely.
        template2.productseries = self.factory.makeProduct().development_focus
        template2.distroseries = None
        template2.sourcepackagename = None

        other_item, this_item = splitter.findShared()[0]

        splitter.split()

        self.assertNotEqual(other_item.potmsgset, this_item.potmsgset)
        self.assertEqual(shared_potmsgset, other_item.potmsgset)
        self.assertNotEqual(shared_potmsgset, this_item.potmsgset)