How to use the kotti.main function in Kotti

To help you get started, we’ve selected a few Kotti examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Kotti / Kotti / kotti / testing.py View on Github external
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),
    )
github Kotti / Kotti / kotti / tests.py View on Github external
def setUpFunctional(global_config=None, **settings):
    import wsgi_intercept.zope_testbrowser

    _settings = {
        'sqlalchemy.url': testing_db_url(),
        'kotti.secret': 'secret',
        'kotti.site_title': 'Website des Kottbusser Tors', # for mailing
        'kotti.populators': 'kotti.tests._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)

    return dict(Browser=wsgi_intercept.zope_testbrowser.WSGI_Browser)
github Kotti / Kotti / kotti / tests.py View on Github external
def test_auth_policies_override(self):
        from pyramid.interfaces import IAuthenticationPolicy
        from pyramid.interfaces import IAuthorizationPolicy
        from pyramid.threadlocal import get_current_registry

        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) == None
        assert registry.queryUtility(IAuthorizationPolicy) == None
github Kotti / Kotti / kotti / tests.py View on Github external
def test_use_tables(self):
        settings = self.required_settings()
        settings['kotti.populators'] = ''
        settings['kotti.use_tables'] = 'principals'
        main({}, **settings)
github Kotti / Kotti / kotti / tests.py View on Github external
def test_includes_overrides(self):
        settings = self.required_settings()
        settings['kotti.includes'] = 'kotti.tests.TestMain._includeme'
        main({}, **settings)
github Kotti / Kotti / kotti / tests.py View on Github external
def test_root_factory(self):
        settings = self.required_settings()
        settings['kotti.root_factory'] = 'kotti.tests.TestMain._root_factory'
        app = main({}, **settings)
        assert get_root() == 'my root object'
        assert app.root_factory() == 'my root object'
github Kotti / Kotti / kotti / tests.py View on Github external
def test_auth_policies_no_override(self):
        from pyramid.interfaces import IAuthenticationPolicy
        from pyramid.interfaces import IAuthorizationPolicy
        from pyramid.threadlocal import get_current_registry

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

        registry = get_current_registry()
        assert registry.queryUtility(IAuthenticationPolicy) != None
        assert registry.queryUtility(IAuthorizationPolicy) != None
github Kotti / Kotti / kotti / tests.py View on Github external
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])