Skip to content

Commit 6112503

Browse files
committed
Add typehinting
1 parent b21ace8 commit 6112503

File tree

3 files changed

+35
-23
lines changed

3 files changed

+35
-23
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ repos:
2424
- id: cpplint
2525
args:
2626
- --config=cpplint.cfg
27+
28+
- repo: https://github.com/astral-sh/ruff-pre-commit
29+
rev: v0.13.2
30+
hooks:
31+
- id: ruff-check
32+
args: [--fix]
33+
- id: ruff-check
34+
args: [--fix, --select, I] # import sorting
35+
- id: ruff-format

FprimeZephyrReference/Components/Watchdog/docs/sdd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Requirement | Description | Verification Method | Verified?
1212
----------- | ----------- | ------------------- | ---------
1313
WD-001 | The `Components::Watchdog` component shall activate upon startup. | Inspection | Yes
1414
WD-002 | The `Components::Watchdog` component shall oscillate the watchdog GPIO pin (24) on/off on each rategroup tick. | Inspection | Yes
15-
WD-003 | The `Components::Watchdog` component shall provide telemetry for watchdog transition count. | Integration Test | In Progress
15+
WD-003 | The `Components::Watchdog` component shall provide telemetry for watchdog transition count. | Integration Test | Yes
1616
WD-004 | The `Components::Watchdog` component shall respond to stop signals to halt the watchdog. | Integration Test | Yes
1717
WD-005 | The `Components::Watchdog` component shall provide a test command to stop the watchdog. | Integration Test | Yes
1818
WD-006 | The `Components::Watchdog` component shall emit an event when the watchdog stops. | Integration Test | Yes

FprimeZephyrReference/test/int/watchdog_test.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,55 +6,61 @@
66
"""
77

88
import time
9+
910
import 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

Comments
 (0)