-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_request_forwarding.py
70 lines (57 loc) · 2.75 KB
/
test_request_forwarding.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File generated from our OpenAPI spec by Stainless.
from __future__ import annotations
import os
import pytest
from finch import Finch, AsyncFinch
from finch.types import RequestForwardingForwardResponse
from tests.utils import assert_matches_type
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
access_token = os.environ.get("API_KEY", "something1234")
class TestRequestForwarding:
strict_client = Finch(base_url=base_url, access_token=access_token, _strict_response_validation=True)
loose_client = Finch(base_url=base_url, access_token=access_token, _strict_response_validation=False)
parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
@parametrize
def test_method_forward(self, client: Finch) -> None:
request_forwarding = client.request_forwarding.forward(
method="POST",
route="/people/search",
)
assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"])
@parametrize
def test_method_forward_with_all_params(self, client: Finch) -> None:
request_forwarding = client.request_forwarding.forward(
method="POST",
route="/people/search",
data=None,
headers={"content-type": "application/json"},
params={
"showInactive": True,
"humanReadable": True,
},
)
assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"])
class TestAsyncRequestForwarding:
strict_client = AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=True)
loose_client = AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=False)
parametrize = pytest.mark.parametrize("client", [strict_client, loose_client], ids=["strict", "loose"])
@parametrize
async def test_method_forward(self, client: AsyncFinch) -> None:
request_forwarding = await client.request_forwarding.forward(
method="POST",
route="/people/search",
)
assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"])
@parametrize
async def test_method_forward_with_all_params(self, client: AsyncFinch) -> None:
request_forwarding = await client.request_forwarding.forward(
method="POST",
route="/people/search",
data=None,
headers={"content-type": "application/json"},
params={
"showInactive": True,
"humanReadable": True,
},
)
assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"])