Esempio n. 1
0
    def test_is_upstream_import_on_sourcepackage_upstream_any_template(self):
        # Actually any upstream potemplate will disallow upstream imports.

        # Use _makeImportEntry to create upstream template and packaging
        # link.
        unused_entry = self._makeImportEntry(
            TranslationSide.UBUNTU, uploader=self.translator.translator)

        sourcepackagename = unused_entry.sourcepackagename
        distroseries = unused_entry.distroseries
        other_potemplate = self.factory.makePOTemplate(
            distroseries=distroseries, sourcepackagename=sourcepackagename)

        entry = self.factory.makeTranslationImportQueueEntry(
            potemplate=other_potemplate,
            by_maintainer=True,
            uploader=self.translator.translator,
            content=self.POFILE)
        entry.potemplate = other_potemplate
        entry.pofile = self.factory.makePOFile(potemplate=other_potemplate)
        transaction.commit()

        importer = POFileImporter(entry, importers[TranslationFileFormat.PO],
                                  None)

        self.assertFalse(importer.is_upstream_import_on_sourcepackage)
 def test_is_upstream_import_on_sourcepackage_upstream_template(self):
     # This entry is for a sourcepackage with an upstream potemplate.
     entry = self._makeImportEntry(
         TranslationSide.UBUNTU, uploader=self.translator.translator)
     importer = POFileImporter(
         entry, importers[TranslationFileFormat.PO], None)
     self.assertFalse(importer.is_upstream_import_on_sourcepackage)
Esempio n. 3
0
 def test_translation_importMessage_does_not_update_file_references(self):
     # Importing a translation message does not update the
     # filereferences on an existing POTMsgSet.  (It used to, which
     # is what caused bug 715854).
     pofile = self.factory.makePOFile()
     potmsgset = self.factory.makePOTMsgSet(potemplate=pofile.potemplate)
     old_file_references = self.factory.getUniqueString()
     new_file_references = self.factory.getUniqueString()
     potmsgset.filereferences = old_file_references
     message = TranslationMessageData()
     message.msgid_singular = potmsgset.singular_text
     message.file_references = new_file_references
     queue_entry = FakeImportQueueEntry(pofile.potemplate, pofile)
     importer = POFileImporter(queue_entry, FakeParser(), DevNullLogger())
     importer.importMessage(message)
     self.assertEqual(old_file_references, potmsgset.filereferences)
Esempio n. 4
0
 def test_share_with_other_side_ubuntu_no_upstream(self):
     # An ubuntu queue entry cannot share with a non-existent upstream.
     entry = self._makeImportEntry(TranslationSide.UBUNTU, no_upstream=True)
     importer = POFileImporter(entry, importers[TranslationFileFormat.PO],
                               None)
     self.assertFalse(importer.share_with_other_side,
                      "Ubuntu import should not share with upstream.")
Esempio n. 5
0
 def test_share_with_other_side_ubuntu(self):
     # An ubuntu queue entry will not be shared with upstream.
     entry = self._makeImportEntry(TranslationSide.UBUNTU)
     importer = POFileImporter(entry, importers[TranslationFileFormat.PO],
                               None)
     self.assertFalse(importer.share_with_other_side,
                      "Ubuntu import should not share with upstream.")
Esempio n. 6
0
 def test_share_with_other_side_upstream(self):
     # An upstream queue entry will be shared with ubuntu.
     entry = self._makeImportEntry(TranslationSide.UPSTREAM)
     importer = POFileImporter(entry, importers[TranslationFileFormat.PO],
                               None)
     self.assertTrue(importer.share_with_other_side,
                     "Upstream import should share with Ubuntu.")
 def test_translation_importMessage_does_not_update_file_references(self):
     # Importing a translation message does not update the
     # filereferences on an existing POTMsgSet.  (It used to, which
     # is what caused bug 715854).
     pofile = self.factory.makePOFile()
     potmsgset = self.factory.makePOTMsgSet(potemplate=pofile.potemplate)
     old_file_references = self.factory.getUniqueString()
     new_file_references = self.factory.getUniqueString()
     potmsgset.filereferences = old_file_references
     message = TranslationMessageData()
     message.msgid_singular = potmsgset.singular_text
     message.file_references = new_file_references
     queue_entry = FakeImportQueueEntry(pofile.potemplate, pofile)
     importer = POFileImporter(queue_entry, FakeParser(), DevNullLogger())
     importer.importMessage(message)
     self.assertEqual(old_file_references, potmsgset.filereferences)
 def test_is_upstream_import_on_sourcepackage_ok(self):
     # This entry qualifies.
     entry = self._makeImportEntry(
         TranslationSide.UBUNTU, by_maintainer=True, no_upstream=True,
         uploader=self.translator.translator)
     importer = POFileImporter(
         entry, importers[TranslationFileFormat.PO], None)
     self.assertTrue(importer.is_upstream_import_on_sourcepackage)
 def test_is_upstream_import_on_sourcepackage_by_maintainer(self):
     # This entry is by_maintainer.
     entry = self._makeImportEntry(
         TranslationSide.UPSTREAM, by_maintainer=True,
         uploader=self.translator.translator)
     importer = POFileImporter(
         entry, importers[TranslationFileFormat.PO], None)
     self.assertFalse(importer.is_upstream_import_on_sourcepackage)
Esempio n. 10
0
 def test_share_with_other_side_ubuntu_uploader_upstream_translator(self):
     # If the uploader in ubuntu has rights on upstream as well, the
     # translations are shared.
     entry = self._makeImportEntry(TranslationSide.UBUNTU,
                                   uploader=self.translator.translator)
     importer = POFileImporter(entry, importers[TranslationFileFormat.PO],
                               None)
     self.assertTrue(importer.share_with_other_side,
                     "Ubuntu import should share with upstream.")
 def test_is_upstream_import_on_sourcepackage_none(self):
     # To do an upstream import on a sourcepackage, three conditions must
     # be met.
     # - It has to be on a sourcepackage.
     # - The by_maintainer flag must be set on the queue entry.
     # - There must be no matching template in the upstream project or
     #   even no upstream project at all.
     # This case meets none of them.
     entry = self._makeImportEntry(
         TranslationSide.UPSTREAM, uploader=self.translator.translator)
     importer = POFileImporter(
         entry, importers[TranslationFileFormat.PO], None)
     self.assertFalse(importer.is_upstream_import_on_sourcepackage)
 def _createPOFileImporter(self,
         pot_importer, po_content, by_maintainer, existing_pofile=None,
         person=None):
     """Create a PO entry from content, relating to a template_entry.
     Create an importer for the entry."""
     potemplate = pot_importer.translation_import_queue_entry.potemplate
     if existing_pofile == None:
         pofile = self.factory.makePOFile(
             TEST_LANGUAGE, potemplate=potemplate)
     else:
         pofile = existing_pofile
     person = person or self.importer_person
     translation_entry = self.translation_import_queue.addOrUpdateEntry(
         pofile.path, po_content, by_maintainer, person,
         productseries=potemplate.productseries, pofile=pofile)
     self.fake_librarian.pretendCommit()
     return POFileImporter(translation_entry, GettextPOImporter(), None)
 def test_old_upstream_upload_not_changes_header(self):
     queue_entry = self._make_queue_entry(True)
     pofile = queue_entry.pofile
     old_raw_header = pofile.header
     POFileImporter(queue_entry, GettextPOImporter(), None)
     self.assertEqual(old_raw_header, pofile.header)
 def test_not_raises_OutdatedTranslationError_on_upstream_uploads(self):
     queue_entry = self._make_queue_entry(True)
     try:
         POFileImporter(queue_entry, GettextPOImporter(), None)
     except OutdatedTranslationError:
         self.fail("OutdatedTranslationError raised.")