Release v0.1.2
This commit is contained in:
51
tests/test_devserver.py
Normal file
51
tests/test_devserver.py
Normal file
@@ -0,0 +1,51 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
class DevserverSmokeTests(unittest.TestCase):
|
||||
def test_smoke_mode_bootstraps_missing_local_sqlite_database(self) -> None:
|
||||
repo_root = Path(__file__).resolve().parents[1]
|
||||
src_root = repo_root / "src"
|
||||
with tempfile.TemporaryDirectory(prefix="govoplan-devserver-smoke-") as directory:
|
||||
runtime_root = Path(directory)
|
||||
env = os.environ.copy()
|
||||
for key in (
|
||||
"DATABASE_URL",
|
||||
"DEV_BOOTSTRAP_ENABLED",
|
||||
"GOVOPLAN_SERVER_CONFIG",
|
||||
"FILE_STORAGE_LOCAL_ROOT",
|
||||
"MOCK_MAILBOX_DIR",
|
||||
):
|
||||
env.pop(key, None)
|
||||
env["APP_ENV"] = "dev"
|
||||
env["CELERY_ENABLED"] = "false"
|
||||
env["ENABLED_MODULES"] = "access"
|
||||
env["PYTHONPATH"] = str(src_root) + (os.pathsep + env["PYTHONPATH"] if env.get("PYTHONPATH") else "")
|
||||
|
||||
result = subprocess.run(
|
||||
[sys.executable, "-m", "govoplan_core.devserver", "--smoke", "--no-reload"],
|
||||
cwd=runtime_root,
|
||||
env=env,
|
||||
text=True,
|
||||
capture_output=True,
|
||||
check=False,
|
||||
)
|
||||
|
||||
self.assertEqual(result.returncode, 0, result.stderr or result.stdout)
|
||||
db_path = runtime_root / "runtime" / "multimailer-dev.db"
|
||||
self.assertTrue(db_path.exists(), result.stdout)
|
||||
self.assertGreater(db_path.stat().st_size, 0, result.stdout)
|
||||
self.assertIn(f"Runtime root: {runtime_root}", result.stdout)
|
||||
self.assertIn(f"Database: sqlite:///{db_path}", result.stdout)
|
||||
self.assertIn("Dev bootstrap for missing SQLite DB: enabled", result.stdout)
|
||||
self.assertIn("Smoke check: OK", result.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user