def test_xml_import(self): """Test the import of a XML file with quota system activited. """ 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('test_import_file.zip') as source: importer = ZipImporter(self.root.folder, TestRequest()) importer.importStream(source) self.assertEqual(self.root.folder.used_space, 35512) self.assertEqual(self.root.used_space, 35512) with IContainerManager(self.root).deleter() as deleter: deleter(self.root.folder) self.assertEqual(self.root.used_space, 0)
def assertImportZip(self, filename, imported, replace=False, update=False, ignore_top_level=False): """Import a ZIP file. """ clearEvents() request = TestRequest() importer = ZipImporter( self.root, request, { 'replace_content': replace, 'update_content': update, 'ignore_top_level_content': ignore_top_level }) with self.layer.open_fixture(filename) as source: importer.importStream(source) self.assertItemsEqual( map(lambda event: '/'.join(event.object.getPhysicalPath()), getEvents(IContentImported)), imported) return importer
def importFromZip(self, input_archive, request, options={}): """ imports fullmedia zipfile """ importer = ZipImporter(self.context, request, options) importer.importStream(input_archive) return importer