refactor(simulation): Add strict type hints to simulation modules
This commit is contained in:
@@ -2,6 +2,7 @@ import sys
|
||||
import os
|
||||
import time
|
||||
import pytest
|
||||
from typing import Any, Optional
|
||||
from api_hook_client import ApiHookClient
|
||||
from simulation.workflow_sim import WorkflowSimulator
|
||||
|
||||
@@ -17,7 +18,7 @@ class BaseSimulation:
|
||||
self.sim = WorkflowSimulator(self.client)
|
||||
self.project_path = None
|
||||
|
||||
def setup(self, project_name="SimProject"):
|
||||
def setup(self, project_name: str = "SimProject") -> None:
|
||||
print(f"\n[BaseSim] Connecting to GUI...")
|
||||
if not self.client.wait_for_server(timeout=5):
|
||||
raise RuntimeError("Could not connect to GUI. Ensure it is running with --enable-test-hooks")
|
||||
@@ -43,20 +44,16 @@ class BaseSimulation:
|
||||
pass
|
||||
print("[BaseSim] Teardown complete.")
|
||||
|
||||
def get_value(self, tag):
|
||||
def get_value(self, tag: str) -> Any:
|
||||
return self.client.get_value(tag)
|
||||
|
||||
def wait_for_event(self, event_type, timeout=5):
|
||||
def wait_for_event(self, event_type: str, timeout: int = 5) -> Optional[dict]:
|
||||
return self.client.wait_for_event(event_type, timeout)
|
||||
|
||||
def assert_panel_visible(self, panel_tag, msg=None):
|
||||
# This assumes we have a hook to check panel visibility or just check if an element in it exists
|
||||
# For now, we'll check if we can get a value from an element that should be in that panel
|
||||
# or use a specific hook if available.
|
||||
# Actually, let's just check if get_indicator_state or similar works for generic tags.
|
||||
def assert_panel_visible(self, panel_tag: str, msg: str = None) -> None:
|
||||
pass
|
||||
|
||||
def wait_for_element(self, tag, timeout=2):
|
||||
def wait_for_element(self, tag: str, timeout: int = 2) -> bool:
|
||||
start = time.time()
|
||||
while time.time() - start < timeout:
|
||||
try:
|
||||
@@ -67,7 +64,7 @@ class BaseSimulation:
|
||||
time.sleep(0.1)
|
||||
return False
|
||||
|
||||
def run_sim(sim_class):
|
||||
def run_sim(sim_class: type) -> None:
|
||||
"""Helper to run a simulation class standalone."""
|
||||
sim = sim_class()
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user