def test_empty(self): from Products.CMFCore.exportimport.workflow import exportWorkflowTool site, _wtool = self._initSite() context = DummyExportContext(site) exportWorkflowTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'workflows.xml') self._compareDOM(text, _EMPTY_TOOL_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_normal(self): from Products.CMFCore.exportimport.catalog import exportCatalogTool site = self._initSite(2) context = DummyExportContext(site) exportCatalogTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'catalog.xml') self._compareDOM(text, _NORMAL_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.CMFCore.exportimport.mailhost import exportMailHost site, _mh = self._initSite(use_changed=False) context = DummyExportContext(site) exportMailHost(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'mailhost.xml') self._compareDOM(text.decode('utf8'), _DEFAULT_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_empty(self): from Products.CMFCore.exportimport.skins import exportSkinsTool site = self._initSite() context = DummyExportContext(site) exportSkinsTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'skins.xml') self._compareDOM(text, _EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_empty(self): from ..typeinfo import exportTypesTool site = self._initSite() context = DummyExportContext(site) exportTypesTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'types.xml') self._compareDOM(text.decode('utf8'), _EMPTY_TOOL_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_export_ini_file(self): ini_file = _makeINIAware('ini_file.html') adapter = self._makeOne(ini_file) context = DummyExportContext(None) adapter.export(context, 'subpath/to') self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'subpath/to/ini_file.html.ini') self.assertEqual(content_type, 'text/plain') self.assertEqual(text.strip(), ini_file.as_ini().strip())
def test_unchanged(self): from ..actions import exportActionProviders site, _atool = self._initSite(0, 0) context = DummyExportContext(site) exportActionProviders(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'actions.xml') self._compareDOM(text.decode('utf8'), _EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_changed(self): from ..memberdata import exportMemberDataTool site, _mdtool = self._initSite(use_changed=True) context = DummyExportContext(site) exportMemberDataTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'memberdata.xml') self._compareDOM(text.decode('utf8'), _CHANGED_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_changed(self): from Products.CMFCore.exportimport.mailhost import exportMailHost site = self._initSite(use_changed=True) context = DummyExportContext(site) exportMailHost(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'mailhost.xml') self._compareDOM(text, _CHANGED_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_export_dav_file(self): from Products.GenericSetup.tests.common import DummyExportContext dav_file = _makeDAVAware('dav_file.html') adapter = self._makeOne(dav_file) context = DummyExportContext(None) adapter.export(context, 'subpath/to') self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'subpath/to/dav_file.html') self.assertEqual(content_type, 'text/plain') self.assertEqual(text.strip(), dav_file.manage_FTPget().strip())
def test_export_site_with_subfolders(self): self._setUpAdapters() FOLDER_IDS = ('foo', 'bar', 'baz') site = _makeFolder('site', site_folder=True) site.title = 'AAA' site.description = 'DESCRIPTION' for id in FOLDER_IDS: folder = _makeFolder(id) folder.title = 'Title: %s' % id folder.description = 'xyzzy' site._setObject(id, folder) context = DummyExportContext(site) exporter = self._getExporter() exporter(context) self.assertEqual(len(context._wrote), 2 + (2 * len(FOLDER_IDS))) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'structure/.objects') self.assertEqual(content_type, 'text/comma-separated-values') objects = [x for x in reader(StringIO(text))] self.assertEqual(len(objects), 3) for index in range(len(FOLDER_IDS)): id = FOLDER_IDS[index] self.assertEqual(objects[index][0], id) self.assertEqual(objects[index][1], TEST_FOLDER) filename, text, content_type = context._wrote[2 + (2 * index)] self.assertEqual(filename, '/'.join(('structure', id, '.objects'))) self.assertEqual(content_type, 'text/comma-separated-values') subobjects = [x for x in reader(StringIO(text))] self.assertEqual(len(subobjects), 0) filename, text, content_type = context._wrote[2 + (2 * index) + 1] self.assertEqual(filename, '/'.join(('structure', id, '.properties'))) self.assertEqual(content_type, 'text/plain') parser = self._get_config_parser(text) self.assertEqual(parser.get('DEFAULT', 'Title'), 'Title: %s' % id) filename, text, content_type = context._wrote[1] self.assertEqual(filename, 'structure/.properties') self.assertEqual(content_type, 'text/plain') parser = self._get_config_parser(text) self.assertEqual(parser.get('DEFAULT', 'title'), 'AAA') self.assertEqual(parser.get('DEFAULT', 'description'), 'DESCRIPTION')
def test_empty(self): from Products.CMFCore.exportimport.cachingpolicymgr \ import exportCachingPolicyManager site, _cpm = self._initSite(with_policy=False) context = DummyExportContext(site) exportCachingPolicyManager(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'cachingpolicymgr.xml') self._compareDOM(text.decode('utf8'), self._EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.CMFCore.exportimport.memberdata \ import exportMemberDataTool site, _mdtool = self._initSite(use_changed=False) context = DummyExportContext(site) exportMemberDataTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'memberdata.xml') self._compareDOM(text, _DEFAULT_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_with_info(self): from Products.CMFFormController.exportimport \ import exportCMFFormController site = self._initSite(with_info=True) context = DummyExportContext(site) exportCMFFormController(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'cmfformcontroller.xml') self._compareDOM(text, self._WITH_INFO_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.CMFCore.exportimport.cookieauth \ import exportCookieCrumbler site, _cc = self._initSite(use_changed=False) context = DummyExportContext(site) exportCookieCrumbler(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'cookieauth.xml') self._compareDOM(text.decode('utf8'), _DEFAULT_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_empty(self): from Products.PluginRegistry.exportimport \ import exportPluginRegistry app, registry = self._initRegistry() context = DummyExportContext(app) exportPluginRegistry(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'pluginregistry.xml') self._compareDOM(text, _EMPTY_PLUGINREGISTRY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_changed(self): from Products.LDAPMultiPlugins.exportimport import \ exportLDAPMultiPlugins site = self._initSite(use_changed=True) context = DummyExportContext(site) exportLDAPMultiPlugins(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'tested.xml') self._compareDOM(text, _CHANGED_LMP_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_with_policy(self): from Products.CMFCore.exportimport.contenttyperegistry \ import exportContentTypeRegistry site = self._initSite(mit_predikat=True) context = DummyExportContext(site) exportContentTypeRegistry(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'contenttyperegistry.xml') self._compareDOM(text, self._WITH_POLICY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.LDAPMultiPlugins.exportimport import \ exportLDAPMultiPlugins site = self._initSite(use_changed=False) context = DummyExportContext(site) exportLDAPMultiPlugins(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'tested.xml') self._compareDOM(text, _LDAPMULTIPLUGIN_BODY) self.assertEqual(content_type, 'text/xml')
def test_empty(self): from Products.CMFCore.exportimport.properties \ import exportSiteProperties site = self._initSite(0, 0) context = DummyExportContext(site) exportSiteProperties(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'properties.xml') self._compareDOM(text.decode('utf8'), _EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.CMFCore.exportimport.actions \ import exportActionProviders site = self._initSite(0, 0) context = DummyExportContext(site) exportActionProviders(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'actions.xml') self._compareDOM(text, _EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_empty(self): from Products.CMFCore.exportimport.contenttyperegistry \ import exportContentTypeRegistry site, _ctr = self._initSite(mit_predikat=False) context = DummyExportContext(site) exportContentTypeRegistry(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'contenttyperegistry.xml') self._compareDOM(text.decode('utf8'), self._EMPTY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_with_policy(self): from Products.CMFCore.exportimport.cachingpolicymgr \ import exportCachingPolicyManager site = self._initSite(with_policy=True) context = DummyExportContext(site) exportCachingPolicyManager(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'cachingpolicymgr.xml') self._compareDOM(text, self._WITH_POLICY_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_unchanged(self): from Products.LDAPUserFolder.exportimport import \ exportLDAPUserFolder site = self._initSite(use_changed=False) context = DummyExportContext(site) exportLDAPUserFolder(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'ldapuserfolder.xml') self._compareDOM(text, _LDAPUSERFOLDER_BODY) self.assertEqual(content_type, 'text/xml')
def test_normal(self): from Products.CMFCore.exportimport.properties \ import exportSiteProperties site = self._initSite() context = DummyExportContext(site) exportSiteProperties(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'properties.xml') self._compareDOM(text, _NORMAL_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_changed(self): from Products.GenericSetup.tests.common import DummyExportContext from ..exportimport import exportLDAPUserFolder site = self._initSite(use_changed=True) context = DummyExportContext(site) exportLDAPUserFolder(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'ldapuserfolder.xml') self._compareDOM(text, _CHANGED_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_with_icon(self): from Products.CMFActionIcons.exportimport \ import exportActionIconsTool site = self._initSite(with_icon=True) context = DummyExportContext(site) exportActionIconsTool(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'actionicons.xml') self._compareDOM(text, self._WITH_ICON_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_changed(self): from Products.CMFCore.exportimport.cookieauth \ import exportCookieCrumbler site = self._initSite(use_changed=True) context = DummyExportContext(site) exportCookieCrumbler(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'cookieauth.xml') self._compareDOM(text, _CHANGED_EXPORT) self.assertEqual(content_type, 'text/xml')
def test_export_with_known_CSV(self): from faux_objects import KNOWN_CSV sheet = _makeCSVAware('config') adapter = self._makeOne(sheet) context = DummyExportContext(None) adapter.export(context, 'subpath/to/sheet') self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'subpath/to/sheet/config.csv') self.assertEqual(content_type, 'text/comma-separated-values') self.assertEqual(text.strip(), KNOWN_CSV.strip())
def test_normal_no_plugins(self): from Products.PluginRegistry.exportimport \ import exportPluginRegistry app, registry = self._initRegistry( plugin_type_info=_PLUGIN_TYPE_INFO) context = DummyExportContext(app) exportPluginRegistry(context) self.assertEqual(len(context._wrote), 1) filename, text, content_type = context._wrote[0] self.assertEqual(filename, 'pluginregistry.xml') self._compareDOM(text, _NO_PLUGINS_PLUGINREGISTRY_EXPORT) self.assertEqual(content_type, 'text/xml')