Пример #1
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)
Пример #2
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),
        )
Пример #3
0
 def setUp(self, **kwargs):
     self.settings = {
         'kotti.configurators': 'kotti_software.kotti_configure',
         'sqlalchemy.url': testing_db_url(),
         'kotti.secret': 'dude',
         'kotti_software.collection_settings.pagesize': '5'
     }
     super(FunctionalTests, self).setUp(**self.settings)
Пример #4
0
def unresolved_settings(custom_settings):
    from kotti import conf_defaults
    from kotti.testing import testing_db_url
    settings = conf_defaults.copy()
    settings['kotti.secret'] = 'secret'
    settings['kotti.secret2'] = 'secret2'
    settings['kotti.populators'] = 'kotti.testing._populator'
    settings['sqlalchemy.url'] = testing_db_url()
    settings.update(custom_settings)
    return settings
Пример #5
0
def unresolved_settings(custom_settings):
    from kotti import conf_defaults
    from kotti.testing import testing_db_url
    settings = conf_defaults.copy()
    settings['kotti.secret'] = 'secret'
    settings['kotti.secret2'] = 'secret2'
    settings['kotti.populators'] = 'kotti.testing._populator'
    settings['sqlalchemy.url'] = testing_db_url()
    settings.update(custom_settings)
    return settings
Пример #6
0
def unresolved_settings(custom_settings):
    from kotti import conf_defaults
    from kotti.testing import testing_db_url

    settings = conf_defaults.copy()
    settings["kotti.secret"] = "secret"
    settings["kotti.secret2"] = "secret2"
    settings["kotti.populators"] = "kotti.testing._populator"
    settings["sqlalchemy.url"] = testing_db_url()
    settings.update(custom_settings)
    return settings
Пример #7
0
def unresolved_settings(custom_settings):
    from kotti import conf_defaults
    from kotti.testing import testing_db_url

    settings = conf_defaults.copy()
    settings["kotti.secret"] = "secret"
    settings["kotti.secret2"] = "secret2"
    settings["kotti.populators"] = "kotti.testing._populator"
    settings["sqlalchemy.url"] = testing_db_url()
    settings.update(custom_settings)
    return settings
Пример #8
0
def connection():
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from sqlalchemy import create_engine
    from kotti.testing import testing_db_url
    from kotti import metadata, DBSession
    engine = create_engine(testing_db_url())
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    return connection
Пример #9
0
def connection():
    """ sets up a SQLAlchemy engine and returns a connection
        to the database.  The connection string used for testing
        can be specified via the `KOTTI_TEST_DB_STRING` environment
        variable.
    """
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from sqlalchemy import create_engine
    from kotti.testing import testing_db_url
    from kotti import metadata, DBSession
    engine = create_engine(testing_db_url())
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    return connection
Пример #10
0
def connection():
    """ sets up a SQLAlchemy engine and returns a connection
        to the database.  The connection string used for testing
        can be specified via the `KOTTI_TEST_DB_STRING` environment
        variable.
    """
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from sqlalchemy import create_engine
    from kotti.testing import testing_db_url
    from kotti import metadata, DBSession
    engine = create_engine(testing_db_url())
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    return connection
Пример #11
0
def tnc_connection():
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from transaction import commit
    from sqlalchemy import create_engine
    from kotti.testing import testing_db_url
    from kotti import metadata, DBSession
    engine = create_engine(testing_db_url())
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    metadata.drop_all(engine)
    metadata.create_all(engine)
    for populate in tnc_settings()['kotti.populators']:
        populate()
    commit()
    return connection
Пример #12
0
def connection(custom_settings):
    """ sets up a SQLAlchemy engine and returns a connection to the database.
    The connection string used for testing can be specified via the
    ``KOTTI_TEST_DB_STRING`` environment variable.  The ``custom_settings``
    fixture is needed to allow users to import their models easily instead of
    having to override the ``connection``.
    """
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from sqlalchemy import create_engine
    from kotti import DBSession
    from kotti import metadata
    from kotti.resources import _adjust_for_engine
    from kotti.testing import testing_db_url
    engine = create_engine(testing_db_url())
    _adjust_for_engine(engine)
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    return connection
Пример #13
0
def connection(custom_settings):
    """ sets up a SQLAlchemy engine and returns a connection to the database.
    The connection string used for testing can be specified via the
    ``KOTTI_TEST_DB_STRING`` environment variable.  The ``custom_settings``
    fixture is needed to allow users to import their models easily instead of
    having to override the ``connection``.
    """
    # the following setup is based on `kotti.resources.initialize_sql`,
    # except that it explicitly binds the session to a specific connection
    # enabling us to use savepoints independent from the orm, thus allowing
    # to `rollback` after using `transaction.commit`...
    from sqlalchemy import create_engine
    from kotti import DBSession
    from kotti import metadata
    from kotti.resources import _adjust_for_engine
    from kotti.testing import testing_db_url
    engine = create_engine(testing_db_url())
    _adjust_for_engine(engine)
    connection = engine.connect()
    DBSession.registry.clear()
    DBSession.configure(bind=connection)
    metadata.bind = engine
    return connection
Пример #14
0
 def required_settings(self):
     return {'sqlalchemy.url': testing_db_url(),
             'kotti.secret': 'dude'}
Пример #15
0
 def setUp(self, **kwargs):
     self.settings = {'kotti.configurators': 'kotti_software.kotti_configure',
                      'sqlalchemy.url': testing_db_url(),
                      'kotti.secret': 'dude',
                      'kotti_software.collection_settings.pagesize': '5'}
     super(FunctionalTests, self).setUp(**self.settings)
Пример #16
0
 def required_settings(self):
     return {'sqlalchemy.url': testing_db_url(), 'kotti.secret': 'dude'}
Пример #17
0
 def required_settings(self):
     return {"sqlalchemy.url": testing_db_url(), "kotti.secret": "dude"}
Пример #18
0
 def required_settings(self):
     return {"sqlalchemy.url": testing_db_url(), "kotti.secret": "dude"}