def test_import_default_settings(self): """Import a Zip file. """ folder = self.root.folder importer = IArchiveFileImporter(folder) with self.layer.open_fixture('test1.zip') as archive: succeeded, failed = importer.importArchive(archive) self.assertItemsEqual(succeeded, [ 'testzip/foo/bar/baz/image5.jpg', 'testzip/foo/bar/image4.jpg', 'testzip/foo/image3.jpg', 'testzip/bar/image2.jpg', 'testzip/image1.jpg', 'testzip/sound1.mp3', 'testzip/Clock.swf' ]) self.assertItemsEqual([], failed) self.assert_(folder['testzip']) self.assert_(folder['testzip']['bar']) self.assert_(folder['testzip']['foo']) self.assert_(folder['testzip']['foo']['bar']) self.assert_(folder['testzip']['foo']['bar']['baz']) self.assertTrue( interfaces.IImage.providedBy(folder['testzip']['image1.jpg'])) self.assertTrue( interfaces.IFile.providedBy(folder['testzip']['sound1.mp3'])) self.assertTrue( interfaces.IFile.providedBy(folder['testzip']['Clock.swf'])) self.assertTrue( interfaces.IImage.providedBy( folder['testzip']['bar']['image2.jpg'])) self.assertTrue( interfaces.IImage.providedBy( folder['testzip']['foo']['bar']['baz']['image5.jpg']))
def test_import_asset_set_title(self): """Set a default title to the imported assets. """ folder = self.root.folder importer = IArchiveFileImporter(folder) with self.layer.open_fixture('test1.zip') as archive: succeeded, failed = importer.importArchive( archive, assettitle=u'Daarhelemali') self.assertItemsEqual(failed, []) self.assertEqual(u'Daarhelemali', folder['testzip']['bar']['image2.jpg'].get_title()) self.assertEqual( u'Daarhelemali', folder['testzip']['foo']['bar']['baz']['image5.jpg'].get_title())
def test_zip_import(self): """Test the import of Zip file with quota system activated. """ factory = self.root.manage_addProduct['Silva'] factory.manage_addFolder('folder', 'Folder') self.assertEqual(self.root.used_space, 0) self.assertEqual(self.root.folder.used_space, 0) with self.layer.open_fixture('test1.zip') as source: IArchiveFileImporter(self.root.folder).importArchive(source) self.assertEqual(self.root.folder.used_space, 10950) self.assertEqual(self.root.used_space, 10950) with IContainerManager(self.root).deleter() as deleter: deleter(self.root.folder) self.assertEqual(self.root.used_space, 0)
def test_import_macos_files(self): """Import an archive file that have Macos X metadata directories. They should be ignored. """ folder = self.root.folder importer = IArchiveFileImporter(folder) with self.layer.open_fixture('test3.zip') as archive: succeeded, failed = importer.importArchive(archive) self.assertItemsEqual(succeeded, ['imgs/c16.png', 'imgs/c17.png']) self.assertItemsEqual([], failed) self.assertItemsEqual(folder.objectIds(), ['imgs']) self.assertItemsEqual(folder.imgs.objectIds(), ['c16.png', 'c17.png']) self.assertTrue(interfaces.IImage.providedBy( folder['imgs']['c16.png'])) self.assertTrue(interfaces.IImage.providedBy( folder['imgs']['c17.png']))
def test_import_no_sub_dirs(self): """Import a Zip that doesn't have any subdirectories. """ folder = self.root.folder importer = IArchiveFileImporter(folder) with self.layer.open_fixture('test2.zip') as archive: succeeded, failed = importer.importArchive(archive) self.assertItemsEqual(succeeded, ['Clock.swf', 'image1.jpg', 'sound1.mp3']) self.assertItemsEqual(failed, []) self.assertItemsEqual(succeeded, ['Clock.swf', 'image1.jpg', 'sound1.mp3']) self.assertItemsEqual([], failed) self.assertItemsEqual(folder.objectIds(), ['Clock.swf', 'image1.jpg', 'sound1.mp3']) self.assertTrue(interfaces.IImage.providedBy(folder['image1.jpg'])) self.assertTrue(interfaces.IFile.providedBy(folder['sound1.mp3'])) self.assertTrue(interfaces.IFile.providedBy(folder['Clock.swf']))
def test_implementation(self): """Test adapter lookup. """ importer = IArchiveFileImporter(self.root.folder, None) self.assertTrue(verifyObject(IArchiveFileImporter, importer)) self.assertTrue(IArchiveFileImporter(self.root.link, None) is None)