ExamplePostgresWrapper

class tests.test_postgres.ExamplePostgresWrapper(*args, **kwargs)[source]

A wrapper around PostgresWrapper and TestWrapperMixin for use in Postgres tests.

  • Sets the default database to privex_py_db

  • Creates the table users

  • Includes two helper query methods insert_user() and find_user()

__init__(*args, **kwargs)[source]

Initialise the database wrapper class.

Parameters
  • db (str) – Database name

  • db_user (str) – Account username with permission for db (defaults to root)

  • db_pass (str) – Account password for db_user (defaults to None)

  • db_host (str) – Database host (defaults to unix socket)

Key str db_schema

(Default: 'public') Schema used for querying table existence

Key str query_mode

Either 'flat' (query returns tuples) or 'dict' (query returns dicts). More details in PyDoc block under query_mode

Key psycopg2.extensions.cursor cursor_cls

If necessary, you may override the Psycopg2 cursor class used by specifying this kwarg. If this isn’t specified, cursor_cls will default to either psycopg2.extras.RealDictCursor if query_mode is dict, or psycopg2.extras.NamedTupleCursor if query_mode is flat.

Methods

Methods

__init__(*args, **kwargs)

Initialise the database wrapper class.

find_user(id)

insert_user(first_name, last_name)

Attributes

Attributes

DEFAULT_DB

SCHEMAS