def test_empty(self):
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.PluggableAuthService.exportimport import exportPAS

            _setUpDefaultTraversable()

            self._setUpAdapters()
            app, pas = self._initPAS()
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 3)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, 'PAS/.objects')
            self.assertEqual(content_type, 'text/comma-separated-values')
            self.assertEqual(text.splitlines(),
                             _EMPTY_PAS_OBJECTS.splitlines())

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, 'PAS/.properties')
            self.assertEqual(content_type, 'text/plain')
            lines = [_f for _f in [x.strip() for x in text.splitlines()] if _f]
            lines = sorted(lines)
            self.assertEqual(len(lines), 3)
            self.assertEqual(lines[0], '[DEFAULT]')
            self.assertEqual(lines[1], 'login_transform =')
            self.assertEqual(lines[2], 'title =')

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, 'PAS/pluginregistry.xml')
            self.assertEqual(content_type, 'text/xml')
Beispiel #2
0
        def test_empty(self):
            from Products.GenericSetup.utils import _getDottedName
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.PluginRegistry.PluginRegistry import PluginRegistry
            from Products.PluggableAuthService.exportimport import exportPAS

            _setUpDefaultTraversable()

            self._setUpAdapters()
            app, pas = self._initPAS()
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 3)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, "PAS/.objects")
            self.assertEqual(content_type, "text/comma-separated-values")
            self.assertEqual(text.splitlines(), _EMPTY_PAS_OBJECTS.splitlines())

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, "PAS/.properties")
            self.assertEqual(content_type, "text/plain")
            lines = filter(None, [x.strip() for x in text.splitlines()])
            self.assertEqual(len(lines), 2)
            self.assertEqual(lines[0], "[DEFAULT]")
            self.assertEqual(lines[1], "title =")

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, "PAS/pluginregistry.xml")
            self.assertEqual(content_type, "text/xml")
Beispiel #3
0
        def test_empty(self):
            from Products.GenericSetup.utils import _getDottedName
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.PluginRegistry.PluginRegistry import PluginRegistry
            from Products.PluggableAuthService.exportimport import exportPAS

            self._setUpAdapters()
            app, pas = self._initPAS()
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 3)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, 'PAS/.objects')
            self.assertEqual(content_type, 'text/comma-separated-values')
            self.assertEqual(text.splitlines(),
                             _EMPTY_PAS_OBJECTS.splitlines())

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, 'PAS/.properties')
            self.assertEqual(content_type, 'text/plain')
            lines = filter(None, [x.strip() for x in text.splitlines()])
            self.assertEqual(len(lines), 2)
            self.assertEqual(lines[0], '[DEFAULT]')
            self.assertEqual(lines[1], 'title =')

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, 'PAS/pluginregistry.xml')
            self.assertEqual(content_type, 'text/xml')
Beispiel #4
0
        def test_empty(self):
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.PluggableAuthService.exportimport import exportPAS

            _setUpDefaultTraversable()

            self._setUpAdapters()
            app, pas = self._initPAS()
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 3)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, 'PAS/.objects')
            self.assertEqual(content_type, 'text/comma-separated-values')
            self.assertEqual(text.splitlines(),
                             _EMPTY_PAS_OBJECTS.splitlines())

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, 'PAS/.properties')
            self.assertEqual(content_type, 'text/plain')
            lines = filter(None, [x.strip() for x in text.splitlines()])
            lines = sorted(lines)
            self.assertEqual(len(lines), 3)
            self.assertEqual(lines[0], '[DEFAULT]')
            self.assertEqual(lines[1], 'login_transform =')
            self.assertEqual(lines[2], 'title =')

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, 'PAS/pluginregistry.xml')
            self.assertEqual(content_type, 'text/xml')
        def test_with_contents(self):
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.GenericSetup.tests.faux_objects \
                import TestCSVAware
            from Products.GenericSetup.utils import _getDottedName
            from Products.PluggableAuthService.exportimport import exportPAS

            _setUpDefaultTraversable()

            self._setUpAdapters()
            app, pas = self._initPAS()
            csv_aware = TestCSVAware()
            csv_aware._setId('csv_plugin')
            pas._setObject('csv_plugin', csv_aware)
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 4)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, 'PAS/.objects')
            self.assertEqual(content_type, 'text/comma-separated-values')

            objects = [x for x in reader(StringIO(text))]
            self.assertEqual(len(objects), 2)

            object_id, type_name = objects[0]
            self.assertEqual(object_id, 'plugins')
            self.assertEqual(type_name, 'plugins')  # adapter-driven

            object_id, type_name = objects[1]
            self.assertEqual(object_id, 'csv_plugin')
            self.assertEqual(type_name, _getDottedName(csv_aware.__class__))

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, 'PAS/.properties')
            self.assertEqual(content_type, 'text/plain')
            lines = [_f for _f in [x.strip() for x in text.splitlines()] if _f]
            lines = sorted(lines)
            self.assertEqual(len(lines), 3)
            self.assertEqual(lines[0], '[DEFAULT]')
            self.assertEqual(lines[1], 'login_transform =')
            self.assertEqual(lines[2], 'title =')

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, 'PAS/pluginregistry.xml')
            self.assertEqual(content_type, 'text/xml')

            filename, text, content_type = context._wrote[3]
            self.assertEqual(filename, 'PAS/csv_plugin.csv')
            self.assertEqual(content_type, 'text/comma-separated-values')
Beispiel #6
0
        def test_with_contents(self):
            from Products.GenericSetup.tests.common import DummyExportContext
            from Products.GenericSetup.tests.faux_objects \
                import TestCSVAware
            from Products.GenericSetup.utils import _getDottedName
            from Products.PluggableAuthService.exportimport import exportPAS

            _setUpDefaultTraversable()

            self._setUpAdapters()
            app, pas = self._initPAS()
            csv_aware = TestCSVAware()
            csv_aware._setId('csv_plugin')
            pas._setObject('csv_plugin', csv_aware)
            context = DummyExportContext(pas)
            exportPAS(context)

            self.assertEqual(len(context._wrote), 4)
            filename, text, content_type = context._wrote[0]
            self.assertEqual(filename, 'PAS/.objects')
            self.assertEqual(content_type, 'text/comma-separated-values')

            objects = [x for x in reader(StringIO(text))]
            self.assertEqual(len(objects), 2)

            object_id, type_name = objects[0]
            self.assertEqual(object_id, 'plugins')
            self.assertEqual(type_name, 'plugins') # adapter-driven

            object_id, type_name = objects[1]
            self.assertEqual(object_id, 'csv_plugin')
            self.assertEqual(type_name, _getDottedName(csv_aware.__class__))

            filename, text, content_type = context._wrote[1]
            self.assertEqual(filename, 'PAS/.properties')
            self.assertEqual(content_type, 'text/plain')
            lines = filter(None, [x.strip() for x in text.splitlines()])
            lines = sorted(lines)
            self.assertEqual(len(lines), 3)
            self.assertEqual(lines[0], '[DEFAULT]')
            self.assertEqual(lines[1], 'login_transform =')
            self.assertEqual(lines[2], 'title =')

            filename, text, content_type = context._wrote[2]
            self.assertEqual(filename, 'PAS/pluginregistry.xml')
            self.assertEqual(content_type, 'text/xml')

            filename, text, content_type = context._wrote[3]
            self.assertEqual(filename, 'PAS/csv_plugin.csv')
            self.assertEqual(content_type, 'text/comma-separated-values')