Conversation
…timestamp formatting and add regression tests for format_date_iso function Events have wrong time in HA Fixes #1587
📝 WalkthroughWalkthroughThis pull request refactors timestamp formatting by extracting the local Changes
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/server/test_datetime_utils.py (1)
150-155: Consider adding a test for malformed input strings.The
format_date_iso()function has a fallback that returnsstr(date_val)on parse exceptions. Adding a test to verify this behavior would improve coverage:Optional test case
def test_malformed_input_returns_original_string(self): """Malformed date strings should fall back to returning the original value.""" result = format_date_iso("not-a-date") assert result == "not-a-date"🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@test/server/test_datetime_utils.py` around lines 150 - 155, Add a test that verifies format_date_iso's fallback behavior for malformed input: create a new test (e.g., test_malformed_input_returns_original_string) alongside test_output_is_valid_iso8601 that calls format_date_iso("not-a-date") and asserts the result equals the original string; reference the format_date_iso function to ensure the test covers the parse-exception branch that returns str(date_val).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@test/server/test_datetime_utils.py`:
- Around line 150-155: Add a test that verifies format_date_iso's fallback
behavior for malformed input: create a new test (e.g.,
test_malformed_input_returns_original_string) alongside
test_output_is_valid_iso8601 that calls format_date_iso("not-a-date") and
asserts the result equals the original string; reference the format_date_iso
function to ensure the test covers the parse-exception branch that returns
str(date_val).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0914d912-0c27-43ab-856a-e86b151e6c36
📒 Files selected for processing (2)
front/plugins/_publisher_mqtt/mqtt.pytest/server/test_datetime_utils.py
Summary by CodeRabbit
Bug Fixes
Tests