#2533: fix primaite config recreated when running setup

This commit is contained in:
Czar Echavez
2024-04-30 19:15:54 +01:00
parent 73f64cd89c
commit 729f9c5064
6 changed files with 74 additions and 39 deletions

View File

@@ -3,6 +3,7 @@ import shutil
import tempfile
from pathlib import Path
import pkg_resources
import pytest
from primaite import _PRIMAITE_ROOT, PRIMAITE_PATHS
@@ -19,9 +20,8 @@ def test_setup():
temp_dir = tempfile.gettempdir()
temp_config = Path(temp_dir) / "primaite_config.yaml"
shutil.copyfile(
_PRIMAITE_ROOT / "setup" / "_package_data" / "primaite_config.yaml", temp_config
) # copy the default primaite config to temp directory
pkg_config_path = Path(pkg_resources.resource_filename("primaite", "setup/_package_data/primaite_config.yaml"))
shutil.copyfile(pkg_config_path, temp_config) # copy the default primaite config to temp directory
PRIMAITE_PATHS.app_config_file_path = temp_config # use the copy for the test
yield # run test
os.remove(temp_config) # clean up temp file