32 lines
835 B
Python
32 lines
835 B
Python
import tkinter as tk
|
|
from target_simulator.gui.target_list_frame import TargetListFrame
|
|
from target_simulator.core.models import Target
|
|
|
|
|
|
class DummyMaster:
|
|
def __init__(self):
|
|
pass
|
|
|
|
|
|
def make_target(tid=1):
|
|
t = Target(tid)
|
|
t.target_id = tid
|
|
t.current_range_nm = 10.0
|
|
t.current_azimuth_deg = 0.0
|
|
t.current_velocity_fps = 0.0
|
|
t.current_heading_deg = 0.0
|
|
t.current_altitude_ft = 0.0
|
|
return t
|
|
|
|
|
|
def test_update_and_remove_target(monkeypatch):
|
|
tf = TargetListFrame(DummyMaster())
|
|
t1 = make_target(1)
|
|
t2 = make_target(2)
|
|
tf.update_target_list([t1, t2])
|
|
assert len(tf.get_targets()) == 2
|
|
|
|
# Simulate selection removal by setting tree focus to a missing id -> should show warning but not raise
|
|
monkeypatch.setattr(tf.tree, "focus", lambda: "")
|
|
tf._on_remove_click()
|