🧪 test: add tests for parse_site_location edge cases#38
🧪 test: add tests for parse_site_location edge cases#38rnovatorov wants to merge 3 commits intomainfrom
Conversation
Added unit tests to `tests/unit/test_cli/test_http/test_api/test_site_location.py` to cover `parse_site_location`. The tests cover standard string format, string containing spaces, exceptions handling incorrect lengths (too few or too many parameters), incorrect coordinate formats (non-float characters), and empty strings. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
The `test_standalone/test_mqtt_adapter.py` test suite used `await asyncio.sleep(0.02)` to wait for mocked methods to be called before assertions. Under higher load, or in some configurations like Python 3.13, this constant delay was insufficient, causing intermittent failures such as `AssertionError: Expected 'publish_log' to have been called`. This replaces the arbitrary sleeps with deterministic synchronization primitives (`asyncio.Event`) where tests wait explicitly for up to 1 second for the mocked function to be called before checking assertions. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
The `test_standalone/test_mqtt_adapter.py` test suite used `await asyncio.sleep(0.02)` to wait for mocked methods to be called before assertions. Under higher load, or in some configurations like Python 3.13, this constant delay was insufficient, causing intermittent failures such as `AssertionError: Expected 'publish_log' to have been called`. This replaces the arbitrary sleeps with deterministic synchronization primitives (`asyncio.Event`) where tests wait explicitly for up to 1 second for the mocked function to be called before checking assertions. Also run `black` to format the new code modifications. Co-authored-by: rnovatorov <20299819+rnovatorov@users.noreply.github.com>
🎯 What: The testing gap for
parse_site_locationinsrc/enapter/cli/http/api/site_location.pyhas been addressed. The function parses site location coordinates strings and previously lacked unit test coverage.📊 Coverage: Test coverage has been added for valid locations, locations with extra spaces around names and values, as well as several exceptions: missing values, extra values, non-numeric latitude/longitude coordinates, and empty string handling.
✨ Result: Test coverage for
parse_site_locationis fully covered, preventing potential future regressions and making its behavior verifiable and reliable.PR created automatically by Jules for task 5468704340888702486 started by @rnovatorov