c.t.mockdb : module documentation

Part of canonical.testing

A self maintaining mock database for tests.

The first time a MockDbConnection is used, it functions as a proxy to the real database connection. Queries and results are recorded into a script.

For subsequent runs, if the same queries are issued in the same order then results are returned from the script and the real database is not used. If the script is detected as being invalid, it is removed and a RetryTest exception raised for the test runner to deal with.

Function script_filename Calculate and return the script filename to use.
Class ScriptEntry An entry in our test's log of database calls.
Class ConnectScriptEntry An entry created instantiating a Connection.
Class ExecuteScriptEntry An entry created via Cursor.execute().
Class CloseScriptEntry An entry created via Connection.close().
Class CommitScriptEntry An entry created via Connection.commit().
Class RollbackScriptEntry An entry created via Connection.rollback().
Class SetIsolationLevelScriptEntry An entry created via Connection.set_isolation_level().
Class ScriptRecorder No class docstring; 8/9 methods documented
Function noop_if_invalid Decorator that causes the decorated method to be a noop if the
Class ScriptPlayer Replay database queries from a script.
Class MockDbConnection Connection to our Mock database.
Class MockDbCursor A fake DB-API cursor as produced by MockDbConnection.cursor.
def script_filename(key):
Calculate and return the script filename to use.
def noop_if_invalid(func):
Decorator that causes the decorated method to be a noop if the script this method belongs too is invalid.

This allows teardown to complete when a ReplayScript has raised a RetryTest exception. Normally during teardown DB operations are made when doing things like aborting the transaction.

API Documentation for Launchpad, generated by pydoctor at 2010-09-27 00:00:11.