def run(self): """See `IRosettaUploadJob`.""" with server(get_ro_server(), no_replace=True): # This is not called upon job creation because the branch would # neither have been mirrored nor scanned then. self._init_translation_file_lists() # Get the product series that are connected to this branch and # that want to upload translations. productseriesset = getUtility(IProductSeriesSet) productseries = productseriesset.findByTranslationsImportBranch( self.branch, self.force_translations_upload) translation_import_queue = getUtility(ITranslationImportQueue) for series in productseries: approver = TranslationBranchApprover(self.file_names, productseries=series) for iter_info in self._iter_lists_and_uploaders(series): file_names, changed_files, uploader = iter_info for upload_file_name, upload_file_content in changed_files: if len(upload_file_content) == 0: continue # Skip empty files entry = translation_import_queue.addOrUpdateEntry( upload_file_name, upload_file_content, True, uploader, productseries=series) approver.approve(entry)
def test_does_not_replace_domain_if_path_contains_no_useful_name(self): # For an upload to a package (where there's no fallback to a # product name), if the path contains no meaningful domain name # but matches that of an existing template, even though the # entry gets approved for import into that template, the # existing template's domain name stays as it was. generic_path = u'po/messages.pot' package = self.factory.makeSourcePackage() package_kwargs = { 'distroseries': package.distroseries, 'sourcepackagename': package.sourcepackagename, } template = self.factory.makePOTemplate(**package_kwargs) original_domain = template.translation_domain entry = self.queue.addOrUpdateEntry(generic_path, self.factory.getUniqueString(), True, template.owner, potemplate=template, **package_kwargs) approver = TranslationBranchApprover(generic_path, **package_kwargs) approver.approve(entry) self.assertEqual(original_domain, template.translation_domain)
def test_approve_new_package_template(self): # The approver has sufficient privileges to create a new # template on a source package. package = self.factory.makeSourcePackage() package_kwargs = {"distroseries": package.distroseries, "sourcepackagename": package.sourcepackagename} template = self.factory.makePOTemplate(**package_kwargs) entry = self.factory.makeTranslationImportQueueEntry(path="messages.pot", potemplate=template, **package_kwargs) self.becomeTheApprover() approver = TranslationBranchApprover([template.path], **package_kwargs) approver.approve(entry)
def test_approve_new_product_template(self): # The approver has sufficient privileges to create a new # template on a product. template = self.factory.makePOTemplate() entry = self.factory.makeTranslationImportQueueEntry( "messages.pot", potemplate=template, productseries=template.productseries ) self.becomeTheApprover() approver = TranslationBranchApprover([template.path], productseries=template.productseries) approver.approve(entry)
def test_approve_new_product_template(self): # The approver has sufficient privileges to create a new # template on a product. template = self.factory.makePOTemplate() entry = self.factory.makeTranslationImportQueueEntry( 'messages.pot', potemplate=template, productseries=template.productseries) self.becomeTheApprover() approver = TranslationBranchApprover( [template.path], productseries=template.productseries) approver.approve(entry)
def test_approve_new_package_template(self): # The approver has sufficient privileges to create a new # template on a source package. package = self.factory.makeSourcePackage() package_kwargs = { 'distroseries': package.distroseries, 'sourcepackagename': package.sourcepackagename, } template = self.factory.makePOTemplate(**package_kwargs) entry = self.factory.makeTranslationImportQueueEntry( path='messages.pot', potemplate=template, **package_kwargs) self.becomeTheApprover() approver = TranslationBranchApprover([template.path], **package_kwargs) approver.approve(entry)
def test_does_not_replace_domain_if_path_contains_no_useful_name(self): # For an upload to a package (where there's no fallback to a # product name), if the path contains no meaningful domain name # but matches that of an existing template, even though the # entry gets approved for import into that template, the # existing template's domain name stays as it was. generic_path = u"po/messages.pot" package = self.factory.makeSourcePackage() package_kwargs = {"distroseries": package.distroseries, "sourcepackagename": package.sourcepackagename} template = self.factory.makePOTemplate(**package_kwargs) original_domain = template.translation_domain entry = self.queue.addOrUpdateEntry( generic_path, self.factory.getUniqueString(), True, template.owner, potemplate=template, **package_kwargs ) approver = TranslationBranchApprover(generic_path, **package_kwargs) approver.approve(entry) self.assertEqual(original_domain, template.translation_domain)