class GettextPOImporterTestCase(unittest.TestCase): """Class test for gettext's .po file imports""" layer = LaunchpadZopelessLayer def setUp(self): # Add a new entry for testing purposes. It's a template one. self.translation_import_queue = getUtility(ITranslationImportQueue) template_path = 'po/testing.pot' by_maintainer = True personset = getUtility(IPersonSet) importer = personset.getByName('carlos') productset = getUtility(IProductSet) firefox = productset.getByName('firefox') productseries = firefox.getSeries('trunk') template_entry = self.translation_import_queue.addOrUpdateEntry( template_path, test_template, by_maintainer, importer, productseries=productseries) # Add another one, a translation file. pofile_path = 'po/es.po' translation_entry = self.translation_import_queue.addOrUpdateEntry( pofile_path, test_translation_file, by_maintainer, importer, productseries=productseries) transaction.commit() self.template_importer = GettextPOImporter() self.template_file = self.template_importer.parse(template_entry) self.translation_importer = GettextPOImporter() self.translation_file = self.translation_importer.parse( translation_entry) def testInterface(self): """Check whether the object follows the interface.""" self.failUnless( verifyObject(ITranslationFormatImporter, self.template_importer), "GettextPOImporter doesn't conform to ITranslationFormatImporter" "interface.") def testFormat(self): # GettextPOImporter reports that it handles the PO file format. format = self.template_importer.getFormat(test_template) self.failUnless( format == TranslationFileFormat.PO, 'GettextPOImporter format expected PO but got %s' % format.name)