fix(api): read STAGING_DB from env at call time in _user_yaml_path()
Some checks failed
CI / test (push) Failing after 25s
Some checks failed
CI / test (push) Failing after 25s
Module-level DB_PATH is frozen at import time, so monkeypatch.setenv() in tests had no effect on _user_yaml_path(). Reading os.environ directly fixes 6 test_dev_api_settings PUT/POST failures in CI where /devl/job-seeker/ doesn't exist.
This commit is contained in:
parent
5266aa52e8
commit
b3223025fa
1 changed files with 4 additions and 5 deletions
|
|
@ -963,9 +963,7 @@ def config_user():
|
||||||
# Try to read name from user.yaml if present
|
# Try to read name from user.yaml if present
|
||||||
try:
|
try:
|
||||||
import yaml
|
import yaml
|
||||||
cfg_path = os.path.join(os.path.dirname(DB_PATH), "config", "user.yaml")
|
cfg_path = _user_yaml_path()
|
||||||
if not os.path.exists(cfg_path):
|
|
||||||
cfg_path = "/devl/job-seeker/config/user.yaml"
|
|
||||||
with open(cfg_path) as f:
|
with open(cfg_path) as f:
|
||||||
cfg = yaml.safe_load(f)
|
cfg = yaml.safe_load(f)
|
||||||
return {"name": cfg.get("name", "")}
|
return {"name": cfg.get("name", "")}
|
||||||
|
|
@ -979,8 +977,9 @@ from scripts.user_profile import load_user_profile, save_user_profile
|
||||||
|
|
||||||
|
|
||||||
def _user_yaml_path() -> str:
|
def _user_yaml_path() -> str:
|
||||||
"""Resolve user.yaml path, falling back to legacy location."""
|
"""Resolve user.yaml path relative to the current STAGING_DB location."""
|
||||||
cfg_path = os.path.join(os.path.dirname(DB_PATH), "config", "user.yaml")
|
db = os.environ.get("STAGING_DB", "/devl/job-seeker/staging.db")
|
||||||
|
cfg_path = os.path.join(os.path.dirname(db), "config", "user.yaml")
|
||||||
if not os.path.exists(cfg_path):
|
if not os.path.exists(cfg_path):
|
||||||
cfg_path = "/devl/job-seeker/config/user.yaml"
|
cfg_path = "/devl/job-seeker/config/user.yaml"
|
||||||
return cfg_path
|
return cfg_path
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue