40 lines
1.1 KiB
Python
40 lines
1.1 KiB
Python
"""Helpers shared by the server tests."""
|
|||
|
|
|
||
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
import os
|
||
|
|
from pathlib import Path
|
||
|
|
from types import SimpleNamespace
|
||
|
|
from typing import Any
|
||
|
|
|
||
|
|
import pytest
|
||
|
|
|
||
|
|
from packetstation.settings import Settings
|
||
|
|
|
||
|
|
|
||
|
|
def make_settings(tmp: Path, **over: Any) -> Settings:
|
||
|
|
values: dict[str, Any] = {
|
||
|
|
"_env_file": None,
|
||
|
|
"stack": "ci",
|
||
|
|
"trusted_proxy_host": "",
|
||
|
|
"static_dir": tmp / "no-static",
|
||
|
|
"assets_dir": tmp / "assets",
|
||
|
|
"backup_dir": tmp / "no-backups",
|
||
|
|
}
|
||
|
|
values.update(over)
|
||
|
|
return Settings(**values)
|
||
|
|
|
||
|
|
|
||
|
|
def fake_visual(production: bool = False, explicit: bool = False) -> SimpleNamespace:
|
||
|
|
server, database = ("vsql", "PESCOINC") if production else (r"VSQL\DEV", "PESCOINCDEV")
|
||
|
|
return SimpleNamespace(
|
||
|
|
is_production=production,
|
||
|
|
server=server,
|
||
|
|
database=database,
|
||
|
|
model_fields_set={"server", "database"} if explicit else set(),
|
||
|
|
)
|
||
|
|
|
||
|
|
|
||
|
|
PG_URL = os.environ.get("TEST_PG_SUPERUSER_URL")
|
||
|
|
needs_pg = pytest.mark.skipif(not PG_URL, reason="TEST_PG_SUPERUSER_URL not set (no PostgreSQL)")
|