Skip to content

Commit

Permalink
Moved to new param for GlobalConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
ArneTR committed Oct 17, 2024
1 parent 8608a10 commit 8e5d739
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 6 additions & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion test/smoke_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 = []
Expand Down

0 comments on commit 8e5d739

Please sign in to comment.