add conftests

This commit is contained in:
Chester Curme 2025-05-19 15:57:26 -04:00
parent f504062687
commit bd4a96dc50
2 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,24 @@
import pytest
from langchain_tests.conftest import _base_vcr_config
_EXTRA_HEADERS = [
("openai-organization", "PLACEHOLDER"),
("x-openai-client-user-agent", "PLACEHOLDER"),
]
def remove_response_headers(response):
response["headers"] = {}
return response
@pytest.fixture(scope="session")
def vcr_config(_base_vcr_config: dict) -> dict:
"""
Extend the default configuration coming from langchain_tests.
"""
config = _base_vcr_config.copy()
config.setdefault("filter_headers", []).extend(_EXTRA_HEADERS)
config["before_record_response"] = remove_response_headers
return config

View File

@ -0,0 +1,25 @@
import pytest
_BASE_FILTER_HEADERS = [
("authorization", "PLACEHOLDER"),
("x-api-key", "PLACEHOLDER"),
]
@pytest.fixture(scope="session")
def _base_vcr_config() -> dict:
"""
Configuration that every cassette will receive.
(Anything permitted by vcr.VCR(**kwargs) can be put here.)
"""
return {
"record_mode": "once",
"filter_headers": _BASE_FILTER_HEADERS.copy(),
"match_on": ["method", "scheme", "host", "port", "path", "query"],
"decode_compressed_response": True,
}
@pytest.fixture(scope="session")
def vcr_config(_base_vcr_config: dict) -> dict:
return _base_vcr_config