agent0.chainsync.test_fixtures.db_session

Create an in memory db session and creates the base db schema.

Attributes

TEST_POSTGRES_NAME

Functions

psql_docker(→ Iterator[agent0.chainsync.PostgresConfig])

Test fixture for running postgres in docker.

database_engine(→ Iterator[sqlalchemy.Engine])

Create psql engine on local postgres container.

db_session(→ Iterator[sqlalchemy.orm.Session])

Initialize the in memory db session and creates the db schema.

Module Contents

agent0.chainsync.test_fixtures.db_session.TEST_POSTGRES_NAME = 'postgres_test'
agent0.chainsync.test_fixtures.db_session.psql_docker() Iterator[agent0.chainsync.PostgresConfig]

Test fixture for running postgres in docker.

Yields:

PostgresConfig – The PostgresConfig.

agent0.chainsync.test_fixtures.db_session.database_engine(psql_docker: agent0.chainsync.PostgresConfig) Iterator[sqlalchemy.Engine]

Create psql engine on local postgres container.

Parameters:

psql_docker (PostgresConfig) – The PostgresConfig object returned by the psql_docker test fixture.

Yields:

Engine – The sqlalchemy engine.

agent0.chainsync.test_fixtures.db_session.db_session(database_engine: sqlalchemy.Engine) Iterator[sqlalchemy.orm.Session]

Initialize the in memory db session and creates the db schema.

Parameters:

database_engine (Engine) – The sqlalchemy database engine returned from the database_engine test fixture.

Yields:

Session – The sqlalchemy session object.