コード例 #1
0
def _makeCSVAware(id, csv=None):
    from Products.GenericSetup.tests.faux_objects import TestCSVAware

    aware = TestCSVAware()
    aware._setId(id)
    if csv is not None:
        aware._csv = csv

    return aware
コード例 #2
0
ファイル: test_content.py プロジェクト: CGTIC/Plone_SP
def _makeCSVAware(id, csv=None):
    from Products.GenericSetup.tests.faux_objects import TestCSVAware

    aware = TestCSVAware()
    aware._setId(id)
    if csv is not None:
        aware._csv = csv

    return aware
コード例 #3
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 = [_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')
コード例 #4
0
ファイル: test_exportimport.py プロジェクト: CGTIC/Plone_SP
        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')