add async post_observation() to AsyncERClient#24
Open
JoshuaVulcan wants to merge 12 commits intomainfrom
Open
Conversation
Adds post_observation() to the async client, matching the sync ERClient's existing method. Supports single observations and lists, applies _clean_observation() to normalize recorded_at to ISO format. ERA-12672 Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds the post_observation() async method to AsyncERClient, bringing it to feature parity with the existing sync ERClient. The implementation correctly mirrors the sync version by handling both single observations and lists, applying datetime normalization through _clean_observation(), and posting to the observations endpoint.
Changes:
- Added
async def post_observation()method toAsyncERClientclass - Added comprehensive test suite with 7 tests covering success cases, datetime cleaning, and various error scenarios (timeout, 403, 404, 409)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| erclient/client.py | Added async post_observation() method that mirrors the sync version, handling single/list observations with datetime cleaning |
| tests/async_client/test_post_observation.py | New test file with 7 tests covering success, list handling, datetime conversion, and error scenarios |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Exercises the isinstance(observation, (list, set)) branch with a monkeypatched _clean_observation since dicts are unhashable and cannot be placed in a real set. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
…ervation tests Co-authored-by: Cursor <cursoragent@cursor.com>
Register observation route with full URL (service_root + '/observations') so respx matches the client request. urljoin(base_url, 'observations') yields .../api/observations, which did not match .../api/v1.0/observations. Co-authored-by: Cursor <cursoragent@cursor.com>
Omit base_url from respx.mock() and register the observations route with the full URL only. Avoids base_url merging that can prevent the route from matching the actual request in CI. Co-authored-by: Cursor <cursoragent@cursor.com>
… async tests Match test_post_sensor_observation pattern so respx route matches the request URL across Python 3.10-3.12. Remove unused re import. Co-authored-by: Cursor <cursoragent@cursor.com>
…ng slash) Co-authored-by: Cursor <cursoragent@cursor.com>
chrisdoehring
approved these changes
Mar 13, 2026
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.
Summary
post_observation()toAsyncERClient, matching the syncERClient's existing method_clean_observation()to normalizerecorded_atdatetime objects to ISO format stringsTest plan
uv run pytest-- all 97 tests pass (90 existing + 7 new)Resolves ERA-12672