Skip to content

chore(internal): share client instances between all tests #271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 38 additions & 44 deletions tests/api_resources/hris/benefits/test_individuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

from finch import Finch, AsyncFinch
from tests.utils import assert_matches_type
from finch._client import Finch, AsyncFinch
from finch.pagination import SyncSinglePage, AsyncSinglePage
from finch.types.hris.benefits import (
IndividualBenefit,
Expand All @@ -19,13 +18,10 @@
)

base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
access_token = "My Access Token"


class TestIndividuals:
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 = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
def test_method_enroll_many(self, client: Finch) -> None:
Expand Down Expand Up @@ -201,21 +197,19 @@ def test_path_params_unenroll_many(self, client: Finch) -> None:


class TestAsyncIndividuals:
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 = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"])

@parametrize
async def test_method_enroll_many(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.enroll_many(
async def test_method_enroll_many(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.enroll_many(
"string",
individuals=[{}],
)
assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
async def test_raw_response_enroll_many(self, client: AsyncFinch) -> None:
response = await client.hris.benefits.individuals.with_raw_response.enroll_many(
async def test_raw_response_enroll_many(self, async_client: AsyncFinch) -> None:
response = await async_client.hris.benefits.individuals.with_raw_response.enroll_many(
"string",
individuals=[{}],
)
Expand All @@ -226,8 +220,8 @@ async def test_raw_response_enroll_many(self, client: AsyncFinch) -> None:
assert_matches_type(AsyncSinglePage[EnrolledIndividual], individual, path=["response"])

@parametrize
async def test_streaming_response_enroll_many(self, client: AsyncFinch) -> None:
async with client.hris.benefits.individuals.with_streaming_response.enroll_many(
async def test_streaming_response_enroll_many(self, async_client: AsyncFinch) -> None:
async with async_client.hris.benefits.individuals.with_streaming_response.enroll_many(
"string",
individuals=[{}],
) as response:
Expand All @@ -240,23 +234,23 @@ async def test_streaming_response_enroll_many(self, client: AsyncFinch) -> None:
assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_enroll_many(self, client: AsyncFinch) -> None:
async def test_path_params_enroll_many(self, async_client: AsyncFinch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
await client.hris.benefits.individuals.with_raw_response.enroll_many(
await async_client.hris.benefits.individuals.with_raw_response.enroll_many(
"",
individuals=[{}],
)

@parametrize
async def test_method_enrolled_ids(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.enrolled_ids(
async def test_method_enrolled_ids(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.enrolled_ids(
"string",
)
assert_matches_type(IndividualEnrolledIDsResponse, individual, path=["response"])

@parametrize
async def test_raw_response_enrolled_ids(self, client: AsyncFinch) -> None:
response = await client.hris.benefits.individuals.with_raw_response.enrolled_ids(
async def test_raw_response_enrolled_ids(self, async_client: AsyncFinch) -> None:
response = await async_client.hris.benefits.individuals.with_raw_response.enrolled_ids(
"string",
)

Expand All @@ -266,8 +260,8 @@ async def test_raw_response_enrolled_ids(self, client: AsyncFinch) -> None:
assert_matches_type(IndividualEnrolledIDsResponse, individual, path=["response"])

@parametrize
async def test_streaming_response_enrolled_ids(self, client: AsyncFinch) -> None:
async with client.hris.benefits.individuals.with_streaming_response.enrolled_ids(
async def test_streaming_response_enrolled_ids(self, async_client: AsyncFinch) -> None:
async with async_client.hris.benefits.individuals.with_streaming_response.enrolled_ids(
"string",
) as response:
assert not response.is_closed
Expand All @@ -279,30 +273,30 @@ async def test_streaming_response_enrolled_ids(self, client: AsyncFinch) -> None
assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_enrolled_ids(self, client: AsyncFinch) -> None:
async def test_path_params_enrolled_ids(self, async_client: AsyncFinch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
await client.hris.benefits.individuals.with_raw_response.enrolled_ids(
await async_client.hris.benefits.individuals.with_raw_response.enrolled_ids(
"",
)

@parametrize
async def test_method_retrieve_many_benefits(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.retrieve_many_benefits(
async def test_method_retrieve_many_benefits(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.retrieve_many_benefits(
"string",
)
assert_matches_type(AsyncSinglePage[IndividualBenefit], individual, path=["response"])

@parametrize
async def test_method_retrieve_many_benefits_with_all_params(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.retrieve_many_benefits(
async def test_method_retrieve_many_benefits_with_all_params(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.retrieve_many_benefits(
"string",
individual_ids="d675d2b7-6d7b-41a8-b2d3-001eb3fb88f6,d02a6346-1f08-4312-a064-49ff3cafaa7a",
)
assert_matches_type(AsyncSinglePage[IndividualBenefit], individual, path=["response"])

@parametrize
async def test_raw_response_retrieve_many_benefits(self, client: AsyncFinch) -> None:
response = await client.hris.benefits.individuals.with_raw_response.retrieve_many_benefits(
async def test_raw_response_retrieve_many_benefits(self, async_client: AsyncFinch) -> None:
response = await async_client.hris.benefits.individuals.with_raw_response.retrieve_many_benefits(
"string",
)

Expand All @@ -312,8 +306,8 @@ async def test_raw_response_retrieve_many_benefits(self, client: AsyncFinch) ->
assert_matches_type(AsyncSinglePage[IndividualBenefit], individual, path=["response"])

@parametrize
async def test_streaming_response_retrieve_many_benefits(self, client: AsyncFinch) -> None:
async with client.hris.benefits.individuals.with_streaming_response.retrieve_many_benefits(
async def test_streaming_response_retrieve_many_benefits(self, async_client: AsyncFinch) -> None:
async with async_client.hris.benefits.individuals.with_streaming_response.retrieve_many_benefits(
"string",
) as response:
assert not response.is_closed
Expand All @@ -325,30 +319,30 @@ async def test_streaming_response_retrieve_many_benefits(self, client: AsyncFinc
assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_retrieve_many_benefits(self, client: AsyncFinch) -> None:
async def test_path_params_retrieve_many_benefits(self, async_client: AsyncFinch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
await client.hris.benefits.individuals.with_raw_response.retrieve_many_benefits(
await async_client.hris.benefits.individuals.with_raw_response.retrieve_many_benefits(
"",
)

@parametrize
async def test_method_unenroll_many(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.unenroll_many(
async def test_method_unenroll_many(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.unenroll_many(
"string",
)
assert_matches_type(AsyncSinglePage[UnenrolledIndividual], individual, path=["response"])

@parametrize
async def test_method_unenroll_many_with_all_params(self, client: AsyncFinch) -> None:
individual = await client.hris.benefits.individuals.unenroll_many(
async def test_method_unenroll_many_with_all_params(self, async_client: AsyncFinch) -> None:
individual = await async_client.hris.benefits.individuals.unenroll_many(
"string",
individual_ids=["string", "string", "string"],
)
assert_matches_type(AsyncSinglePage[UnenrolledIndividual], individual, path=["response"])

@parametrize
async def test_raw_response_unenroll_many(self, client: AsyncFinch) -> None:
response = await client.hris.benefits.individuals.with_raw_response.unenroll_many(
async def test_raw_response_unenroll_many(self, async_client: AsyncFinch) -> None:
response = await async_client.hris.benefits.individuals.with_raw_response.unenroll_many(
"string",
)

Expand All @@ -358,8 +352,8 @@ async def test_raw_response_unenroll_many(self, client: AsyncFinch) -> None:
assert_matches_type(AsyncSinglePage[UnenrolledIndividual], individual, path=["response"])

@parametrize
async def test_streaming_response_unenroll_many(self, client: AsyncFinch) -> None:
async with client.hris.benefits.individuals.with_streaming_response.unenroll_many(
async def test_streaming_response_unenroll_many(self, async_client: AsyncFinch) -> None:
async with async_client.hris.benefits.individuals.with_streaming_response.unenroll_many(
"string",
) as response:
assert not response.is_closed
Expand All @@ -371,8 +365,8 @@ async def test_streaming_response_unenroll_many(self, client: AsyncFinch) -> Non
assert cast(Any, response.is_closed) is True

@parametrize
async def test_path_params_unenroll_many(self, client: AsyncFinch) -> None:
async def test_path_params_unenroll_many(self, async_client: AsyncFinch) -> None:
with pytest.raises(ValueError, match=r"Expected a non-empty value for `benefit_id` but received ''"):
await client.hris.benefits.individuals.with_raw_response.unenroll_many(
await async_client.hris.benefits.individuals.with_raw_response.unenroll_many(
"",
)
Loading