Skip to content

Commit 287b4e6

Browse files
authored
tests: drop commonly modified headers from VCR (#2583)
1 parent 908c0e6 commit 287b4e6

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

tests/models/cassettes/test_model_names/test_known_model_names.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ interactions:
44
headers:
55
accept:
66
- '*/*'
7-
accept-encoding:
8-
- gzip, deflate
97
connection:
108
- keep-alive
119
host:
@@ -14,8 +12,6 @@ interactions:
1412
uri: https://us.inference.heroku.com/available-models
1513
response:
1614
headers:
17-
cache-control:
18-
- no-cache, no-store, must-revalidate
1915
connection:
2016
- keep-alive
2117
content-length:

tests/models/test_model_names.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
from collections.abc import Iterator
3+
from functools import partial
34
from typing import Any
45

56
import httpx
@@ -28,10 +29,22 @@
2829
]
2930

3031

32+
def modify_response(response: dict[str, Any], filter_headers: list[str]) -> dict[str, Any]: # pragma: lax no cover
33+
for header in response['headers'].copy():
34+
assert isinstance(header, str)
35+
if header.lower() in filter_headers:
36+
del response['headers'][header]
37+
return response
38+
39+
3140
@pytest.fixture(scope='module')
3241
def vcr_config(): # pragma: lax no cover
3342
if not os.getenv('CI'):
34-
return {'record_mode': 'rewrite'}
43+
return {
44+
'record_mode': 'rewrite',
45+
'filter_headers': ['accept-encoding'],
46+
'before_record_response': partial(modify_response, filter_headers=['cache-control']),
47+
}
3548
return {'record_mode': 'none'}
3649

3750

0 commit comments

Comments
 (0)