def test_XpiTraversal(self): """Test a typical traversal of XPI file, with nested jar file.""" xpi_archive = get_en_US_xpi_file_to_import('en-US') record = TraversalRecorder('', xpi_archive) self.assertEqual(record.traversal, [ [ ('copyover1.foo', 'en-US', 'jar:chrome/en-US.jar!/copyover1.foo', 'main/copyover1.foo', '.foo' ), ('subdir/copyover2.foo', 'en-US', 'jar:chrome/en-US.jar!/subdir/copyover2.foo', 'main/subdir/copyover2.foo', '.foo' ), ('subdir/test2.dtd', 'en-US', 'jar:chrome/en-US.jar!/subdir/test2.dtd', 'main/subdir/test2.dtd', '.dtd' ), ('subdir/test2.properties', 'en-US', 'jar:chrome/en-US.jar!/subdir/test2.properties', 'main/subdir/test2.properties', '.properties' ), ('test1.dtd', 'en-US', 'jar:chrome/en-US.jar!/test1.dtd', 'main/test1.dtd', '.dtd' ), ('test1.properties', 'en-US', 'jar:chrome/en-US.jar!/test1.properties', 'main/test1.properties', '.properties' ), '.' ], '.' ])
def setUpTranslationImportQueueForTemplate(self, subdir): """Return an ITranslationImportQueueEntry for testing purposes. :param subdir: subdirectory in firefox-data to get XPI data from. """ # Get the file to import. en_US_xpi = get_en_US_xpi_file_to_import(subdir) return import_pofile_or_potemplate(file_contents=en_US_xpi.read(), person=self.importer, potemplate=self.firefox_template)
def setUpTranslationImportQueueForTemplate(self, subdir): """Return an ITranslationImportQueueEntry for testing purposes. :param subdir: subdirectory in firefox-data to get XPI data from. """ # Get the file to import. en_US_xpi = get_en_US_xpi_file_to_import(subdir) return import_pofile_or_potemplate( file_contents=en_US_xpi.read(), person=self.importer, potemplate=self.firefox_template)
def test_XpiTraversalWithoutManifest(self): """Test traversal of an XPI file without manifest.""" xpi_archive = get_en_US_xpi_file_to_import('no-manifest') record = TraversalRecorder('', xpi_archive) # Without manifest, there is no knowledge of locale or chrome # paths, so those are None. self.assertEqual( record.traversal, [[('file.txt', None, 'jar:chrome/en-US.jar!/file.txt', None, '.txt'), '.'], ('no-jar.txt', None, 'no-jar.txt', None, '.txt'), '.'])
def setUpTranslationImportQueueForTranslation(self, subdir): """Return an ITranslationImportQueueEntry for testing purposes. :param subdir: subdirectory in firefox-data to get XPI data from. """ # Get the file to import. Given the way XPI file format works, we can # just use the same template file like a translation one. es_xpi = get_en_US_xpi_file_to_import(subdir) return import_pofile_or_potemplate(file_contents=es_xpi.read(), person=self.importer, pofile=self.spanish_firefox, by_maintainer=True)
def setUpTranslationImportQueueForTranslation(self, subdir): """Return an ITranslationImportQueueEntry for testing purposes. :param subdir: subdirectory in firefox-data to get XPI data from. """ # Get the file to import. Given the way XPI file format works, we can # just use the same template file like a translation one. es_xpi = get_en_US_xpi_file_to_import(subdir) return import_pofile_or_potemplate( file_contents=es_xpi.read(), person=self.importer, pofile=self.spanish_firefox, by_maintainer=True)
def test_XpiTraversalWithoutManifest(self): """Test traversal of an XPI file without manifest.""" xpi_archive = get_en_US_xpi_file_to_import('no-manifest') record = TraversalRecorder('', xpi_archive) # Without manifest, there is no knowledge of locale or chrome # paths, so those are None. self.assertEqual(record.traversal, [ [ ('file.txt', None, 'jar:chrome/en-US.jar!/file.txt', None, '.txt' ), '.' ], ('no-jar.txt', None, 'no-jar.txt', None, '.txt' ), '.' ])
def test_XpiTraversal(self): """Test a typical traversal of XPI file, with nested jar file.""" xpi_archive = get_en_US_xpi_file_to_import('en-US') record = TraversalRecorder('', xpi_archive) self.assertEqual( record.traversal, [[('copyover1.foo', 'en-US', 'jar:chrome/en-US.jar!/copyover1.foo', 'main/copyover1.foo', '.foo'), ('subdir/copyover2.foo', 'en-US', 'jar:chrome/en-US.jar!/subdir/copyover2.foo', 'main/subdir/copyover2.foo', '.foo'), ('subdir/test2.dtd', 'en-US', 'jar:chrome/en-US.jar!/subdir/test2.dtd', 'main/subdir/test2.dtd', '.dtd'), ('subdir/test2.properties', 'en-US', 'jar:chrome/en-US.jar!/subdir/test2.properties', 'main/subdir/test2.properties', '.properties'), ('test1.dtd', 'en-US', 'jar:chrome/en-US.jar!/test1.dtd', 'main/test1.dtd', '.dtd'), ('test1.properties', 'en-US', 'jar:chrome/en-US.jar!/test1.properties', 'main/test1.properties', '.properties'), '.'], '.'])
def test_validate_xpi_good(self): validator = self._makeValidator() xpi_content = get_en_US_xpi_file_to_import('en-US').read() result = validator._validateContent('pl.xpi', xpi_content) self.assertTrue(result)