ERA-12676: Add user management and EULA endpoints to both clients#35
Open
JoshuaVulcan wants to merge 5 commits intomainfrom
Open
ERA-12676: Add user management and EULA endpoints to both clients#35JoshuaVulcan wants to merge 5 commits intomainfrom
JoshuaVulcan wants to merge 5 commits intomainfrom
Conversation
ERA-12676: Adds accounts/user parity across both clients: ERClient (sync) and AsyncERClient (async): - get_users: List all users (async was missing) - get_user(id): Get single user by ID or 'me' - patch_user(id, data): Update user with partial data - get_user_profiles(id): Get user profiles - get_eula: Get active End-User License Agreement - accept_eula: Accept the active EULA Includes 24 tests (12 async + 12 sync) covering success, not-found, and forbidden scenarios for all new endpoints. Co-authored-by: Cursor <cursoragent@cursor.com>
# Conflicts: # tests/sync_client/conftest.py
Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds account/user-management and EULA endpoints to the EarthRanger Python clients (sync + async) to achieve feature parity and provide typed convenience wrappers around the underlying HTTP helpers.
Changes:
- Added user endpoints:
get_users(),get_user(user_id),patch_user(user_id, data),get_user_profiles(user_id)(sync + async parity). - Added EULA endpoints:
get_eula()andaccept_eula()(sync + async parity). - Added new sync/async test modules covering success and authorization/not-found error scenarios for the new endpoints.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
erclient/client.py |
Adds the new user/account + EULA convenience methods to ERClient and AsyncERClient. |
tests/sync_client/test_accounts.py |
New sync tests for the added endpoints using mocked session responses. |
tests/async_client/test_accounts.py |
New async tests for the added endpoints using respx route mocks. |
💡 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.
Comment on lines
+24
to
+29
| er_client._http_session.get = MagicMock( | ||
| return_value=_mock_response(200, {"data": expected}) | ||
| ) | ||
| result = er_client.get_users() | ||
| er_client._http_session.get.assert_called_once() | ||
| assert result == expected |
| updated = {**user_response, "first_name": "Updated"} | ||
| route.return_value = httpx.Response(httpx.codes.OK, json={"data": updated}) | ||
| result = await er_client.patch_user("c925e69e-51cf-43d0-b659-2000ae023664", {"first_name": "Updated"}) | ||
| assert route.called |
Comment on lines
+176
to
+182
| async def test_accept_eula(er_client, eula_accept_response): | ||
| async with respx.mock(base_url=er_client._api_root("v1.0"), assert_all_called=False) as m: | ||
| route = m.post("user/eula/accept") | ||
| route.return_value = httpx.Response(httpx.codes.CREATED, json={"data": eula_accept_response}) | ||
| result = await er_client.accept_eula() | ||
| assert route.called | ||
| assert result == eula_accept_response |
| response = MagicMock() | ||
| response.ok = 200 <= status_code < 400 | ||
| response.status_code = status_code | ||
| response.text = json.dumps(json_data) if json_data else "" |
| :param data: Partial user data (e.g., {"first_name": "New"}) | ||
| :return: Updated user data | ||
| """ | ||
| self.logger.debug(f'Patching user {user_id}: {data}') |
| :param data: Partial user data (e.g., {"first_name": "New"}) | ||
| :return: Updated user data | ||
| """ | ||
| self.logger.debug(f'Patching user {user_id}: {data}') |
Comment on lines
+9
to
+17
| def _mock_response(status_code=200, json_data=None): | ||
| """Helper to create a mock response object.""" | ||
| response = MagicMock() | ||
| response.ok = 200 <= status_code < 400 | ||
| response.status_code = status_code | ||
| response.text = json.dumps(json_data) if json_data else "" | ||
| response.json.return_value = json_data | ||
| response.url = "https://fake-site.erdomain.org/api/v1.0/test" | ||
| return response |
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
get_users()toAsyncERClient(sync already had it)get_user(id),patch_user(id, data)to bothERClientandAsyncERClientget_user_profiles(id)to both clientsget_eula()andaccept_eula()to both clientsTest plan
Resolves ERA-12676