Files
m038 ade19fa094 feat(config): add optional IMMICH_DB_URL for pgvector spike
Optional Postgres DSN field on Config (REST creds stay required), env.example
entry, and a throwaway scripts/requirements-spike.txt (psycopg3 + pgvector)
kept out of the app's runtime deps. Unblocks the M1.5 pgvector feasibility spike.
2026-06-27 20:32:07 +02:00

29 lines
1.1 KiB
Python

import os
import pytest
from app.config import load_config, ConfigError
def test_missing_required_raises():
with pytest.raises(ConfigError) as e:
load_config({"IMMICH_URL": "http://x"})
assert "IMMICH_API_KEY" in e.value.missing
def test_anthropic_optional_and_paths(tmp_path):
cfg = load_config({"IMMICH_URL": "http://x/", "IMMICH_API_KEY": "k",
"DATA_DIR": str(tmp_path)})
assert cfg.immich_url == "http://x" # trailing slash stripped
assert cfg.anthropic_api_key == "" # optional in M1
assert cfg.db_path == os.path.join(str(tmp_path), "trip-cluster.db")
assert cfg.thumbs_dir == os.path.join(str(tmp_path), "thumbs")
def test_immich_db_url_optional():
# DSN is optional — only the pgvector spike / M1.5 need it; REST creds stay required.
cfg = load_config({"IMMICH_URL": "http://x", "IMMICH_API_KEY": "k"})
assert cfg.immich_db_url is None
cfg = load_config({"IMMICH_URL": "http://x", "IMMICH_API_KEY": "k",
"IMMICH_DB_URL": " postgresql://u:p@h:5432/immich "})
assert cfg.immich_db_url == "postgresql://u:p@h:5432/immich" # trimmed