File size: 932 Bytes
d1ecac0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
"""``BackendSettings`` imports cleanly and keeps its ``BACKEND_*`` field names."""

from __future__ import annotations

import subprocess
import sys
from pathlib import Path

import pytest

from app.core.config import BackendSettings

BACKEND_DIR = Path(__file__).resolve().parents[2]


def test_importing_the_settings_emits_no_user_warning() -> None:
    """A fresh interpreter, because the warning fires once, when the class is defined."""
    result = subprocess.run(
        [sys.executable, "-W", "error::UserWarning", "-c", "import app.core.config"],
        cwd=BACKEND_DIR,
        capture_output=True,
        text=True,
        check=False,
    )

    assert result.returncode == 0, result.stderr


def test_model_version_still_reads_its_environment_variable(
    monkeypatch: pytest.MonkeyPatch,
) -> None:
    monkeypatch.setenv("BACKEND_MODEL_VERSION", "v9.9.9")

    assert BackendSettings().model_version == "v9.9.9"