From 778c297724917ffe123a7a3b145f2ddd4afa1384 Mon Sep 17 00:00:00 2001 From: Dimitris Papagiannis Date: Wed, 5 Jun 2024 18:49:36 +0200 Subject: [PATCH] Cleanup --- tests/fixtures.py | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/tests/fixtures.py b/tests/fixtures.py index e6d9b4f..63e93cb 100644 --- a/tests/fixtures.py +++ b/tests/fixtures.py @@ -92,24 +92,22 @@ def cfg(): @pytest.fixture def testing_database(): + username = os.environ.get("POSTGRES_USERNAME", "postgres") + password = os.environ.get("POSTGRES_PASSWORD", "postgres") + host = os.environ.get("POSTGRES_HOST", "127.0.0.1") + port = os.environ.get("POSTGRES_PORT", 5432) + db_name = "postgres_test" db_uri = DQM2MirrorDB.format_db_uri( - username=os.environ.get("POSTGRES_USERNAME", "postgres"), - password=os.environ.get("POSTGRES_PASSWORD", "postgres"), - host=os.environ.get("POSTGRES_HOST", "127.0.0.1"), - port=os.environ.get("POSTGRES_PORT", 5432), - db_name="postgres_test", + username=username, password=password, host=host, port=port, db_name=db_name ) - engine = create_engine(db_uri) - if not database_exists(engine.url): - create_database(db_uri) - db = DQM2MirrorDB( - log=dummy_log(), - username=os.environ.get("POSTGRES_USERNAME", "postgres"), - password=os.environ.get("POSTGRES_PASSWORD", "postgres"), - host=os.environ.get("POSTGRES_HOST", "127.0.0.1"), - port=os.environ.get("POSTGRES_PORT", 5432), - db_name="postgres_test", - server=False, + + db = get_or_create_db( + db_uri=db_uri, + username=username, + password=password, + host=host, + port=port, + db_name=db_name, ) fill_db(db) @@ -123,8 +121,8 @@ def testing_databases(): password = os.environ.get("POSTGRES_PASSWORD", "postgres") host = os.environ.get("POSTGRES_HOST", "127.0.0.1") port = os.environ.get("POSTGRES_PORT", 5432) - db_prod_name = os.environ.get("POSTGRES_PRODUCTION_DB_NAME") + "_test" - db_play_name = os.environ.get("POSTGRES_PLAYBACK_DB_NAME") + "_test" + db_prod_name = "postgres_production_test" + db_play_name = "postgres_playback_tests" db_prod_uri = DQM2MirrorDB.format_db_uri( username=username, password=password, host=host, port=port, db_name=db_prod_name )