def test_cursor_selects_postgres_database(connect_mock: MagicMock) -> None: """Test that the cursor requests the postgres database.""" janitor = DatabaseJanitor("user", "host", "1234", "database_name", 10) with janitor.cursor(): connect_mock.assert_called_once_with(dbname="postgres", user="******", password=None, host="host", port="1234")
def test_cursor_selects_postgres_database(connect_mock): """Test that the cursor requests the postgres database.""" janitor = DatabaseJanitor('user', 'host', '1234', 'database_name', 9.0) with janitor.cursor(): connect_mock.assert_called_once_with( dbname='postgres', user='******', host='host', port='1234' )
def database(postgresql_proc): """Initialize a test postgres database.""" janitor = DatabaseJanitor( postgresql_proc.user, postgresql_proc.host, postgresql_proc.port, postgresql_proc.dbname, postgresql_proc.version, postgresql_proc.password, ) janitor.init() with janitor.cursor() as cur: cur.execute("""\ CREATE TABLE my_source_1 (id serial PRIMARY KEY, num integer); CREATE TABLE my_source_2 (id serial PRIMARY KEY, num integer); """) yield postgresql_proc janitor.drop()