44Integration tests for the Load-Switch component.
55"""
66
7- import time
8-
97import pytest
108from common import proves_send_and_assert_command
119from fprime_gds .common .data_types .ch_data import ChData
1210from fprime_gds .common .testing_fw .api import IntegrationTestAPI
1311
1412loadswitch = "ReferenceDeployment.loadswitch"
1513
14+
1615@pytest .fixture (autouse = True )
1716def ensure_loadswitch_off (fprime_test_api : IntegrationTestAPI , start_gds ):
1817 """Ensure LoadSwitch starts in OFF state"""
1918 turn_off (fprime_test_api )
2019 yield
2120 turn_off (fprime_test_api )
2221
22+
2323def turn_on (fprime_test_api : IntegrationTestAPI ):
2424 """Helper function to turn on the loadswitch"""
2525 proves_send_and_assert_command (
2626 fprime_test_api ,
2727 f"{ loadswitch } .TURN_ON" ,
2828 )
2929
30+
3031def turn_off (fprime_test_api : IntegrationTestAPI ):
3132 """Helper function to turn off the loadswitch"""
32- proves_send_and_assert_command (
33- fprime_test_api ,
34- f"{ loadswitch } .TURN_OFF"
35- )
33+ proves_send_and_assert_command (fprime_test_api , f"{ loadswitch } .TURN_OFF" )
34+
3635
3736def get_is_on (fprime_test_api : IntegrationTestAPI ) -> int :
3837 """Helper function to request packet and get fresh IsOn telemetry"""
@@ -46,11 +45,13 @@ def get_is_on(fprime_test_api: IntegrationTestAPI) -> int:
4645 )
4746 return result .get_val ()
4847
48+
4949def test_01_loadswitch_telemetry_basic (fprime_test_api : IntegrationTestAPI , start_gds ):
5050 """Test that we can read IsOn telemetry"""
5151 value = get_is_on (fprime_test_api )
5252 assert value in (0 , 1 ), f"IsOn should be 0 or 1, got { value } "
5353
54+
5455def test_02_turn_on_sets_high (fprime_test_api : IntegrationTestAPI , start_gds ):
5556 """
5657 Test TURN_ON command sets GPIO high, emits ON event, and updates telemetry
@@ -66,6 +67,7 @@ def test_02_turn_on_sets_high(fprime_test_api: IntegrationTestAPI, start_gds):
6667 value = get_is_on (fprime_test_api )
6768 assert value == 1 , f"Expected IsOn = 1 after TURN_ON, got { value } "
6869
70+
6971def test_03_turn_off_sets_low (fprime_test_api : IntegrationTestAPI , start_gds ):
7072 """
7173 Test TURN_OFF command sets GPIO low, emits OFF event, and updates telemetry
@@ -79,4 +81,4 @@ def test_03_turn_off_sets_low(fprime_test_api: IntegrationTestAPI, start_gds):
7981
8082 # Confirm telemetry IsOn is 0
8183 value = get_is_on (fprime_test_api )
82- assert value == 0 , f"Expected IsOn = 0 after TURN_OFF, got { value } "
84+ assert value == 0 , f"Expected IsOn = 0 after TURN_OFF, got { value } "
0 commit comments