test(streaming): add empty-monitors edge case for stream_alerts#42
Draft
KhaledSalhab-Develeap wants to merge 4 commits into
Draft
test(streaming): add empty-monitors edge case for stream_alerts#42KhaledSalhab-Develeap wants to merge 4 commits into
KhaledSalhab-Develeap wants to merge 4 commits into
Conversation
…470) Guard the path where stream_alerts receives an empty monitors list on first poll: verify nothing is yielded, asyncio.sleep is still called (the loop continues), and monitors appearing on the second poll set the baseline without triggering transition alerts.
3 tasks
Same as the parent async-streaming branch: _otel.py and test_otel.py require the PY-11 client wiring that is not present here, so they were dead code plus a failing standalone test. Remove them and the opentelemetry deps. OTel is delivered solely by the PY-11 PR.
Reconcile the divergent main-merge so this PR's diff against its parent shows only the empty-monitors stream_alerts test (the actual change), not the whole rebased delta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add three unit tests to
TestStreamAlertsintests/unit/test_streaming.pycovering the edge case wherestream_alerts()is called and the monitors list returned by the API is empty.What changed
tests/unit/test_streaming.py: three new tests added toTestStreamAlerts:test_stream_alerts_empty_monitors_yields_nothing-- empty list on the first poll yields no alertstest_stream_alerts_empty_monitors_sleep_still_called--asyncio.sleepis still invoked when monitors is empty (the loop does not exit early)test_stream_alerts_empty_then_monitors_appear_no_transition-- monitors present on the second poll after an empty first poll set the baseline without emitting a transition alert, because there is no prior state to diff againstWhy this shape
The three tests each pin a distinct observable behaviour of the empty path: no yield, no early exit, and correct baseline initialisation. Splitting them makes each failure message self-describing. No production code changes are required; the existing implementation already handles this path correctly.
Verification
pytest tests/unit/test_streaming.py --no-covAcceptance criteria
stream_alerts()with an empty monitors list correctly yields nothing