66"""
77
88import time
9+
910import pytest
11+ from fprime_gds .common .data_types .ch_data import ChData
12+ from fprime_gds .common .testing_fw .api import IntegrationTestAPI
13+
1014
1115@pytest .fixture (autouse = True )
12- def ensure_watchdog_running (fprime_test_api ):
16+ def ensure_watchdog_running (fprime_test_api : IntegrationTestAPI ):
1317 """Fixture to ensure watchdog is started before and after each test"""
1418 start_watchdog (fprime_test_api )
1519 yield
1620 start_watchdog (fprime_test_api )
1721
18- def start_watchdog (fprime_test_api ):
22+
23+ def start_watchdog (fprime_test_api : IntegrationTestAPI ):
1924 """Helper function to start the watchdog"""
2025 fprime_test_api .send_and_assert_command (
21- "ReferenceDeployment.watchdog.START_WATCHDOG" ,
22- max_delay = 2
26+ "ReferenceDeployment.watchdog.START_WATCHDOG" , max_delay = 2
2327 )
2428 fprime_test_api .assert_event (
25- "ReferenceDeployment.watchdog.WatchdogStart" ,
26- timeout = 2
29+ "ReferenceDeployment.watchdog.WatchdogStart" , timeout = 2
2730 )
2831
29- def get_watchdog_transitions (fprime_test_api ):
32+
33+ def get_watchdog_transitions (fprime_test_api : IntegrationTestAPI ) -> int :
3034 """Helper function to request packet and get fresh WatchdogTransitions telemetry"""
3135 fprime_test_api .clear_histories ()
32- fprime_test_api .send_and_assert_command ("CdhCore.tlmSend.SEND_PKT" , ["5" ], max_delay = 2 )
33- result = fprime_test_api .assert_telemetry (
34- "ReferenceDeployment.watchdog.WatchdogTransitions" ,
35- start = "NOW" , timeout = 3
36+ fprime_test_api .send_and_assert_command (
37+ "CdhCore.tlmSend.SEND_PKT" , ["5" ], max_delay = 2
38+ )
39+ result : ChData = fprime_test_api .assert_telemetry (
40+ "ReferenceDeployment.watchdog.WatchdogTransitions" , start = "NOW" , timeout = 3
3641 )
3742 return result .get_val ()
3843
3944
40- def test_01_watchdog_telemetry_basic (fprime_test_api ):
45+ def test_01_watchdog_telemetry_basic (fprime_test_api : IntegrationTestAPI ):
4146 """Test that we can read WatchdogTransitions telemetry"""
4247 value = get_watchdog_transitions (fprime_test_api )
4348 assert value >= 0 , f"WatchdogTransitions should be >= 0, got { value } "
4449
4550
46- def test_02_watchdog_increments (fprime_test_api ):
51+ def test_02_watchdog_increments (fprime_test_api : IntegrationTestAPI ):
4752 """Test that WatchdogTransitions increments over time"""
4853
4954 initial_value = get_watchdog_transitions (fprime_test_api )
5055 time .sleep (2.0 ) # Wait for watchdog to run more cycles
5156 updated_value = get_watchdog_transitions (fprime_test_api )
5257
53- assert updated_value > initial_value , \
58+ assert updated_value > initial_value , (
5459 f"WatchdogTransitions should increase. Initial: { initial_value } , Updated: { updated_value } "
60+ )
5561
5662
57- def test_03_stop_watchdog_command (fprime_test_api ):
63+ def test_03_stop_watchdog_command (fprime_test_api : IntegrationTestAPI ):
5864 """
5965 Test STOP_WATCHDOG command sends and emits WatchdogStop
6066 event and WatchdogTransitions stops incrementing
@@ -63,15 +69,11 @@ def test_03_stop_watchdog_command(fprime_test_api):
6369
6470 # Send stop command
6571 fprime_test_api .send_and_assert_command (
66- "ReferenceDeployment.watchdog.STOP_WATCHDOG" ,
67- max_delay = 2
72+ "ReferenceDeployment.watchdog.STOP_WATCHDOG" , max_delay = 2
6873 )
6974
7075 # Check for watchdog stop event
71- fprime_test_api .assert_event (
72- "ReferenceDeployment.watchdog.WatchdogStop" ,
73- timeout = 2
74- )
76+ fprime_test_api .assert_event ("ReferenceDeployment.watchdog.WatchdogStop" , timeout = 2 )
7577
7678 # Get watchdog transition count
7779 initial_value = get_watchdog_transitions (fprime_test_api )
@@ -80,5 +82,6 @@ def test_03_stop_watchdog_command(fprime_test_api):
8082 time .sleep (2.0 )
8183 final_value = get_watchdog_transitions (fprime_test_api )
8284
83- assert final_value == initial_value , \
85+ assert final_value == initial_value , (
8486 f"Watchdog should remain stopped. Initial: { initial_value } , Final: { final_value } "
87+ )
0 commit comments