Refactor radar system
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
"""Construct desktop fixtures without touching a running application's resources."""
|
||||
|
||||
from pathlib import Path
|
||||
import json
|
||||
import os
|
||||
import tempfile
|
||||
from unittest import mock
|
||||
|
||||
from python_app.gui.app_window import AppWindow
|
||||
|
||||
|
||||
def isolated_window(add_cleanup) -> AppWindow:
|
||||
temporary = tempfile.TemporaryDirectory(prefix="radar_gui_test_")
|
||||
add_cleanup(temporary.cleanup)
|
||||
root = Path(temporary.name)
|
||||
source = Path(__file__).resolve().parents[2]
|
||||
payload = json.loads((source / "run_config_examples/run_config_simulator.example.json").read_text(encoding="utf-8"))
|
||||
for name, ring in payload["rings"].items():
|
||||
ring["name"] = f"/{root.name}_{name}"
|
||||
payload["run"]["processing_live_config_path"] = str(root / "python_app/runtime/processing_live.json")
|
||||
payload["control_button"]["enabled"] = False
|
||||
profile = root / "run_config.json"
|
||||
profile.write_text(json.dumps(payload), encoding="utf-8")
|
||||
with mock.patch.dict(os.environ, {
|
||||
"RADAR_SYSTEM_PROFILE": str(profile), "RADAR_SYSTEM_AUTO_START": "0",
|
||||
"RADAR_SYSTEM_AUTO_APPLY_RADAR": "0",
|
||||
}), mock.patch.object(AppWindow, "_init_web_ui"):
|
||||
window = AppWindow(root)
|
||||
return window
|
||||
Reference in New Issue
Block a user