S1005403_RisCC/tests/test_trajectory_editor_logic_extra.py

39 lines
1.2 KiB
Python

import tkinter as tk
from target_simulator.gui.trajectory_editor_window import TrajectoryEditorWindow
from target_simulator.core.models import Waypoint, ManeuverType
class DummyMaster:
def __init__(self):
pass
def bind(self, *a, **k):
return None
def test_time_multiplier_parsing(monkeypatch):
monkeypatch.setattr(tk.Toplevel, 'wait_window', lambda self, w: None)
ed = TrajectoryEditorWindow(DummyMaster(), existing_ids=[], max_range_nm=50)
ed.time_multiplier_var.set('4x')
ed._on_time_multiplier_changed()
assert ed.time_multiplier == 4.0
def test_total_simulation_time_calculation(monkeypatch):
monkeypatch.setattr(tk.Toplevel, 'wait_window', lambda self, w: None)
ed = TrajectoryEditorWindow(DummyMaster(), existing_ids=[], max_range_nm=50)
# set valid waypoints
w1 = Waypoint()
w1.maneuver_type = ManeuverType.FLY_TO_POINT
w1.target_range_nm = 1
w1.target_azimuth_deg = 0
w1.target_altitude_ft = 0
w2 = Waypoint()
w2.maneuver_type = ManeuverType.FLY_TO_POINT
w2.duration_s = 5
w2.target_range_nm = 2
w2.target_azimuth_deg = 0
w2.target_altitude_ft = 0
ed.waypoints = [w1, w2]
t = ed._get_total_simulation_time()
assert isinstance(t, float) and t >= 0.0