Skip to content

feat: add async get_events_export() to AsyncERClient (ERA-12670)#33

Open
JoshuaVulcan wants to merge 4 commits intomainfrom
ERA-12670/async-events-export
Open

feat: add async get_events_export() to AsyncERClient (ERA-12670)#33
JoshuaVulcan wants to merge 4 commits intomainfrom
ERA-12670/async-events-export

Conversation

@JoshuaVulcan
Copy link
Copy Markdown
Contributor

@JoshuaVulcan JoshuaVulcan commented Feb 11, 2026

Summary

  • Adds get_events_export(filter=None) to AsyncERClient, achieving parity with the existing sync method.
  • Introduces a private _get_raw() helper on AsyncERClient that returns the raw httpx.Response without JSON parsing, suitable for file-download endpoints (CSV export).
  • Adds comprehensive tests (18 new) for both sync and async get_events_export() covering success, filter forwarding, URL construction, content-type verification, and error handling (401/403/404/500).

Details

The das activity/events/export endpoint returns a CSV file. The sync client already supports this via return_response=True in its _get(). The async _call() always parses JSON, so a new _get_raw() method was needed to bypass that while preserving the standard error-handling pipeline (_handle_http_status_error).

Changes

  • erclient/client.py — added _get_raw() and get_events_export() to AsyncERClient
  • tests/async_client/test_get_events_export.py — 9 async tests
  • tests/sync_client/test_get_events_export.py — 9 sync tests (new coverage for the pre-existing sync method)
  • tests/sync_client/conftest.py — sync test fixtures

Test plan

  • All 108 tests pass (python3 -m pytest -v)
  • Async: success, filter param, no-filter, CSV content-type, 401, 403, 404, 500
  • Sync: success, filter param, no-filter, URL construction, 401, 403, 404, 500, empty CSV

Jira: ERA-12670

Add get_events_export(filter=None) to AsyncERClient for parity with the
existing sync method.  Because the endpoint returns a CSV file rather
than JSON, a new _get_raw() helper is introduced that returns the raw
httpx.Response without attempting JSON parsing while preserving the
standard error-handling pipeline.

Also adds comprehensive tests for both the sync and async
get_events_export() methods covering success, filter forwarding, URL
construction, and error cases (401, 403, 404, 500).

Co-authored-by: Cursor <cursoragent@cursor.com>
@JoshuaVulcan JoshuaVulcan added autoreviewing PR is currently being auto-reviewed and removed autoreviewing PR is currently being auto-reviewed labels Feb 11, 2026
JoshuaVulcan added a commit that referenced this pull request Feb 11, 2026
Use _get_raw (from PR #33) for raw GET responses instead of adding
_get_response; rebased onto ERA-12670/async-events-export.

Co-authored-by: Cursor <cursoragent@cursor.com>
JoshuaVulcan and others added 2 commits February 11, 2026 10:57
# Conflicts:
#	tests/sync_client/conftest.py
… main async helpers; fix events export test URLs

Co-authored-by: Cursor <cursoragent@cursor.com>
@JoshuaVulcan JoshuaVulcan requested a review from a team as a code owner February 12, 2026 01:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds get_events_export(filter=None) to AsyncERClient to achieve parity with the existing sync method. The endpoint returns CSV data, so a new _get_raw() helper method is introduced to bypass JSON parsing while maintaining consistent error handling. The PR also refactors the async _delete method to delegate to _call instead of having its own inline implementation, and adds comprehensive tests for both sync and async versions.

Changes:

  • Added _get_raw() and get_events_export() methods to AsyncERClient, and refactored _delete to delegate to _call
  • Added 9 async tests covering success, filter forwarding, content-type, and error cases (401/403/404/500)
  • Added 9 sync tests for the pre-existing get_events_export() method

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
erclient/client.py Added get_events_export() and _get_raw() to AsyncERClient; refactored _delete to delegate to _call
tests/async_client/test_get_events_export.py New async test file with 9 tests for the export endpoint
tests/sync_client/test_get_events_export.py New sync test file with 9 tests for the existing export method

💡 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 +1690 to +1701
self.logger.error(
'Request to ER failed',
extra=dict(
provider_key=self.provider_key,
service=self.service_root,
path=path,
status_code=None,
reason=reason,
text="",
),
)
raise ERClientException(f'Request to ER failed: {reason}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants