11"""
2- watchdog_test .py:
2+ rtc_test .py:
33
4- Simple integration tests for the Watchdog component.
4+ Simple integration tests for the RTC Manager component.
55Tests are ordered so that stop tests run last.
66"""
77
8+ import json
89import time
9- import pytest
1010from datetime import datetime , timezone
11- import json
11+ from typing import Any
12+
13+ import pytest
14+ from fprime_gds .common .data_types .ch_data import ChData
15+ from fprime_gds .common .data_types .event_data import EventData
16+ from fprime_gds .common .testing_fw .api import IntegrationTestAPI
17+
1218
1319@pytest .fixture (autouse = True )
14- def set_now_time (fprime_test_api ):
20+ def set_now_time (fprime_test_api : IntegrationTestAPI ):
1521 """Fixture to set the time to test runner's time before and after each test"""
1622 set_time (fprime_test_api )
1723 yield
1824 set_time (fprime_test_api )
1925
20- def set_time (fprime_test_api , dt : datetime = None ):
26+
27+ def set_time (fprime_test_api : IntegrationTestAPI , dt : datetime = None ):
2128 """Helper function to set the time to now or to a specified datetime"""
2229 if dt is None :
2330 dt = datetime .now (timezone .utc )
@@ -36,27 +43,25 @@ def set_time(fprime_test_api, dt: datetime = None):
3643 [
3744 time_data_str ,
3845 ],
39- max_delay = 2
40- )
41- fprime_test_api .assert_event (
42- "ReferenceDeployment.rv3028Manager.TimeSet" ,
43- timeout = 2
46+ max_delay = 2 ,
4447 )
48+ fprime_test_api .assert_event ("ReferenceDeployment.rv3028Manager.TimeSet" , timeout = 2 )
49+
4550
46- def get_time (fprime_test_api ) :
51+ def get_time (fprime_test_api : IntegrationTestAPI ) -> dict [ str , Any ] :
4752 """Helper function to request packet and get fresh WatchdogTransitions telemetry"""
4853 fprime_test_api .clear_histories ()
49- fprime_test_api .send_and_assert_command ("ReferenceDeployment.rtcManager.GET_TIME" , max_delay = 2 )
50- result = fprime_test_api .assert_event (
51- "ReferenceDeployment.rtcManager.GetTime" ,
52- timeout = 2
54+ fprime_test_api .send_and_assert_command (
55+ "ReferenceDeployment.rtcManager.GET_TIME" , max_delay = 2
56+ )
57+ result : EventData = fprime_test_api .assert_event (
58+ "ReferenceDeployment.rtcManager.GetTime" , timeout = 2
5359 )
5460
55- # EventData get_dict() https://github.com/nasa/fprime-gds/blob/67d0ec62f829ed23d72776f1d323f71eaafd31cc/src/fprime_gds/common/data_types/event_data.py#L130C9-L130C17
5661 return result .get_dict ()
5762
5863
59- def test_01_current_time_set (fprime_test_api ):
64+ def test_01_current_time_set (fprime_test_api : IntegrationTestAPI ):
6065 """Test that we can read WatchdogTransitions telemetry"""
6166 event_data = get_time (fprime_test_api )
6267 event_display_text_time = datetime .fromisoformat (event_data ["display_text" ])
@@ -65,7 +70,7 @@ def test_01_current_time_set(fprime_test_api):
6570 pytest .approx (event_display_text_time , abs = 30 ) == datetime .now (timezone .utc )
6671
6772
68- def test_02_set_time_in_past (fprime_test_api ):
73+ def test_02_set_time_in_past (fprime_test_api : IntegrationTestAPI ):
6974 """Test that we can set the time to a past time"""
7075 curiosity_landing = datetime (2012 , 8 , 6 , 5 , 17 , 57 , tzinfo = timezone .utc )
7176 set_time (fprime_test_api , curiosity_landing )
@@ -77,7 +82,7 @@ def test_02_set_time_in_past(fprime_test_api):
7782 pytest .approx (event_display_text_time , abs = 30 ) == curiosity_landing
7883
7984
80- def test_03_time_incrementing (fprime_test_api ):
85+ def test_03_time_incrementing (fprime_test_api : IntegrationTestAPI ):
8186 """Test that time increments over time"""
8287 initial_event_data = get_time (fprime_test_api )
8388 initial_time = datetime .fromisoformat (initial_event_data ["display_text" ])
@@ -87,16 +92,16 @@ def test_03_time_incrementing(fprime_test_api):
8792 updated_event_data = get_time (fprime_test_api )
8893 updated_time = datetime .fromisoformat (updated_event_data ["display_text" ])
8994
90- assert updated_time > initial_time , \
95+ assert updated_time > initial_time , (
9196 f"Time should increase. Initial: { initial_time } , Updated: { updated_time } "
97+ )
9298
9399
94- def test_04_time_in_telemetry (fprime_test_api ):
100+ def test_04_time_in_telemetry (fprime_test_api : IntegrationTestAPI ):
95101 """Test that we can get Time telemetry"""
96102 # result in ChData object https://github.com/nasa/fprime-gds/blob/67d0ec62f829ed23d72776f1d323f71eaafd31cc/src/fprime_gds/common/data_types/ch_data.py#L18
97- result = fprime_test_api .assert_telemetry (
98- "CdhCore.cmdDisp.CommandsDispatched" ,
99- timeout = 3
103+ result : ChData = fprime_test_api .assert_telemetry (
104+ "CdhCore.cmdDisp.CommandsDispatched" , timeout = 3
100105 )
101106
102107 # result.time is TimeType object https://github.com/nasa/fprime-tools/blob/aaa5840181146ca38b195c2a4d3f1bcbb35234c1/src/fprime/common/models/serialize/time_type.py#L49
0 commit comments