Rework radar system

This commit is contained in:
Ayzen
2026-10-06 12:32:26 +03:00
parent 552cdc688a
commit 5bb86b7165
299 changed files with 13537 additions and 27763 deletions
+24 -1
View File
@@ -1,12 +1,20 @@
"""Construct desktop fixtures without touching a running application's resources."""
from pathlib import Path
from typing import TypeVar
from PyQt6.QtWidgets import QWidget
from python_app.gui.controllers.sections.views import SectionView
_Widget = TypeVar("_Widget", bound=QWidget)
import json
import os
import tempfile
from unittest import mock
from PyQt6.QtCore import QCoreApplication, QEvent
from python_app.gui.app_window import AppWindow
from python_app.gui.controllers.web_controller import WebBridge
def isolated_window(add_cleanup) -> AppWindow:
@@ -24,6 +32,21 @@ def isolated_window(add_cleanup) -> AppWindow:
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"):
}), mock.patch.object(WebBridge, "start_server"):
window = AppWindow(root)
def destroy_window() -> None:
window.close()
# Close stops services; Qt must destroy the widget tree before Python GC
# can collect the controller callbacks and their graphics objects.
window.deleteLater()
QCoreApplication.sendPostedEvents(window, QEvent.Type.DeferredDelete)
add_cleanup(destroy_window)
return window
def widget(view: SectionView, name: str, kind: type[_Widget]) -> _Widget:
value = view.fields[name]
assert isinstance(value, kind), name
return value