Open
Conversation
Add get_task_status(task_id) to both ERClient (sync) and AsyncERClient
(async) for polling the status of background tasks.
Endpoint: core/taskstatus/{task_id}/
Returns a dict with:
- task_id: the task identifier
- status: PENDING | STARTED | SUCCESS | FAILURE
- result: task result data (null while pending/started)
- location: relative URL to the status endpoint
This enables clients to track the progress of async operations like
GPX uploads and data exports.
Includes 12 new tests across sync and async test suites covering
all task states, URL construction, and error handling.
Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # tests/sync_client/conftest.py
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a get_task_status convenience API to both sync and async EarthRanger clients, along with new tests to validate status parsing, error handling, and URL construction.
Changes:
- Add
get_task_status(task_id)toERClientandAsyncERClient. - Add sync tests covering PENDING/SUCCESS/FAILURE/STARTED, 404 handling, and URL construction.
- Add async tests covering the same scenarios using
respx/httpx.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
erclient/client.py |
Introduces get_task_status on both sync and async clients, delegating to existing _get logic. |
tests/sync_client/test_task_status.py |
New sync unit tests using unittest.mock to validate request URL and returned data payload behavior. |
tests/async_client/test_task_status.py |
New async unit tests using respx to validate request URL, response parsing, and NOT_FOUND error mapping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| @@ -0,0 +1,123 @@ | |||
| """Tests for get_task_status in the sync ERClient.""" | |||
| import json | |||
| from unittest.mock import patch, MagicMock | |||
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
Adds
get_task_status(task_id)to bothERClient(sync) andAsyncERClient(async) for polling background task status.core/taskstatus/{task_id}/(GET)task_id,status(PENDING/STARTED/SUCCESS/FAILURE),result, andlocationTest plan
tests/sync_client/test_task_status.pytests/async_client/test_task_status.pyRelated