def test_empty_adding_plugins(self): from Products.GenericSetup.tests.common import DummyImportContext from Products.GenericSetup.tests.faux_objects import TestCSVAware, KNOWN_CSV from Products.GenericSetup.utils import _getDottedName from Products.PluginRegistry.PluginRegistry import PluginRegistry from Products.PluggableAuthService.exportimport import importPAS self._setUpAdapters() app, pas = self._initPAS() context = DummyImportContext(pas) context._files["PAS/.objects"] = _PAS_WITH_CSV_PLUGIN_OBJECTS context._files["PAS/.properties"] = _EMPTY_PAS_PROPERTIES context._files["PAS/pluginregistry.xml"] = _EMPTY_PLUGINREGISTRY_EXPORT context._files["PAS/csv_plugin.csv"] = KNOWN_CSV self.assertEqual(len(pas.objectIds()), 1) self.failUnless("plugins" in pas.objectIds()) importPAS(context) self.assertEqual(len(pas.objectIds()), 2) self.failUnless("plugins" in pas.objectIds()) self.failUnless("csv_plugin" in pas.objectIds()) csv_plugin = pas._getOb("csv_plugin") self.failUnless(csv_plugin.__class__ is TestCSVAware) self.assertEqual(csv_plugin._was_put.getvalue().strip(), KNOWN_CSV.strip())
def test_empty_adding_plugins(self): from Products.GenericSetup.tests.common import DummyImportContext from Products.GenericSetup.tests.faux_objects \ import TestCSVAware, KNOWN_CSV from Products.PluggableAuthService.exportimport import importPAS self._setUpAdapters() app, pas = self._initPAS() context = DummyImportContext(pas) context._files['PAS/.objects'] = _PAS_WITH_CSV_PLUGIN_OBJECTS context._files['PAS/.properties'] = _EMPTY_PAS_PROPERTIES context._files[ 'PAS/pluginregistry.xml'] = _EMPTY_PLUGINREGISTRY_EXPORT context._files['PAS/csv_plugin.csv'] = KNOWN_CSV self.assertEqual(len(pas.objectIds()), 1) self.failUnless('plugins' in pas.objectIds()) importPAS(context) self.assertEqual(len(pas.objectIds()), 2) self.failUnless('plugins' in pas.objectIds()) self.failUnless('csv_plugin' in pas.objectIds()) csv_plugin = pas._getOb('csv_plugin') self.failUnless(csv_plugin.__class__ is TestCSVAware) self.assertEqual(csv_plugin._was_put.getvalue().strip(), KNOWN_CSV.strip())
def test_export_with_known_CSV(self): from Products.GenericSetup.tests.common import DummyExportContext from Products.GenericSetup.tests.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())