The oslo_db.sqlalchemy.test_base Module

The oslo_db.sqlalchemy.test_base Module

class oslo_db.sqlalchemy.test_base.DbFixture(*args, **kwargs)

Bases: fixtures.fixture.Fixture

Basic database fixture.

Allows to run tests on various db backends, such as SQLite, MySQL and PostgreSQL. By default use sqlite backend. To override default backend uri set env variable OS_TEST_DBAPI_ADMIN_CONNECTION with database admin credentials for specific backend.

DBNAME = 'openstack_citest'
DRIVER = 'sqlite'
PASSWORD = 'openstack_citest'
USERNAME = 'openstack_citest'
setUp()
class oslo_db.sqlalchemy.test_base.DbTestCase(*args, **kwargs)

Bases: oslotest.base.BaseTestCase

Base class for testing of DB code.

FIXTURE

alias of DbFixture

SCHEMA_SCOPE = None
SKIP_ON_UNAVAILABLE_DB = True
generate_schema(engine)

Generate schema objects to be used within a test.

The function is separate from the setUp() case as the scope of this method is controlled by the provisioning system. A test that specifies SCHEMA_SCOPE may not call this method for each test, as the schema may be maintained from a previous run.

resources
setUp()
class oslo_db.sqlalchemy.test_base.MySQLOpportunisticFixture(*args, **kwargs)

Bases: oslo_db.sqlalchemy.test_base.DbFixture

DRIVER = 'mysql'
class oslo_db.sqlalchemy.test_base.MySQLOpportunisticTestCase(*args, **kwargs)

Bases: oslo_db.sqlalchemy.test_base.OpportunisticTestCase

FIXTURE

alias of MySQLOpportunisticFixture

class oslo_db.sqlalchemy.test_base.OpportunisticTestCase(*args, **kwargs)

Bases: oslo_db.sqlalchemy.test_base.DbTestCase

Placeholder for backwards compatibility.

class oslo_db.sqlalchemy.test_base.PostgreSQLOpportunisticFixture(*args, **kwargs)

Bases: oslo_db.sqlalchemy.test_base.DbFixture

DRIVER = 'postgresql'
class oslo_db.sqlalchemy.test_base.PostgreSQLOpportunisticTestCase(*args, **kwargs)

Bases: oslo_db.sqlalchemy.test_base.OpportunisticTestCase

FIXTURE

alias of PostgreSQLOpportunisticFixture

oslo_db.sqlalchemy.test_base.backend_specific(*dialects)

Decorator to skip backend specific tests on inappropriate engines.

::dialects: list of dialects names under which the test will be launched.

oslo_db.sqlalchemy.test_base.optimize_db_test_loader(*args, **kwargs)

Organize package-level tests into a testresources.OptimizingTestSuite.

This function provides a unittest-compatible load_tests hook for a given package; for per-module, use the optimize_module_test_loader() function.

When a unitest or subunit style test runner is used, the function will be called in order to return a TestSuite containing the tests to run; this function ensures that this suite is an OptimisingTestSuite, which will organize the production of test resources across groups of tests at once.

The function is invoked as:

from oslo_db.sqlalchemy import test_base

load_tests = test_base.optimize_package_test_loader(__file__)

The loader must be present in the package level __init__.py.

The function also applies testscenarios expansion to all test collections. This so that an existing test suite that already needs to build TestScenarios from a load_tests call can still have this take place when replaced with this function.

Creative Commons Attribution 3.0 License

Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.