Skip to content

Commit 7869481

Browse files
committed
test with a temporary config folder
1 parent 03092a1 commit 7869481

File tree

3 files changed

+43
-58
lines changed

3 files changed

+43
-58
lines changed

tests/config/test_config.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import os
2+
from pathlib import Path
3+
4+
import pytest
5+
6+
import agml.backend.config as cfg
7+
8+
9+
def test_config_setup():
10+
"""Test that the config directory is set up correctly."""
11+
tmp_config_dir = Path(os.getenv("AGML_CONFIG_DIR"))
12+
# Check if the config directory exists
13+
assert tmp_config_dir.exists()
14+
15+
# Check that the SUPER_BASE_DIR is set correctly
16+
assert cfg.SUPER_BASE_DIR == tmp_config_dir
17+
18+
# Check that the default config file is created and valid parameters are accessible
19+
default_config_file = tmp_config_dir / "config.json"
20+
assert default_config_file.exists()
21+
22+
assert cfg.data_save_path() == cfg._get_config("data_path")
23+
assert cfg.model_save_path() == cfg._get_config("model_path")
24+
assert cfg.synthetic_data_save_path() == cfg._get_config("synthetic_data_path")
25+
26+

tests/conftest.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import os
2+
from pathlib import Path
3+
import shutil
4+
5+
import pytest
6+
7+
from pytest import TempPathFactory
8+
9+
10+
def pytest_sessionstart(session):
11+
"""
12+
Called before the whole run, right before
13+
returning the exit status to the system.
14+
"""
15+
tmp_path_factory: TempPathFactory = session.config._tmp_path_factory
16+
tmp_config_dir: Path = tmp_path_factory.mktemp("agml")
17+
os.environ["AGML_CONFIG_DIR"] = str(tmp_config_dir)

tests/main.py

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)