mirror of
https://github.com/Frooodle/Stirling-PDF.git
synced 2026-04-22 23:08:53 +02:00
Add SaaS AI engine (#5907)
This commit is contained in:
31
engine/tests/test_env.py
Normal file
31
engine/tests/test_env.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from dotenv import dotenv_values
|
||||
|
||||
ENGINE_ROOT = Path(__file__).parent.parent
|
||||
SRC_DIR = ENGINE_ROOT / "src"
|
||||
EXAMPLE_FILE = ENGINE_ROOT / "config" / ".env.example"
|
||||
|
||||
|
||||
def _parse_example_keys() -> set[str]:
|
||||
return set(dotenv_values(EXAMPLE_FILE).keys())
|
||||
|
||||
|
||||
def _find_stirling_env_vars() -> set[str]:
|
||||
env_vars: set[str] = set()
|
||||
for path in SRC_DIR.rglob("*.py"):
|
||||
for match in re.finditer(r"\b(STIRLING_\w+)\b", path.read_text()):
|
||||
env_vars.add(match.group(1))
|
||||
return env_vars
|
||||
|
||||
|
||||
def test_every_stirling_env_var_is_in_example_file():
|
||||
example_keys = _parse_example_keys()
|
||||
source_vars = _find_stirling_env_vars()
|
||||
missing = sorted(source_vars - example_keys)
|
||||
assert not missing, "env vars used in src/ but missing from config/.env.example:\n" + "\n".join(
|
||||
f" {v}" for v in missing
|
||||
)
|
||||
Reference in New Issue
Block a user