37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
from __future__ import annotations
|
|
|
|
import importlib.util
|
|
from pathlib import Path
|
|
|
|
|
|
def _load_cron_module():
|
|
root = Path(__file__).resolve().parents[3]
|
|
script = root / "scripts" / "cron_km_vectorize.py"
|
|
spec = importlib.util.spec_from_file_location("cron_km_vectorize", script)
|
|
assert spec is not None
|
|
assert spec.loader is not None
|
|
module = importlib.util.module_from_spec(spec)
|
|
spec.loader.exec_module(module)
|
|
return module
|
|
|
|
|
|
def test_project_headers_default_to_awoooi(monkeypatch):
|
|
monkeypatch.delenv("KM_PROJECT_ID", raising=False)
|
|
module = _load_cron_module()
|
|
|
|
assert module._project_headers() == {"X-Project-ID": "awoooi"}
|
|
|
|
|
|
def test_project_headers_use_env_value(monkeypatch):
|
|
monkeypatch.setenv("KM_PROJECT_ID", "tenant-a")
|
|
module = _load_cron_module()
|
|
|
|
assert module._project_headers() == {"X-Project-ID": "tenant-a"}
|
|
|
|
|
|
def test_project_headers_fallback_when_env_is_blank(monkeypatch):
|
|
monkeypatch.setenv("KM_PROJECT_ID", " ")
|
|
module = _load_cron_module()
|
|
|
|
assert module._project_headers() == {"X-Project-ID": "awoooi"}
|