Skip to content

Commit

Permalink
test with a temporary config folder
Browse files Browse the repository at this point in the history
  • Loading branch information
lalmei committed Dec 5, 2024
1 parent 03092a1 commit 7869481
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 58 deletions.
26 changes: 26 additions & 0 deletions tests/config/test_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from pathlib import Path

import pytest

import agml.backend.config as cfg


def test_config_setup():
"""Test that the config directory is set up correctly."""
tmp_config_dir = Path(os.getenv("AGML_CONFIG_DIR"))
# Check if the config directory exists
assert tmp_config_dir.exists()

# Check that the SUPER_BASE_DIR is set correctly
assert cfg.SUPER_BASE_DIR == tmp_config_dir

# Check that the default config file is created and valid parameters are accessible
default_config_file = tmp_config_dir / "config.json"
assert default_config_file.exists()

assert cfg.data_save_path() == cfg._get_config("data_path")
assert cfg.model_save_path() == cfg._get_config("model_path")
assert cfg.synthetic_data_save_path() == cfg._get_config("synthetic_data_path")


17 changes: 17 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import os
from pathlib import Path
import shutil

import pytest

from pytest import TempPathFactory


def pytest_sessionstart(session):
"""
Called before the whole run, right before
returning the exit status to the system.
"""
tmp_path_factory: TempPathFactory = session.config._tmp_path_factory
tmp_config_dir: Path = tmp_path_factory.mktemp("agml")
os.environ["AGML_CONFIG_DIR"] = str(tmp_config_dir)
58 changes: 0 additions & 58 deletions tests/main.py

This file was deleted.

0 comments on commit 7869481

Please sign in to comment.