def test_publish(self): upload = self.uploadTestData() transaction.commit() upload.queue_root.realiseUpload(self.logger) # Test if the job was created correctly jobs = list(PackageTranslationsUploadJob.iterReady()) self.assertEqual(1, len(jobs)) job = jobs[0] # Assert if the job corresponds to the file we uploaded self.assertEqual(job.sourcepackagename, self.spr.sourcepackagename) self.assertEqual(job.libraryfilealias.filename, self.translations_file) # Test if the pmount translations tarball files were added to the # translation import queue with dbuser("upload_package_translations_job"): job.run() self.assertContentEqual(self._getImportableFilesFromTarball(), self._getQueuePaths()) self.factory.makePOTemplate( distroseries=self.breezy_autotest, sourcepackagename=self.spr.sourcepackagename, path="po/pmount.pot", translation_domain=self.package_name) # Approve all translations in the queue with dbuser("translations_import_queue_gardener"): gardener = ImportQueueGardener( 'translations-import-queue-gardener', logger=self.logger, test_args=[]) gardener.main() # Import all approved translations with dbuser("poimport"): importer = TranslationsImport('poimport', logger=self.logger, test_args=[]) importer.main() # Test if all translations in the queue were successfully imported self.assertContentEqual( self._getImportableFilesFromTarball(), self._getQueuePaths(import_status=RosettaImportStatus.IMPORTED))
def test_copyFromPPAToArchiveWithTranslations(self): # Upload the package to a PPA and process it. src_upload, spph, bin_upload = self.uploadToPPA() target_archive = self.breezy_autotest.main_archive # Copy the source package with binaries from PPA to the main archive. # Give QueueAdmin permissions for the user so the upload will be # accepted right away. person = target_archive.owner for component in self.breezy_autotest.components: getUtility(IArchivePermissionSet).newQueueAdmin( target_archive, person, component) self.assertTrue( target_archive.canAdministerQueue(person, self.breezy_autotest.components, spph.pocket, self.breezy_autotest)) target_archive.copyPackage(source_name=self.package_name, version=self.version, from_archive=self.name16.archive, to_pocket='RELEASE', to_series=self.breezy_autotest.name, person=person, include_binaries=True, unembargo=True, auto_approve=True) # Get copy job and run it, should be enough to publish it copy_job_source = getUtility(IPlainPackageCopyJobSource) copy_job = copy_job_source.getActiveJobs(target_archive).one() with dbuser('copy_packages'): copy_job.run() published_source = target_archive.getPublishedSources(name='pmount')[0] self.assertIsNotNone(published_source) self.assertEqual( published_source.sourcepackagerelease.upload_archive.displayname, 'PPA for Foo Bar') self.assertEqual(published_source.archive.displayname, 'Primary Archive for Ubuntu Test') # Move package to main, as only main and restricted packages have # their translations processed. published_source = published_source.changeOverride( new_component="main") self.spr = published_source.sourcepackagerelease self.assertIsNotNone(published_source.getPublishedBinaries()) # Process the upload for it to create the PTUJ upload = IStore(PackageUpload).find(PackageUpload).order_by( Desc(PackageUpload.id)).first() upload.realiseUpload(self.logger) # Assert the job is created correctly ptu_jobs = list(PackageTranslationsUploadJob.iterReady()) self.assertNotEqual(len(ptu_jobs), 0) # Let's attachTranslations ptu_job = ptu_jobs[0] with dbuser('upload_package_translations_job'): ptu_job.run() # Test if the pmount translations tarball files were added to the # translation import queue self.assertContentEqual(self._getImportableFilesFromTarball(), self._getQueuePaths()) self.factory.makePOTemplate( distroseries=self.breezy_autotest, sourcepackagename=self.spr.sourcepackagename, path="po/pmount.pot", translation_domain=self.package_name) # Approve all translations in the queue with dbuser("translations_import_queue_gardener"): gardener = ImportQueueGardener( 'translations-import-queue-gardener', logger=self.logger, test_args=[]) gardener.main() # Import all approved translations with dbuser("poimport"): importer = TranslationsImport('poimport', logger=self.logger, test_args=[]) importer.main() # Test if all translations in the queue were successfully imported self.assertContentEqual( self._getImportableFilesFromTarball(), self._getQueuePaths(import_status=RosettaImportStatus.IMPORTED))
#!/usr/bin/python -S # # Copyright 2009 Canonical Ltd. This software is licensed under the # GNU Affero General Public License version 3 (see the file LICENSE). import _pythonpath from lp.services.config import config from lp.translations.scripts.po_import import TranslationsImport if __name__ == '__main__': script = TranslationsImport('rosetta-poimport', dbuser=config.poimport.dbuser) script.lock_and_run()
def setUp(self): super(TestTranslationsImport, self).setUp() self.queue = TranslationImportQueue() self.script = TranslationsImport('poimport', test_args=[]) self.script.logger.setLevel(logging.FATAL) self.owner = self.factory.makePerson()