kotti.tests¶
Fixture dependencies¶
- kotti.tests.custom_settings()[source]¶
This is a dummy fixture meant to be overridden in add on package’s
conftest.py
. It can be used to inject arbitrary settings for third party test suites. The default settings dictionary will be updated with the dictionary returned by this fixture.This is also a good place to import your add on’s
resources
module to have the corresponding tables created duringcreate_all()
inkotti.tests.content()
.- Result
settings
- Return type
dict
- kotti.tests.config(settings)[source]¶
returns a Pyramid Configurator object initialized with Kotti’s default (test) settings.
- kotti.tests.connection(custom_settings)[source]¶
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. Thecustom_settings
fixture is needed to allow users to import their models easily instead of having to override theconnection
.
- kotti.tests.content(connection, settings)[source]¶
sets up some default content using Kotti’s testing populator.
- kotti.tests.db_session(config, content, connection)[source]¶
returns a db session object and sets up a db transaction savepoint, which will be rolled back after the test.
- kotti.tests.dummy_request(config, request, monkeypatch)[source]¶
returns a dummy request object after registering it as the currently active request. This is needed when pyramid.threadlocal.get_current_request is used.
- kotti.tests.browser(db_session, request, setup_app)[source]¶
returns an instance of zope.testbrowser. The kotti.testing.user pytest marker (or pytest.mark.user) can be used to pre-authenticate the browser with the given login name: @user(‘admin’).
- kotti.tests.depot_tween(config, dummy_request)[source]¶
Sets up the Depot tween and patches Depot’s
set_middleware
to suppress exceptions on subsequent calls. Yields theDepotManager
.
- kotti.tests.mock_filedepot(depot_tween)[source]¶
Configures a mock depot store for
depot.manager.DepotManager
This filedepot is not integrated with dbsession. Can be used in simple, standalone unit tests.
- kotti.tests.filedepot(db_session, depot_tween)[source]¶
Configures a dbsession integrated mock depot store for
depot.manager.DepotManager