diff --git a/libs/partners/openai/tests/conftest.py b/libs/partners/openai/tests/conftest.py new file mode 100644 index 00000000000..575a647f359 --- /dev/null +++ b/libs/partners/openai/tests/conftest.py @@ -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 diff --git a/libs/standard-tests/langchain_tests/conftest.py b/libs/standard-tests/langchain_tests/conftest.py new file mode 100644 index 00000000000..f1429e77af5 --- /dev/null +++ b/libs/standard-tests/langchain_tests/conftest.py @@ -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