49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
"""Tests for the constants module."""
|
|
|
|
import re
|
|
|
|
import pytest
|
|
|
|
from src.constants import (
|
|
APP_NAME,
|
|
APP_TITLE,
|
|
VERSION,
|
|
_load_debug,
|
|
_load_version,
|
|
)
|
|
|
|
|
|
def test_load_version_returns_string() -> None:
|
|
assert isinstance(_load_version(), str)
|
|
|
|
|
|
def test_load_version_semver_format() -> None:
|
|
assert re.match(r"^\d+\.\d+\.\d+", _load_version()), f"Not semver: {_load_version()!r}"
|
|
|
|
|
|
def test_version_has_v_prefix() -> None:
|
|
assert VERSION.startswith("v")
|
|
|
|
|
|
def test_app_name_value() -> None:
|
|
assert APP_NAME == "GOGUpdater"
|
|
|
|
|
|
def test_app_title_contains_version() -> None:
|
|
assert VERSION in APP_TITLE
|
|
|
|
|
|
def test_load_debug_returns_bool() -> None:
|
|
assert isinstance(_load_debug(), bool)
|
|
|
|
|
|
def test_load_debug_true_variants(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
for value in ("true", "1", "yes", "YES", "True"):
|
|
monkeypatch.setenv("ENV_DEBUG", value)
|
|
assert _load_debug() is True, f"Expected True for ENV_DEBUG={value!r}"
|
|
|
|
|
|
def test_load_debug_false_when_unset(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
monkeypatch.delenv("ENV_DEBUG", raising=False)
|
|
assert _load_debug() is False
|