Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rewrite test casettes due to vcrpy update #290

Merged
merged 1 commit into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def _filter_response_headers(response):
"match_on": ["method", "path", "query", "body"],
"before_record_request": _compose_vcr_transformers([_anonymize_host, _normalize_multipart_boundary_hash]),
"before_record_response": _compose_vcr_transformers([_filter_response_headers]),
"decode_compressed_response": True,
"ignore_hosts": [
"huggingface.co", # requests cannot be captured because they are influenced by the operating system
],
Expand Down
6 changes: 3 additions & 3 deletions tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ def parse_vcr_response_body(response: dict[str, Any]) -> Iterator[dict[str, Any]
headers = response["headers"]
content_type = headers.get("Content-Type", headers.get("content-type"))[0]
if content_type.startswith("application/json"):
yield json.loads(response["content"])
yield json.loads(response["body"]["string"])
elif content_type.startswith("text/event-stream"):
httpx_response = Response(
content=response["content"],
content=response["body"]["string"],
headers={header: value[0] for header, value in response["headers"].items()},
status_code=response["status_code"],
status_code=response["status"]["code"],
)
for event in EventSource(httpx_response).iter_sse():
if event.data:
Expand Down
Loading