Skip to content

Commit b7287e4

Browse files
author
David Meadows
committed
fix(internal): update custom code related tests
1 parent 5aff0ca commit b7287e4

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

tests/api_resources/test_access_tokens.py

+30-1
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,44 @@
33
from __future__ import annotations
44

55
import os
6-
from typing import Any, cast
6+
from typing import TYPE_CHECKING, Any, Iterator, AsyncIterator, cast
77

88
import pytest
99

1010
from finch import Finch, AsyncFinch
1111
from finch.types import CreateAccessTokenResponse
1212
from tests.utils import assert_matches_type
1313

14+
if TYPE_CHECKING:
15+
from _pytest.fixtures import FixtureRequest
16+
1417
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
18+
client_id = "00000000-0000-0000-0000-000000000000"
19+
client_secret = "TEST"
20+
21+
22+
@pytest.fixture(scope="module")
23+
def client(request: FixtureRequest) -> Iterator[Finch]:
24+
strict = getattr(request, "param", True)
25+
if not isinstance(strict, bool):
26+
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
27+
28+
with Finch(
29+
base_url=base_url, client_id=client_id, client_secret=client_secret, _strict_response_validation=strict
30+
) as client:
31+
yield client
32+
33+
34+
@pytest.fixture(scope="module")
35+
async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncFinch]:
36+
strict = getattr(request, "param", True)
37+
if not isinstance(strict, bool):
38+
raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}")
39+
40+
async with AsyncFinch(
41+
base_url=base_url, client_id=client_id, client_secret=client_secret, _strict_response_validation=strict
42+
) as client:
43+
yield client
1544

1645

1746
class TestAccessTokens:

0 commit comments

Comments
 (0)