Skip to content

Commit

Permalink
fix: rewrite test casettes due to vcrpy update (#290)
Browse files Browse the repository at this point in the history
Signed-off-by: Radek Ježek <[email protected]>
  • Loading branch information
jezekra1 authored Jan 25, 2024
1 parent c4d6f74 commit e120414
Show file tree
Hide file tree
Showing 36 changed files with 16,569 additions and 16,691 deletions.
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

0 comments on commit e120414

Please sign in to comment.