Ejemplo n.º 1
0
    def test_kotti_static_needed_merged_to_kotti_fanstatic_needed(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.static.needed"] = "kotti.fanstatic.edit_needed"

        with patch("kotti.resources.initialize_sql"):
            app = main({}, **settings)

        groups = app.registry.settings["kotti.fanstatic.view_needed"]
        resource_names = [[r.relpath for r in group.resources] for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert "view.css" in resource_names

        settings = self.required_settings()
        settings["kotti.fanstatic.view_needed"] = "kotti.fanstatic.view_needed"
        settings["kotti.static.view_needed"] = " kotti.fanstatic.edit_needed"
        with warnings.catch_warnings(record=True):
            with patch("kotti.resources.initialize_sql"):
                app = main({}, **settings)
        regsettings = app.registry.settings

        assert len(regsettings["kotti.fanstatic.view_needed"]) == 2

        with raises(KeyError):
            regsettings["kotti.static.view_needed"]

        groups = regsettings["kotti.fanstatic.view_needed"]
        resource_names = [[r.relpath for r in group.resources] for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert "edit.css" in resource_names
Ejemplo n.º 2
0
    def setup(self):
        from kotti import main

        settings = {'sqlalchemy.url': testing_db_url(),
                    'kotti.secret': 'dude'}
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
Ejemplo n.º 3
0
    def test_kotti_static_needed_merged_to_kotti_fanstatic_needed(
            self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.static.needed'] = 'kotti.fanstatic.edit_needed'

        with patch('kotti.resources.initialize_sql'):
            app = main({}, **settings)

        groups = app.registry.settings['kotti.fanstatic.view_needed']
        resource_names = [[r.relpath for r in group.resources]
                          for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert 'view.css' in resource_names

        settings = self.required_settings()
        settings['kotti.fanstatic.view_needed'] = 'kotti.fanstatic.view_needed'
        settings['kotti.static.view_needed'] = ' kotti.fanstatic.edit_needed'
        with warnings.catch_warnings(record=True):
            with patch('kotti.resources.initialize_sql'):
                app = main({}, **settings)
        regsettings = app.registry.settings

        assert len(regsettings['kotti.fanstatic.view_needed']) == 2

        with raises(KeyError):
            regsettings['kotti.static.view_needed']

        groups = regsettings['kotti.fanstatic.view_needed']
        resource_names = [[r.relpath for r in group.resources]
                          for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert 'edit.css' in resource_names
Ejemplo n.º 4
0
    def test_asset_overrides(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.asset_overrides"] = "pyramid:scaffold/ pyramid.fixers"
        with patch("kotti.resources.initialize_sql"):
            main({}, **settings)
Ejemplo n.º 5
0
    def test_asset_overrides(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.asset_overrides'] = 'pyramid:scaffold/'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
Ejemplo n.º 6
0
    def test_kotti_static_needed_merged_to_kotti_fanstatic_needed(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.static.needed'] = 'kotti.fanstatic.edit_needed'

        with patch('kotti.resources.initialize_sql'):
            app = main({}, **settings)

        groups = app.registry.settings['kotti.fanstatic.view_needed']
        resource_names = [[r.relpath for r in group.resources] for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert 'view.css' in resource_names

        settings = self.required_settings()
        settings['kotti.fanstatic.view_needed'] = 'kotti.fanstatic.view_needed'
        settings['kotti.static.view_needed'] = ' kotti.fanstatic.edit_needed'
        with patch('kotti.resources.initialize_sql'):
            app = main({}, **settings)
        regsettings = app.registry.settings

        assert len(regsettings['kotti.fanstatic.view_needed']) == 2

        with raises(KeyError):
            regsettings['kotti.static.view_needed']

        groups = regsettings['kotti.fanstatic.view_needed']
        resource_names = [[r.relpath for r in group.resources] for group in groups]
        resource_names = [name for names in resource_names for name in names]
        assert 'edit.css' in resource_names
Ejemplo n.º 7
0
    def test_use_tables(self):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.populators"] = ""
        settings["kotti.use_tables"] = "principals"
        main({}, **settings)
Ejemplo n.º 8
0
    def test_asset_overrides(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.asset_overrides'] = 'pyramid:scaffold/ pyramid.fixers'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
Ejemplo n.º 9
0
    def test_use_tables(self):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.populators'] = ''
        settings['kotti.use_tables'] = 'principals'
        main({}, **settings)
Ejemplo n.º 10
0
    def test_use_tables(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.populators"] = ""
        settings["kotti.use_tables"] = "principals"
        with patch("kotti.resources.initialize_sql"):
            main({}, **settings)
Ejemplo n.º 11
0
    def test_search_content(self):
        from kotti import main
        from kotti.views.util import search_content

        settings = self.required_settings()
        settings['kotti.search_content'] = 'kotti.tests.test_app._dummy_search'
        main({}, **settings)
        assert search_content(u"Nuno") == u"Not found. Sorry!"
Ejemplo n.º 12
0
    def test_use_tables(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.populators'] = ''
        settings['kotti.use_tables'] = 'principals'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
Ejemplo n.º 13
0
    def test_use_tables(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.populators'] = ''
        settings['kotti.use_tables'] = 'principals'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
Ejemplo n.º 14
0
    def test_asset_overrides(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.asset_overrides"] = "pyramid:scaffold/"
        with patch("kotti.resources.initialize_sql"):
            with patch("kotti.filedepot.TweenFactory"):
                main({}, **settings)
Ejemplo n.º 15
0
    def test_default_filedepot(self, db_session):
        from kotti import main
        from depot.manager import DepotManager

        settings = self.required_settings()

        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert DepotManager.get().__class__.__name__ == 'DBFileStorage'
Ejemplo n.º 16
0
    def test_use_tables(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.populators"] = ""
        settings["kotti.use_tables"] = "principals"
        with patch("kotti.resources.initialize_sql"):
            with patch("kotti.filedepot.TweenFactory"):
                main({}, **settings)
Ejemplo n.º 17
0
    def test_search_content(self, db_session):
        from kotti import main
        from kotti.views.util import search_content

        settings = self.required_settings()
        settings['kotti.search_content'] = 'kotti.testing.dummy_search'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert search_content(u"Nuno") == u"Not found. Sorry!"
Ejemplo n.º 18
0
    def test_setting_values_as_unicode(self):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings['kotti.site_title'] = 'K\xc3\xb6tti'  # Kötti

        main({}, **settings)
        self.assertEqual(get_settings()['kotti.site_title'], u'K\xf6tti')
Ejemplo n.º 19
0
    def test_auth_policies_no_override(self):
        from kotti import main

        settings = self.required_settings()
        main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is not None
        assert registry.queryUtility(IAuthorizationPolicy) is not None
Ejemplo n.º 20
0
    def test_default_filedepot(self, db_session):
        from kotti import main
        from depot.manager import DepotManager

        settings = self.required_settings()

        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert DepotManager.get().__class__.__name__ == 'DBFileStorage'
Ejemplo n.º 21
0
    def test_search_content(self, db_session):
        from kotti import main
        from kotti.views.util import search_content

        settings = self.required_settings()
        settings['kotti.search_content'] = 'kotti.testing.dummy_search'
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert search_content(u"Nuno") == u"Not found. Sorry!"
Ejemplo n.º 22
0
    def test_search_content(self, db_session):
        from kotti import main
        from kotti.views.util import search_content

        settings = self.required_settings()
        settings["kotti.search_content"] = "kotti.testing.dummy_search"
        with patch("kotti.resources.initialize_sql"):
            with patch("kotti.filedepot.TweenFactory"):
                main({}, **settings)
        assert search_content("Nuno") == "Not found. Sorry!"
Ejemplo n.º 23
0
    def test_auth_policies_no_override(self, db_session):
        from kotti import main

        settings = self.required_settings()
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is not None
        assert registry.queryUtility(IAuthorizationPolicy) is not None
Ejemplo n.º 24
0
    def test_stamp_heads(self):
        from kotti import main
        from kotti import DBSession

        settings = self.required_settings()
        main({}, **settings)

        res = DBSession.execute(select(
            columns=['version_num'], from_obj=['kotti_alembic_version']))
        assert tuple(res)  # a version_num should exist
Ejemplo n.º 25
0
    def test_auth_policies_no_override(self, db_session):
        from kotti import main

        settings = self.required_settings()
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is not None
        assert registry.queryUtility(IAuthorizationPolicy) is not None
Ejemplo n.º 26
0
    def test_search_content(self, db_session):
        from kotti import main
        from kotti.views.util import search_content

        settings = self.required_settings()
        settings["kotti.search_content"] = "kotti.testing.dummy_search"
        with patch("kotti.resources.initialize_sql"):
            with patch("kotti.filedepot.TweenFactory"):
                main({}, **settings)
        assert search_content("Nuno") == "Not found. Sorry!"
Ejemplo n.º 27
0
    def test_auth_policies_override(self):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.authn_policy_factory'] = 'kotti.none_factory'
        settings['kotti.authz_policy_factory'] = 'kotti.none_factory'
        main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is None
        assert registry.queryUtility(IAuthorizationPolicy) is None
Ejemplo n.º 28
0
    def test_kotti_includes_deprecation_warning(self):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.includes"] = "kotti.tests.test_app._includeme_layout"
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter("always")
            main({}, **settings)
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            msg = str(w[-1].message)
            assert "The 'kotti.includes' setting has been deprecated" in msg
Ejemplo n.º 29
0
    def test_stamp_heads(self, db_session, connection):
        from kotti import main

        settings = self.required_settings()
        engine = connection.engine
        engine.table_names = Mock(return_value=[])
        with patch("kotti.engine_from_config", return_value=engine):
            with patch("kotti.resources.metadata"):
                main({}, **settings)

        res = db_session.execute(select(columns=["version_num"], from_obj=["kotti_alembic_version"]))
        assert tuple(res)  # a version_num should exist
Ejemplo n.º 30
0
    def test_auth_policies_no_override(self):
        from pyramid.interfaces import IAuthenticationPolicy
        from pyramid.interfaces import IAuthorizationPolicy
        from pyramid.threadlocal import get_current_registry
        from kotti import main

        settings = self.required_settings()
        main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) != None
        assert registry.queryUtility(IAuthorizationPolicy) != None
Ejemplo n.º 31
0
    def test_auth_policies_override(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings["kotti.authn_policy_factory"] = "kotti.none_factory"
        settings["kotti.authz_policy_factory"] = "kotti.none_factory"
        with patch("kotti.resources.initialize_sql"):
            main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is None
        assert registry.queryUtility(IAuthorizationPolicy) is None
Ejemplo n.º 32
0
    def test_auth_policies_no_override(self):
        from pyramid.interfaces import IAuthenticationPolicy
        from pyramid.interfaces import IAuthorizationPolicy
        from pyramid.threadlocal import get_current_registry
        from kotti import main

        settings = self.required_settings()
        main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) != None
        assert registry.queryUtility(IAuthorizationPolicy) != None
Ejemplo n.º 33
0
    def test_kotti_static_needed_deprecation_warning(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.static.view_needed'] = (' kotti.fanstatic.view_needed')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            with patch('kotti.resources.initialize_sql'):
                main({}, **settings)
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            msg = str(w[-1].message)
            assert "The 'kotti.static.view_needed' setting has been deprecated" in msg
Ejemplo n.º 34
0
    def test_kotti_static_needed_deprecation_warning(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.static.view_needed'] = (' kotti.fanstatic.view_needed')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            with patch('kotti.resources.initialize_sql'):
                main({}, **settings)
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            msg = str(w[-1].message)
            assert "The 'kotti.static.view_needed' setting has been deprecated" in msg
Ejemplo n.º 35
0
    def test_kotti_includes_deprecation_warning(self):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.includes'] = (
            'kotti.tests.test_app._includeme_layout')
        with warnings.catch_warnings(record=True) as w:
            warnings.simplefilter('always')
            main({}, **settings)
            assert len(w) == 1
            assert issubclass(w[-1].category, DeprecationWarning)
            msg = str(w[-1].message)
            assert "The 'kotti.includes' setting has been deprecated" in msg
Ejemplo n.º 36
0
    def test_auth_policies_override(self, db_session):
        from kotti import main

        settings = self.required_settings()
        settings['kotti.authn_policy_factory'] = 'kotti.none_factory'
        settings['kotti.authz_policy_factory'] = 'kotti.none_factory'
        with patch('kotti.resources.initialize_sql'):
            with patch('kotti.filedepot.TweenFactory'):
                main({}, **settings)

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) is None
        assert registry.queryUtility(IAuthorizationPolicy) is None
Ejemplo n.º 37
0
    def test_setting_values_as_unicode(self):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings['kotti.site_title'] = 'K\xc3\xb6tti'  # Kötti
        settings['kotti_foo.site_title'] = 'K\xc3\xb6tti'
        settings['foo.site_title'] = 'K\xc3\xb6tti'

        main({}, **settings)
        assert get_settings()['kotti.site_title'] == u'K\xf6tti'
        assert get_settings()['kotti_foo.site_title'] == u'K\xf6tti'
        assert get_settings()['foo.site_title'] == 'K\xc3\xb6tti'
Ejemplo n.º 38
0
    def test_setting_values_as_unicode(self, db_session):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings['kotti.site_title'] = 'K\xc3\xb6tti'  # Kötti
        settings['kotti_foo.site_title'] = 'K\xc3\xb6tti'
        settings['foo.site_title'] = 'K\xc3\xb6tti'

        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert get_settings()['kotti.site_title'] == u'K\xf6tti'
        assert get_settings()['kotti_foo.site_title'] == u'K\xf6tti'
        assert get_settings()['foo.site_title'] == 'K\xc3\xb6tti'
Ejemplo n.º 39
0
    def test_stamp_heads(self, db_session, connection):
        from kotti import main

        settings = self.required_settings()
        engine = connection.engine
        engine.table_names = Mock(return_value=[])
        with patch('kotti.engine_from_config', return_value=engine):
            with patch('kotti.resources.metadata'):
                main({}, **settings)

        res = db_session.execute(
            select(columns=['version_num'],
                   from_obj=['kotti_alembic_version']))
        assert tuple(res)  # a version_num should exist
Ejemplo n.º 40
0
    def test_setting_values_as_unicode(self, db_session):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings['kotti.site_title'] = 'K\xc3\xb6tti'  # Kötti
        settings['kotti_foo.site_title'] = 'K\xc3\xb6tti'
        settings['foo.site_title'] = 'K\xc3\xb6tti'

        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)
        assert get_settings()['kotti.site_title'] == u'K\xf6tti'
        assert get_settings()['kotti_foo.site_title'] == u'K\xf6tti'
        assert get_settings()['foo.site_title'] == 'K\xc3\xb6tti'
Ejemplo n.º 41
0
    def test_override_settings(self):
        class MyType(object):
            pass

        def my_configurator(conf):
            conf['kotti.base_includes'] = ''
            conf['kotti.available_types'] = [MyType]

        settings = self.required_settings()
        settings['kotti.configurators'] = [my_configurator]
        main({}, **settings)

        self.assertEqual(get_settings()['kotti.base_includes'], [])
        self.assertEqual(get_settings()['kotti.available_types'], [MyType])
Ejemplo n.º 42
0
    def test_setting_values_as_unicode(self, db_session):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings["kotti.site_title"] = "K\xc3\xb6tti"  # Kötti
        settings["kotti_foo.site_title"] = "K\xc3\xb6tti"
        settings["foo.site_title"] = "K\xc3\xb6tti"

        with patch("kotti.resources.initialize_sql"):
            main({}, **settings)
        assert get_settings()["kotti.site_title"] == u"K\xf6tti"
        assert get_settings()["kotti_foo.site_title"] == u"K\xf6tti"
        assert get_settings()["foo.site_title"] == "K\xc3\xb6tti"
Ejemplo n.º 43
0
    def test_setting_values_as_unicode(self, db_session, filedepot):
        from kotti import get_settings
        from kotti import main

        settings = self.required_settings()
        settings["kotti.site_title"] = b"K\xc3\xb6tti"  # Kötti
        settings["kotti_foo.site_title"] = b"K\xc3\xb6tti"
        settings["foo.site_title"] = b"K\xc3\xb6tti"

        with patch("kotti.resources.initialize_sql"):
            with patch("kotti.filedepot.TweenFactory"):
                main({}, **settings)
        assert get_settings()["kotti.site_title"] == "Kötti"
        assert get_settings()["kotti_foo.site_title"] == "Kötti"
        assert get_settings()["foo.site_title"] == b"K\xc3\xb6tti"
Ejemplo n.º 44
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    from zope.testbrowser.wsgi import Browser
    from webtest import TestApp

    tearDown()

    _settings = {
        "sqlalchemy.url": testing_db_url(),
        "kotti.secret": "secret",
        "kotti.site_title": "Website des Kottbusser Tors",  # for mailing
        "kotti.populators": "kotti.testing._populator",
        "mail.default_sender": "kotti@localhost",
        "pyramid.includes": "kotti.testing._functional_includeme",
    }
    _settings.update(settings)

    host, port = BASE_URL.split(":")[-2:]
    app = main({}, **_settings)
    Browser.pyquery = property(_zope_testbrowser_pyquery)

    return dict(
        Browser=lambda: Browser(
            "http://{}:{}/".format(host[2:], int(port)), wsgi_app=app
        ),
        browser=Browser("http://{}:{}/".format(host[2:], int(port)), wsgi_app=app),
        test_app=TestApp(app),
    )
Ejemplo n.º 45
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    from zope.testbrowser.wsgi import Browser
    from webtest import TestApp

    tearDown()

    _settings = {
        "sqlalchemy.url": testing_db_url(),
        "kotti.secret": "secret",
        "kotti.site_title": "Website des Kottbusser Tors",  # for mailing
        "kotti.populators": "kotti.testing._populator",
        "mail.default_sender": "kotti@localhost",
        "pyramid.includes": "kotti.testing._functional_includeme",
    }
    _settings.update(settings)

    host, port = BASE_URL.split(":")[-2:]
    app = main({}, **_settings)
    Browser.pyquery = property(_zope_testbrowser_pyquery)

    return dict(
        Browser=lambda: Browser("http://{}:{}/".format(host[2:], int(port)),
                                wsgi_app=app),
        browser=Browser("http://{}:{}/".format(host[2:], int(port)),
                        wsgi_app=app),
        test_app=TestApp(app),
    )
Ejemplo n.º 46
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    import wsgi_intercept.zope_testbrowser
    from webtest import TestApp

    tearDown()

    _settings = {
        'sqlalchemy.url': testing_db_url(),
        'kotti.secret': 'secret',
        'kotti.site_title': 'Website des Kottbusser Tors',  # for mailing
        'kotti.populators': 'kotti.testing._populator',
        'mail.default_sender': 'kotti@localhost',
        'pyramid.includes': 'kotti.testing._functional_includeme',
        }
    _settings.update(settings)

    host, port = BASE_URL.split(':')[-2:]
    app = main({}, **_settings)
    wsgi_intercept.add_wsgi_intercept(host[2:], int(port), lambda: app)
    Browser = wsgi_intercept.zope_testbrowser.WSGI_Browser
    Browser.pyquery = property(_zope_testbrowser_pyquery)

    return dict(
        Browser=Browser,
        browser=Browser(),
        test_app=TestApp(app),
        )
Ejemplo n.º 47
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    from zope.testbrowser.wsgi import Browser
    from webtest import TestApp

    tearDown()

    _settings = {
        'sqlalchemy.url': testing_db_url(),
        'kotti.secret': 'secret',
        'kotti.site_title': 'Website des Kottbusser Tors',  # for mailing
        'kotti.populators': 'kotti.testing._populator',
        'mail.default_sender': 'kotti@localhost',
        'pyramid.includes': 'kotti.testing._functional_includeme',
    }
    _settings.update(settings)

    host, port = BASE_URL.split(':')[-2:]
    app = main({}, **_settings)
    Browser.pyquery = property(_zope_testbrowser_pyquery)

    return dict(
        Browser=lambda: Browser('http://{}:{}/'.format(host[2:], int(port)),
                                wsgi_app=app),
        browser=Browser('http://{}:{}/'.format(host[2:], int(port)),
                        wsgi_app=app),
        test_app=TestApp(app),
    )
Ejemplo n.º 48
0
def setup_app():
    from mock import patch
    from kotti import main
    with patch('kotti.resources.initialize_sql'):
        with patch('kotti.engine_from_config'):
            app = main({}, **settings())
    return app
Ejemplo n.º 49
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    import wsgi_intercept.zope_testbrowser
    from webtest import TestApp

    tearDown()

    _settings = {
        'sqlalchemy.url': testing_db_url(),
        'kotti.secret': 'secret',
        'kotti.site_title': 'Website des Kottbusser Tors',  # for mailing
        'kotti.populators': 'kotti.testing._populator',
        'mail.default_sender': 'kotti@localhost',
        }
    _settings.update(settings)

    host, port = BASE_URL.split(':')[-2:]
    app = main({}, **_settings)
    wsgi_intercept.add_wsgi_intercept(host[2:], int(port), lambda: app)
    Browser = wsgi_intercept.zope_testbrowser.WSGI_Browser

    return dict(
        Browser=Browser,
        browser=Browser(),
        test_app=TestApp(app),
        )
Ejemplo n.º 50
0
def setUpFunctional(global_config=None, **settings):
    from kotti import main
    import wsgi_intercept.zope_testbrowser
    from webtest import TestApp

    tearDown()

    _settings = {
        'sqlalchemy.url': testing_db_url(),
        'kotti.secret': 'secret',
        'kotti.site_title': 'Test Splash Page',  # for mailing
        'kotti.populators':
            'kotti.testing._populator\nkotti_splashpage.populate',
        'mail.default_sender': 'kotti@localhost',
        'kotti.includes': 'kotti_splashpage'
        }
    _settings.update(settings)

    host, port = BASE_URL.split(':')[-2:]
    app = main({}, **_settings)
    wsgi_intercept.add_wsgi_intercept(host[2:], int(port), lambda: app)
    Browser = wsgi_intercept.zope_testbrowser.WSGI_Browser

    return dict(
        Browser=Browser,
        browser=Browser(),
        test_app=TestApp(app),
        )
Ejemplo n.º 51
0
    def test_override_settings(self):
        from kotti import main
        from kotti import get_settings

        class MyType(object):
            pass

        def my_configurator(conf):
            conf['kotti.base_includes'] = ''
            conf['kotti.available_types'] = [MyType]

        settings = self.required_settings()
        settings['kotti.configurators'] = [my_configurator]
        main({}, **settings)

        self.assertEqual(get_settings()['kotti.base_includes'], [])
        self.assertEqual(get_settings()['kotti.available_types'], [MyType])
Ejemplo n.º 52
0
    def test_stamp_heads(self, db_session, connection):
        from kotti import main

        settings = self.required_settings()
        engine = connection.engine
        engine.table_names = Mock(return_value=[])
        with patch("kotti.engine_from_config", return_value=engine):
            with patch("kotti.resources.metadata"):
                with patch("kotti.filedepot.TweenFactory"):
                    main({}, **settings)

        res = db_session.execute(
            select(
                columns=[column("version_num")],
                from_obj=[table("kotti_alembic_version")],
            ))
        assert tuple(res)  # a version_num should exist
Ejemplo n.º 53
0
    def test_override_settings(self, db_session):
        from kotti import main
        from kotti import get_settings

        class MyType(object):
            pass

        def my_configurator(conf):
            conf['kotti.base_includes'] = ''
            conf['kotti.available_types'] = [MyType]

        settings = self.required_settings()
        settings['kotti.configurators'] = [my_configurator]
        with patch('kotti.resources.initialize_sql'):
            main({}, **settings)

        assert get_settings()['kotti.base_includes'] == []
        assert get_settings()['kotti.available_types'] == [MyType]