diff --git a/test/conftest.py b/test/conftest.py index 5a53527..2689bd4 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -2,11 +2,16 @@ import sys import pytest +# These tests assumes the green-metrics-tool directory lives side by side with the examples-repository +CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) +ROOT_DIR = os.path.abspath(f"{CURRENT_DIR}/../") +GMT_TEST_DIR = os.path.abspath(f"{CURRENT_DIR}/../../green-metrics-tool/tests") + ## VERY IMPORTANT to override the config file here ## otherwise it will automatically connect to non-test DB and delete all your real data from lib.global_config import GlobalConfig from lib.db import DB -GlobalConfig().override_config(config_name='test-config.yml') +GlobalConfig().override_config(config_location=f"{GMT_TEST_DIR}/test-config.yml") def pytest_addoption(parser): parser.addoption("--name", action="store") diff --git a/test/smoke_test.py b/test/smoke_test.py index 2f28137..3292149 100644 --- a/test/smoke_test.py +++ b/test/smoke_test.py @@ -6,6 +6,8 @@ # These tests assumes the green-metrics-tool directory lives side by side with the examples-repository CURRENT_DIR = os.path.dirname(os.path.abspath(__file__)) ROOT_DIR = os.path.abspath(f"{CURRENT_DIR}/../") +GMT_TEST_DIR = os.path.abspath(f"{CURRENT_DIR}/../../green-metrics-tool/tests") + sys.path.append(f"{CURRENT_DIR}/../../green-metrics-tool") sys.path.append(f"{CURRENT_DIR}/../../green-metrics-tool/tools") sys.path.append(f"{CURRENT_DIR}/../../green-metrics-tool/lib") @@ -17,7 +19,7 @@ from db import DB #pylint: disable=expression-not-assigned -GlobalConfig(config_name='test-config.yml').config +GlobalConfig(config_location=f"{GMT_TEST_DIR}/test-config.yml").config def example_directories(): example_dirs = []