Add enterprise appliance experience Phase 1 foundation
This commit is contained in:
1 parent
b3eec34158
commit
ebaa2e7219
69 files changed
+6832
-18
No files matched your search
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import importlib.util
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
BACKEND_MAIN = REPO_ROOT / "ansible/roles/cezen-backend/files/main.py"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def isolated_appliance(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> dict[str, Path]:
|
||||
"""Return isolated appliance paths and never touch /opt/cezen."""
|
||||
data = tmp_path / "data"
|
||||
backups = tmp_path / "backups"
|
||||
data.mkdir()
|
||||
backups.mkdir()
|
||||
monkeypatch.setenv("CEZEN_DATA", str(data))
|
||||
monkeypatch.setenv("CEZEN_BACKUP_DIR", str(backups))
|
||||
monkeypatch.setenv("CEZEN_LICENSE_JSON", str(tmp_path / "license.json"))
|
||||
return {"root": tmp_path, "data": data, "backups": backups}
|
||||
|
||||
|
||||
def load_backend_module(module_name: str = "cezen_backend_test"):
|
||||
"""Load the packaged backend only after fixtures set environment variables."""
|
||||
spec = importlib.util.spec_from_file_location(module_name, BACKEND_MAIN)
|
||||
if spec is None or spec.loader is None:
|
||||
raise RuntimeError(f"Cannot load backend from {BACKEND_MAIN}")
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
return module
|
||||
Reference in new issue
Block a user