9201ef759e
CI / lint (push) Waiting to run
CI / mypy (push) Waiting to run
CI / docs (push) Waiting to run
CI / test on 3.10 (standard) (push) Waiting to run
CI / test on 3.11 (standard) (push) Waiting to run
CI / test on 3.12 (standard) (push) Waiting to run
CI / test on 3.10 (all-extras) (push) Waiting to run
CI / test on 3.11 (all-extras) (push) Waiting to run
CI / test on 3.12 (all-extras) (push) Waiting to run
CI / test on 3.13 (all-extras) (push) Waiting to run
CI / test on 3.14 (pydantic-evals) (push) Waiting to run
Harness Compat / harness compat (push) Waiting to run
CI / test on 3.13 (standard) (push) Waiting to run
CI / test on 3.14 (standard) (push) Waiting to run
CI / test on 3.14 (all-extras) (push) Waiting to run
CI / test on 3.10 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.11 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.12 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.13 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.14 (pydantic-ai-slim) (push) Waiting to run
CI / test on 3.10 (pydantic-evals) (push) Waiting to run
CI / test on 3.11 (pydantic-evals) (push) Waiting to run
CI / test on 3.12 (pydantic-evals) (push) Waiting to run
CI / test on 3.13 (pydantic-evals) (push) Waiting to run
CI / test on 3.10 (lowest-versions) (push) Waiting to run
CI / test on 3.11 (lowest-versions) (push) Waiting to run
CI / test on 3.12 (lowest-versions) (push) Waiting to run
CI / test on 3.13 (lowest-versions) (push) Waiting to run
CI / test on 3.14 (lowest-versions) (push) Waiting to run
CI / test examples on 3.11 (push) Waiting to run
CI / test examples on 3.12 (push) Waiting to run
CI / test examples on 3.13 (push) Waiting to run
CI / test examples on 3.14 (push) Waiting to run
CI / coverage (push) Blocked by required conditions
CI / check (push) Blocked by required conditions
CI / deploy-docs (push) Blocked by required conditions
CI / deploy-docs-preview (push) Blocked by required conditions
CI / build release artifacts (push) Blocked by required conditions
CI / publish to PyPI (push) Blocked by required conditions
CI / Send tweet (push) Blocked by required conditions
58 lines
2.4 KiB
Python
58 lines
2.4 KiB
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Callable
|
|
|
|
import pytest
|
|
from vcr.cassette import Cassette
|
|
from vcr.record_mode import RecordMode
|
|
from vcr.request import Request
|
|
|
|
from .conftest import check_vcr_cassette_usage, pytest_recording_configure
|
|
|
|
|
|
class RecordingVCR:
|
|
before_record_request: Callable[[Request], Request | None] | None = None
|
|
|
|
def register_serializer(self, name: str, serializer: object) -> None:
|
|
pass
|
|
|
|
def register_matcher(self, name: str, matcher: Callable[[Request, Request], None]) -> None:
|
|
pass
|
|
|
|
|
|
def test_pytest_recording_configure_drops_google_oauth_token_requests() -> None:
|
|
vcr = RecordingVCR()
|
|
pytest_recording_configure(None, vcr) # pyright: ignore[reportArgumentType]
|
|
|
|
before_record_request = vcr.before_record_request
|
|
assert before_record_request is not None
|
|
request = Request('POST', 'https://oauth2.googleapis.com/token', None, dict[str, str]())
|
|
|
|
assert before_record_request(request) is None
|
|
|
|
|
|
def test_check_vcr_cassette_usage_allows_loaded_unused_cassette_by_default() -> None:
|
|
cassette = Cassette('fake.yaml', record_mode=RecordMode.NONE)
|
|
|
|
check_vcr_cassette_usage(cassette, strict_usage=False)
|
|
|
|
|
|
def test_check_vcr_cassette_usage_reports_unused_interactions() -> None:
|
|
cassette = Cassette('fake.yaml', record_mode=RecordMode.NONE)
|
|
cassette.append(Request('POST', 'https://example.com/one', b'{}', dict[str, str]()), {}) # pyright: ignore[reportUnknownMemberType]
|
|
cassette.append(Request('POST', 'https://example.com/two', b'{}', dict[str, str]()), {}) # pyright: ignore[reportUnknownMemberType]
|
|
cassette.play_counts[0] = 1 # pyright: ignore[reportUnknownMemberType]
|
|
|
|
with pytest.raises(pytest.fail.Exception, match=r'played 1/2; unused indexes: \[1\]'):
|
|
check_vcr_cassette_usage(cassette, strict_usage=False)
|
|
|
|
|
|
def test_check_vcr_cassette_usage_allows_fully_used_cassette() -> None:
|
|
cassette = Cassette('fake.yaml', record_mode=RecordMode.NONE)
|
|
cassette.append(Request('POST', 'https://example.com/one', b'{}', dict[str, str]()), {}) # pyright: ignore[reportUnknownMemberType]
|
|
cassette.append(Request('POST', 'https://example.com/two', b'{}', dict[str, str]()), {}) # pyright: ignore[reportUnknownMemberType]
|
|
cassette.play_counts[0] = 1 # pyright: ignore[reportUnknownMemberType]
|
|
cassette.play_counts[1] = 1 # pyright: ignore[reportUnknownMemberType]
|
|
|
|
check_vcr_cassette_usage(cassette, strict_usage=False)
|