mirror of
https://github.com/bunny-lab-io/Borealis.git
synced 2025-10-28 15:01:57 -06:00
Fixed Engine Flask Server Accessibility
This commit is contained in:
@@ -117,6 +117,13 @@ def engine_harness(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[
|
||||
log_path = logs_dir / "server.log"
|
||||
error_log_path = logs_dir / "error.log"
|
||||
|
||||
static_dir = tmp_path / "static"
|
||||
static_dir.mkdir(parents=True, exist_ok=True)
|
||||
(static_dir / "index.html").write_text("<html><body>Engine Test UI</body></html>", encoding="utf-8")
|
||||
assets_dir = static_dir / "assets"
|
||||
assets_dir.mkdir(parents=True, exist_ok=True)
|
||||
(assets_dir / "example.txt").write_text("asset", encoding="utf-8")
|
||||
|
||||
config = {
|
||||
"DATABASE_PATH": str(db_path),
|
||||
"TLS_CERT_PATH": str(cert_path),
|
||||
@@ -124,7 +131,8 @@ def engine_harness(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Iterator[
|
||||
"TLS_BUNDLE_PATH": str(bundle_path),
|
||||
"LOG_FILE": str(log_path),
|
||||
"ERROR_LOG_FILE": str(error_log_path),
|
||||
"API_GROUPS": ("tokens", "enrollment"),
|
||||
"STATIC_FOLDER": str(static_dir),
|
||||
"API_GROUPS": ("core", "tokens", "enrollment"),
|
||||
}
|
||||
|
||||
app, _socketio, _context = create_app(config)
|
||||
|
||||
9
Data/Engine/Unit_Tests/test_core_api.py
Normal file
9
Data/Engine/Unit_Tests/test_core_api.py
Normal file
@@ -0,0 +1,9 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_health_endpoint(engine_harness):
|
||||
client = engine_harness.app.test_client()
|
||||
response = client.get("/health")
|
||||
assert response.status_code == 200
|
||||
payload = response.get_json()
|
||||
assert payload == {"status": "ok"}
|
||||
23
Data/Engine/Unit_Tests/test_web_ui.py
Normal file
23
Data/Engine/Unit_Tests/test_web_ui.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def test_web_ui_root_serves_index(engine_harness):
|
||||
client = engine_harness.app.test_client()
|
||||
response = client.get("/")
|
||||
assert response.status_code == 200
|
||||
body = response.get_data(as_text=True)
|
||||
assert "Engine Test UI" in body
|
||||
|
||||
|
||||
def test_web_ui_serves_static_assets(engine_harness):
|
||||
client = engine_harness.app.test_client()
|
||||
response = client.get("/assets/example.txt")
|
||||
assert response.status_code == 200
|
||||
assert response.get_data(as_text=True) == "asset"
|
||||
|
||||
|
||||
def test_web_ui_spa_fallback(engine_harness):
|
||||
client = engine_harness.app.test_client()
|
||||
response = client.get("/devices")
|
||||
assert response.status_code == 200
|
||||
assert "Engine Test UI" in response.get_data(as_text=True)
|
||||
Reference in New Issue
Block a user