audit_trail.pytest_plugin¶
pytest fixtures for the audit tables of a test database.
For test databases whose migrations do not create the audit tables. Enable
the plugin in the root conftest.py and override audit_trail there,
session-scoped, to return the application's AuditTrail; its engine must
point at the test database::
pytest_plugins = ["audit_trail.pytest_plugin"]
@pytest.fixture(scope="session")
def audit_trail() -> AuditTrail:
return AuditTrail(test_engine, schema="audit")
Fixtures:
audit_tables(session): creates the audit tables and the partitions of the current and the next month, and drops the tables at the end.audit_clean(function): empties the tables before the test.
Both return the AuditTrail. With an AsyncEngine they run in an event
loop of their own, on a copy of the engine's pool that is closed afterwards:
the pool the tests use is not touched, whatever event loop its connections
belong to.
audit_trail ¶
The application's AuditTrail; override it in conftest.py.
Source code in audit_trail/pytest_plugin.py
audit_tables ¶
Create the audit tables and partitions; drop the tables afterwards.
Source code in audit_trail/pytest_plugin.py
audit_clean ¶
audit_tables, emptied before the test.