Skip to content

Rtc test fix#407

Open
collinc04 wants to merge 7 commits into
mainfrom
RTC_test_fix
Open

Rtc test fix#407
collinc04 wants to merge 7 commits into
mainfrom
RTC_test_fix

Conversation

@collinc04
Copy link
Copy Markdown
Contributor

Functionality remains the same but it looks like it is more common convention to use assert instead

Pull Request Title (e.g., Feature: Add user authentication)

Description

Related Issues/Tickets

How Has This Been Tested?

  • Unit tests
  • Integration tests
  • Z Tests
  • Manual testing (describe steps)

Screenshots / Recordings (if applicable)

Checklist

  • Written detailed sdd with requirements, channels, ports, commands, telemetry defined and correctly formatted and spelled
  • Have written relevant integration tests and have documented them in the sdd
  • Have done a code review with
  • Have tested this PR on every supported board with correct board definitions

Further Notes / Considerations

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 25, 2026

Review Change Stack

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

💤 Files selected but had no reviewable changes (1)
  • PROVESFlightControllerReference/test/int/z-tmp112_test.py
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 60adf8bc-2275-458d-a284-2f38532904c4

📥 Commits

Reviewing files that changed from the base of the PR and between 51904cf and 435ce42.

📒 Files selected for processing (1)
  • PROVESFlightControllerReference/test/int/z-tmp112_test.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

RTC integration tests switch alarm event checks from await_event(..., timeout=10) to fprime_test_api.assert_event(..., start="NOW", timeout=10) and adjust double-set alarm scheduling times; the Zephyr workspace subproject pointer is advanced to a new commit.

Changes

RTC Test Event Assertion Migration

Layer / File(s) Summary
Replace await_event with assert_event (start=NOW)
PROVESFlightControllerReference/test/int/rtc_test.py
Alarm trigger, cancellation, cancellation-without-alarm, and alarm list test validations now call fprime_test_api.assert_event(..., start="NOW", timeout=10) instead of await_event(..., timeout=10).
Adjust alarm timing for double-set tests
PROVESFlightControllerReference/test/int/rtc_test.py
"Set in the past" and "double-set" tests use assert_event(start="NOW", timeout=10) and the double-set initial/re-set times are changed to ~60 seconds in the future.

Zephyr Subproject Pointer Update

Layer / File(s) Summary
Advance Zephyr workspace subproject
lib/zephyr-workspace/zephyr
Subproject pointer advanced from commit 3568e1b to 684c9e8.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

  • #401: Implements replacing await_event with assert_event (start="NOW") in the rtc_test alarm suite.

Poem

🐰
I hopped through tests at break of day,
Replaced waits with "NOW" to speed the play,
Alarms set far, then set again,
Zephyr's pointer sailed upstream again,
Hooray — the test burrow's bright and gay!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete with only a brief sentence about the changes and an unfilled template; critical sections like Related Issues, testing details, and checklist items are missing or unchecked. Complete the description by filling in Related Issues/Tickets, documenting how tests were verified, and checking relevant checklist items. Provide specific details about the alarm test changes.
Title check ❓ Inconclusive The title 'Rtc test fix' is vague and generic, using non-descriptive terminology that doesn't convey the specific nature of the changes. Improve the title to be more specific, such as 'Update RTC alarm tests to use assert_event with start=NOW' or 'Migrate RTC tests from await_event to assert_event.'
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PROVESFlightControllerReference/test/int/rtc_test.py`:
- Around line 309-311: The test test_06_rtc_alarm_cancellation is asserting that
f"{rtcManager}.AlarmTriggered" is emitted after canceling an alarm, which
contradicts the test purpose; update the assertion logic in
test_06_rtc_alarm_cancellation so that after calling the cancel flow you either
assert an AlarmCanceled (or equivalent) event from f"{rtcManager}" if such an
event exists, or assert that f"{rtcManager}.AlarmTriggered" is NOT emitted (use
the framework's "not emitted"/absence check with an appropriate timeout), or
alternatively query the ALARM_LIST (as done earlier near line ~283) to verify
the alarm is removed. Ensure references to rtcManager, AlarmTriggered,
AlarmCanceled (if present), and ALARM_LIST in the test are used to locate and
implement the correct check.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: d079521f-fc18-4658-a63d-c8095bbf96f9

📥 Commits

Reviewing files that changed from the base of the PR and between 9bb0602 and 94a06e5.

📒 Files selected for processing (2)
  • PROVESFlightControllerReference/test/int/rtc_test.py
  • lib/zephyr-workspace/zephyr

Comment on lines +309 to +311
fprime_test_api.assert_event(
f"{rtcManager}.AlarmTriggered", start="NOW", timeout=10
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Test logic contradicts its purpose.

The test test_06_rtc_alarm_cancellation has a docstring stating "Test that we can cancel an RTC alarm and that it does not trigger", but the assertion checks that AlarmTriggered event is emitted after canceling the alarm. This is logically inconsistent.

After canceling an alarm, the test should either:

  1. Assert that an AlarmCanceled or similar confirmation event is emitted (if one exists)
  2. Verify the alarm does NOT trigger by checking that AlarmTriggered is not emitted
  3. Verify the alarm is no longer set using ALARM_LIST (similar to line 283)
🔍 Suggested fix - verify alarm does not trigger
 # Cancel the alarm immediately
 fprime_test_api.send_command(f"{rtcManager}.ALARM_CANCEL")
 
-fprime_test_api.assert_event(
-    f"{rtcManager}.AlarmTriggered", start="NOW", timeout=10
-)
+# Verify the alarm is no longer set
+fprime_test_api.send_command(f"{rtcManager}.ALARM_LIST")
+fprime_test_api.assert_event(f"{rtcManager}.AlarmNotSet", start="NOW", timeout=10)

Alternatively, if there's an AlarmCanceled event, assert that instead.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/test/int/rtc_test.py` around lines 309 - 311,
The test test_06_rtc_alarm_cancellation is asserting that
f"{rtcManager}.AlarmTriggered" is emitted after canceling an alarm, which
contradicts the test purpose; update the assertion logic in
test_06_rtc_alarm_cancellation so that after calling the cancel flow you either
assert an AlarmCanceled (or equivalent) event from f"{rtcManager}" if such an
event exists, or assert that f"{rtcManager}.AlarmTriggered" is NOT emitted (use
the framework's "not emitted"/absence check with an appropriate timeout), or
alternatively query the ALARM_LIST (as done earlier near line ~283) to verify
the alarm is removed. Ensure references to rtcManager, AlarmTriggered,
AlarmCanceled (if present), and ALARM_LIST in the test are used to locate and
implement the correct check.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
PROVESFlightControllerReference/test/int/rtc_test.py (1)

327-329: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Test logic still contradicts its purpose.

The test cancels an alarm but then asserts that AlarmTriggered is emitted, which contradicts the docstring "that it does not trigger". As noted in the previous review, after canceling you should assert AlarmCanceled or verify AlarmTriggered is not emitted.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/test/int/rtc_test.py` around lines 327 - 329,
The test currently cancels an alarm but then asserts that
f"{rtcManager}.AlarmTriggered" is emitted, which contradicts the docstring;
update the assertion after the cancel operation to either assert that
f"{rtcManager}.AlarmCanceled" is emitted (use fprime_test_api.assert_event with
that event name and suitable start/timeout) or verify that
f"{rtcManager}.AlarmTriggered" is NOT emitted (use the test API's non-emission
check or invert the assert_event call) so the test verifies cancellation rather
than a trigger.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@PROVESFlightControllerReference/test/int/rtc_test.py`:
- Around line 425-432: Replace the dict(...) construction used to build
alarm_time_data with a dictionary literal for consistency and style: locate the
alarm_time_data assignment in rtc_test.py (variable name alarm_time_data) and
rewrite it using a brace-enclosed literal with the same keys (Year, Month, Day,
Hour, Minute, Second) and values (alarm_time.year, alarm_time.month, etc.),
preserving ordering and semantics.

---

Duplicate comments:
In `@PROVESFlightControllerReference/test/int/rtc_test.py`:
- Around line 327-329: The test currently cancels an alarm but then asserts that
f"{rtcManager}.AlarmTriggered" is emitted, which contradicts the docstring;
update the assertion after the cancel operation to either assert that
f"{rtcManager}.AlarmCanceled" is emitted (use fprime_test_api.assert_event with
that event name and suitable start/timeout) or verify that
f"{rtcManager}.AlarmTriggered" is NOT emitted (use the test API's non-emission
check or invert the assert_event call) so the test verifies cancellation rather
than a trigger.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 4d9460cb-603f-4f23-8e8c-e12f2d58d72f

📥 Commits

Reviewing files that changed from the base of the PR and between 94a06e5 and 51904cf.

📒 Files selected for processing (1)
  • PROVESFlightControllerReference/test/int/rtc_test.py

Comment on lines +425 to +432
alarm_time_data = dict(
Year=alarm_time.year,
Month=alarm_time.month,
Day=alarm_time.day,
Hour=alarm_time.hour,
Minute=alarm_time.minute,
Second=alarm_time.second,
)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider using dict literal for consistency.

Static analysis suggests replacing dict(...) with a dictionary literal {...} for consistency with Python conventions. This is a minor style improvement.

✨ Optional refactor to dict literal
-    alarm_time_data = dict(
-        Year=alarm_time.year,
-        Month=alarm_time.month,
-        Day=alarm_time.day,
-        Hour=alarm_time.hour,
-        Minute=alarm_time.minute,
-        Second=alarm_time.second,
-    )
+    alarm_time_data = {
+        "Year": alarm_time.year,
+        "Month": alarm_time.month,
+        "Day": alarm_time.day,
+        "Hour": alarm_time.hour,
+        "Minute": alarm_time.minute,
+        "Second": alarm_time.second,
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
alarm_time_data = dict(
Year=alarm_time.year,
Month=alarm_time.month,
Day=alarm_time.day,
Hour=alarm_time.hour,
Minute=alarm_time.minute,
Second=alarm_time.second,
)
alarm_time_data = {
"Year": alarm_time.year,
"Month": alarm_time.month,
"Day": alarm_time.day,
"Hour": alarm_time.hour,
"Minute": alarm_time.minute,
"Second": alarm_time.second,
}
🧰 Tools
🪛 Ruff (0.15.14)

[warning] 425-432: Unnecessary dict() call (rewrite as a literal)

Rewrite as a literal

(C408)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@PROVESFlightControllerReference/test/int/rtc_test.py` around lines 425 - 432,
Replace the dict(...) construction used to build alarm_time_data with a
dictionary literal for consistency and style: locate the alarm_time_data
assignment in rtc_test.py (variable name alarm_time_data) and rewrite it using a
brace-enclosed literal with the same keys (Year, Month, Day, Hour, Minute,
Second) and values (alarm_time.year, alarm_time.month, etc.), preserving
ordering and semantics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants