diff --git a/tests/api_resources/hris/benefits/test_individuals.py b/tests/api_resources/hris/benefits/test_individuals.py index 9d4a741e..00e182a5 100644 --- a/tests/api_resources/hris/benefits/test_individuals.py +++ b/tests/api_resources/hris/benefits/test_individuals.py @@ -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, @@ -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: @@ -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=[{}], ) @@ -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: @@ -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", ) @@ -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 @@ -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", ) @@ -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 @@ -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", ) @@ -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 @@ -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( "", ) diff --git a/tests/api_resources/hris/test_benefits.py b/tests/api_resources/hris/test_benefits.py index 025e7a61..8d7d6510 100644 --- a/tests/api_resources/hris/test_benefits.py +++ b/tests/api_resources/hris/test_benefits.py @@ -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 import ( CompanyBenefit, @@ -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 TestBenefits: - 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_create(self, client: Finch) -> None: @@ -197,18 +193,16 @@ def test_streaming_response_list_supported_benefits(self, client: Finch) -> None class TestAsyncBenefits: - 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_create(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.create() + async def test_method_create(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.create() assert_matches_type(CreateCompanyBenefitsResponse, benefit, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.create( + async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.create( description="string", frequency="one_time", type="401k", @@ -216,8 +210,8 @@ async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(CreateCompanyBenefitsResponse, benefit, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.hris.benefits.with_raw_response.create() + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.benefits.with_raw_response.create() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -225,8 +219,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: assert_matches_type(CreateCompanyBenefitsResponse, benefit, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.hris.benefits.with_streaming_response.create() as response: + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.hris.benefits.with_streaming_response.create() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -236,15 +230,15 @@ async def test_streaming_response_create(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_retrieve(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.retrieve( + async def test_method_retrieve(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.retrieve( "string", ) assert_matches_type(CompanyBenefit, benefit, path=["response"]) @parametrize - async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: - response = await client.hris.benefits.with_raw_response.retrieve( + async def test_raw_response_retrieve(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.benefits.with_raw_response.retrieve( "string", ) @@ -254,8 +248,8 @@ async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: assert_matches_type(CompanyBenefit, benefit, path=["response"]) @parametrize - async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: - async with client.hris.benefits.with_streaming_response.retrieve( + async def test_streaming_response_retrieve(self, async_client: AsyncFinch) -> None: + async with async_client.hris.benefits.with_streaming_response.retrieve( "string", ) as response: assert not response.is_closed @@ -267,30 +261,30 @@ async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_retrieve(self, client: AsyncFinch) -> None: + async def test_path_params_retrieve(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.with_raw_response.retrieve( + await async_client.hris.benefits.with_raw_response.retrieve( "", ) @parametrize - async def test_method_update(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.update( + async def test_method_update(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.update( "string", ) assert_matches_type(UpdateCompanyBenefitResponse, benefit, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.update( + async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.update( "string", description="string", ) assert_matches_type(UpdateCompanyBenefitResponse, benefit, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.hris.benefits.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.benefits.with_raw_response.update( "string", ) @@ -300,8 +294,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(UpdateCompanyBenefitResponse, benefit, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.hris.benefits.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.hris.benefits.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -313,20 +307,20 @@ async def test_streaming_response_update(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncFinch) -> None: + async def test_path_params_update(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.with_raw_response.update( + await async_client.hris.benefits.with_raw_response.update( "", ) @parametrize - async def test_method_list(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.list() + async def test_method_list(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.list() assert_matches_type(AsyncSinglePage[CompanyBenefit], benefit, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncFinch) -> None: - response = await client.hris.benefits.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.benefits.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -334,8 +328,8 @@ async def test_raw_response_list(self, client: AsyncFinch) -> None: assert_matches_type(AsyncSinglePage[CompanyBenefit], benefit, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncFinch) -> None: - async with client.hris.benefits.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncFinch) -> None: + async with async_client.hris.benefits.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -345,13 +339,13 @@ async def test_streaming_response_list(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list_supported_benefits(self, client: AsyncFinch) -> None: - benefit = await client.hris.benefits.list_supported_benefits() + async def test_method_list_supported_benefits(self, async_client: AsyncFinch) -> None: + benefit = await async_client.hris.benefits.list_supported_benefits() assert_matches_type(AsyncSinglePage[SupportedBenefit], benefit, path=["response"]) @parametrize - async def test_raw_response_list_supported_benefits(self, client: AsyncFinch) -> None: - response = await client.hris.benefits.with_raw_response.list_supported_benefits() + async def test_raw_response_list_supported_benefits(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.benefits.with_raw_response.list_supported_benefits() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -359,8 +353,8 @@ async def test_raw_response_list_supported_benefits(self, client: AsyncFinch) -> assert_matches_type(AsyncSinglePage[SupportedBenefit], benefit, path=["response"]) @parametrize - async def test_streaming_response_list_supported_benefits(self, client: AsyncFinch) -> None: - async with client.hris.benefits.with_streaming_response.list_supported_benefits() as response: + async def test_streaming_response_list_supported_benefits(self, async_client: AsyncFinch) -> None: + async with async_client.hris.benefits.with_streaming_response.list_supported_benefits() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/hris/test_company.py b/tests/api_resources/hris/test_company.py index a8ae716d..d9f50bb0 100644 --- a/tests/api_resources/hris/test_company.py +++ b/tests/api_resources/hris/test_company.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.hris import Company base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestCompany: - 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_retrieve(self, client: Finch) -> None: @@ -48,18 +44,16 @@ def test_streaming_response_retrieve(self, client: Finch) -> None: class TestAsyncCompany: - 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_retrieve(self, client: AsyncFinch) -> None: - company = await client.hris.company.retrieve() + async def test_method_retrieve(self, async_client: AsyncFinch) -> None: + company = await async_client.hris.company.retrieve() assert_matches_type(Company, company, path=["response"]) @parametrize - async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: - response = await client.hris.company.with_raw_response.retrieve() + async def test_raw_response_retrieve(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.company.with_raw_response.retrieve() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -67,8 +61,8 @@ async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: assert_matches_type(Company, company, path=["response"]) @parametrize - async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: - async with client.hris.company.with_streaming_response.retrieve() as response: + async def test_streaming_response_retrieve(self, async_client: AsyncFinch) -> None: + async with async_client.hris.company.with_streaming_response.retrieve() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/hris/test_directory.py b/tests/api_resources/hris/test_directory.py index 52e39ec2..92308518 100644 --- a/tests/api_resources/hris/test_directory.py +++ b/tests/api_resources/hris/test_directory.py @@ -9,20 +9,16 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncIndividualsPage, AsyncIndividualsPage from finch.types.hris import IndividualInDirectory # pyright: reportDeprecated=false base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestDirectory: - 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_list(self, client: Finch) -> None: @@ -98,26 +94,24 @@ def test_streaming_response_list_individuals(self, client: Finch) -> None: class TestAsyncDirectory: - 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_list(self, client: AsyncFinch) -> None: - directory = await client.hris.directory.list() + async def test_method_list(self, async_client: AsyncFinch) -> None: + directory = await async_client.hris.directory.list() assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncFinch) -> None: - directory = await client.hris.directory.list( + async def test_method_list_with_all_params(self, async_client: AsyncFinch) -> None: + directory = await async_client.hris.directory.list( limit=0, offset=0, ) assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncFinch) -> None: - response = await client.hris.directory.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.directory.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -125,8 +119,8 @@ async def test_raw_response_list(self, client: AsyncFinch) -> None: assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncFinch) -> None: - async with client.hris.directory.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncFinch) -> None: + async with async_client.hris.directory.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -136,16 +130,16 @@ async def test_streaming_response_list(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list_individuals(self, client: AsyncFinch) -> None: + async def test_method_list_individuals(self, async_client: AsyncFinch) -> None: with pytest.warns(DeprecationWarning): - directory = await client.hris.directory.list_individuals() + directory = await async_client.hris.directory.list_individuals() assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_method_list_individuals_with_all_params(self, client: AsyncFinch) -> None: + async def test_method_list_individuals_with_all_params(self, async_client: AsyncFinch) -> None: with pytest.warns(DeprecationWarning): - directory = await client.hris.directory.list_individuals( + directory = await async_client.hris.directory.list_individuals( limit=0, offset=0, ) @@ -153,9 +147,9 @@ async def test_method_list_individuals_with_all_params(self, client: AsyncFinch) assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_raw_response_list_individuals(self, client: AsyncFinch) -> None: + async def test_raw_response_list_individuals(self, async_client: AsyncFinch) -> None: with pytest.warns(DeprecationWarning): - response = await client.hris.directory.with_raw_response.list_individuals() + response = await async_client.hris.directory.with_raw_response.list_individuals() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -163,9 +157,9 @@ async def test_raw_response_list_individuals(self, client: AsyncFinch) -> None: assert_matches_type(AsyncIndividualsPage[IndividualInDirectory], directory, path=["response"]) @parametrize - async def test_streaming_response_list_individuals(self, client: AsyncFinch) -> None: + async def test_streaming_response_list_individuals(self, async_client: AsyncFinch) -> None: with pytest.warns(DeprecationWarning): - async with client.hris.directory.with_streaming_response.list_individuals() as response: + async with async_client.hris.directory.with_streaming_response.list_individuals() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/hris/test_employments.py b/tests/api_resources/hris/test_employments.py index 90cc3b49..d6d53313 100644 --- a/tests/api_resources/hris/test_employments.py +++ b/tests/api_resources/hris/test_employments.py @@ -9,18 +9,14 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncResponsesPage, AsyncResponsesPage from finch.types.hris import EmploymentDataResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestEmployments: - 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_retrieve_many(self, client: Finch) -> None: @@ -55,20 +51,18 @@ def test_streaming_response_retrieve_many(self, client: Finch) -> None: class TestAsyncEmployments: - 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_retrieve_many(self, client: AsyncFinch) -> None: - employment = await client.hris.employments.retrieve_many( + async def test_method_retrieve_many(self, async_client: AsyncFinch) -> None: + employment = await async_client.hris.employments.retrieve_many( requests=[{"individual_id": "string"}, {"individual_id": "string"}, {"individual_id": "string"}], ) assert_matches_type(AsyncResponsesPage[EmploymentDataResponse], employment, path=["response"]) @parametrize - async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: - response = await client.hris.employments.with_raw_response.retrieve_many( + async def test_raw_response_retrieve_many(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.employments.with_raw_response.retrieve_many( requests=[{"individual_id": "string"}, {"individual_id": "string"}, {"individual_id": "string"}], ) @@ -78,8 +72,8 @@ async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: assert_matches_type(AsyncResponsesPage[EmploymentDataResponse], employment, path=["response"]) @parametrize - async def test_streaming_response_retrieve_many(self, client: AsyncFinch) -> None: - async with client.hris.employments.with_streaming_response.retrieve_many( + async def test_streaming_response_retrieve_many(self, async_client: AsyncFinch) -> None: + async with async_client.hris.employments.with_streaming_response.retrieve_many( requests=[{"individual_id": "string"}, {"individual_id": "string"}, {"individual_id": "string"}], ) as response: assert not response.is_closed diff --git a/tests/api_resources/hris/test_individuals.py b/tests/api_resources/hris/test_individuals.py index 328f515f..12b244a0 100644 --- a/tests/api_resources/hris/test_individuals.py +++ b/tests/api_resources/hris/test_individuals.py @@ -9,18 +9,14 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncResponsesPage, AsyncResponsesPage from finch.types.hris import IndividualResponse 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_retrieve_many(self, client: Finch) -> None: @@ -57,26 +53,24 @@ def test_streaming_response_retrieve_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_retrieve_many(self, client: AsyncFinch) -> None: - individual = await client.hris.individuals.retrieve_many() + async def test_method_retrieve_many(self, async_client: AsyncFinch) -> None: + individual = await async_client.hris.individuals.retrieve_many() assert_matches_type(AsyncResponsesPage[IndividualResponse], individual, path=["response"]) @parametrize - async def test_method_retrieve_many_with_all_params(self, client: AsyncFinch) -> None: - individual = await client.hris.individuals.retrieve_many( + async def test_method_retrieve_many_with_all_params(self, async_client: AsyncFinch) -> None: + individual = await async_client.hris.individuals.retrieve_many( options={"include": ["string", "string", "string"]}, requests=[{"individual_id": "string"}, {"individual_id": "string"}, {"individual_id": "string"}], ) assert_matches_type(AsyncResponsesPage[IndividualResponse], individual, path=["response"]) @parametrize - async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: - response = await client.hris.individuals.with_raw_response.retrieve_many() + async def test_raw_response_retrieve_many(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.individuals.with_raw_response.retrieve_many() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -84,8 +78,8 @@ async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: assert_matches_type(AsyncResponsesPage[IndividualResponse], individual, path=["response"]) @parametrize - async def test_streaming_response_retrieve_many(self, client: AsyncFinch) -> None: - async with client.hris.individuals.with_streaming_response.retrieve_many() as response: + async def test_streaming_response_retrieve_many(self, async_client: AsyncFinch) -> None: + async with async_client.hris.individuals.with_streaming_response.retrieve_many() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/hris/test_pay_statements.py b/tests/api_resources/hris/test_pay_statements.py index 159311f0..8b96e656 100644 --- a/tests/api_resources/hris/test_pay_statements.py +++ b/tests/api_resources/hris/test_pay_statements.py @@ -9,18 +9,14 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncResponsesPage, AsyncResponsesPage from finch.types.hris import PayStatementResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestPayStatements: - 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_retrieve_many(self, client: Finch) -> None: @@ -55,20 +51,18 @@ def test_streaming_response_retrieve_many(self, client: Finch) -> None: class TestAsyncPayStatements: - 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_retrieve_many(self, client: AsyncFinch) -> None: - pay_statement = await client.hris.pay_statements.retrieve_many( + async def test_method_retrieve_many(self, async_client: AsyncFinch) -> None: + pay_statement = await async_client.hris.pay_statements.retrieve_many( requests=[{"payment_id": "string"}], ) assert_matches_type(AsyncResponsesPage[PayStatementResponse], pay_statement, path=["response"]) @parametrize - async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: - response = await client.hris.pay_statements.with_raw_response.retrieve_many( + async def test_raw_response_retrieve_many(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.pay_statements.with_raw_response.retrieve_many( requests=[{"payment_id": "string"}], ) @@ -78,8 +72,8 @@ async def test_raw_response_retrieve_many(self, client: AsyncFinch) -> None: assert_matches_type(AsyncResponsesPage[PayStatementResponse], pay_statement, path=["response"]) @parametrize - async def test_streaming_response_retrieve_many(self, client: AsyncFinch) -> None: - async with client.hris.pay_statements.with_streaming_response.retrieve_many( + async def test_streaming_response_retrieve_many(self, async_client: AsyncFinch) -> None: + async with async_client.hris.pay_statements.with_streaming_response.retrieve_many( requests=[{"payment_id": "string"}], ) as response: assert not response.is_closed diff --git a/tests/api_resources/hris/test_payments.py b/tests/api_resources/hris/test_payments.py index 5ab7ea90..022a0c30 100644 --- a/tests/api_resources/hris/test_payments.py +++ b/tests/api_resources/hris/test_payments.py @@ -10,18 +10,14 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type from finch._utils import parse_date -from finch._client import Finch, AsyncFinch from finch.pagination import SyncSinglePage, AsyncSinglePage from finch.types.hris import Payment base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestPayments: - 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_list(self, client: Finch) -> None: @@ -59,21 +55,19 @@ def test_streaming_response_list(self, client: Finch) -> None: class TestAsyncPayments: - 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_list(self, client: AsyncFinch) -> None: - payment = await client.hris.payments.list( + async def test_method_list(self, async_client: AsyncFinch) -> None: + payment = await async_client.hris.payments.list( end_date=parse_date("2021-01-01"), start_date=parse_date("2021-01-01"), ) assert_matches_type(AsyncSinglePage[Payment], payment, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncFinch) -> None: - response = await client.hris.payments.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncFinch) -> None: + response = await async_client.hris.payments.with_raw_response.list( end_date=parse_date("2021-01-01"), start_date=parse_date("2021-01-01"), ) @@ -84,8 +78,8 @@ async def test_raw_response_list(self, client: AsyncFinch) -> None: assert_matches_type(AsyncSinglePage[Payment], payment, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncFinch) -> None: - async with client.hris.payments.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncFinch) -> None: + async with async_client.hris.payments.with_streaming_response.list( end_date=parse_date("2021-01-01"), start_date=parse_date("2021-01-01"), ) as response: diff --git a/tests/api_resources/jobs/test_automated.py b/tests/api_resources/jobs/test_automated.py index 13e7e221..c683780c 100644 --- a/tests/api_resources/jobs/test_automated.py +++ b/tests/api_resources/jobs/test_automated.py @@ -9,18 +9,14 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncPage, AsyncPage from finch.types.jobs import AutomatedAsyncJob, AutomatedCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestAutomated: - 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_create(self, client: Finch) -> None: @@ -126,20 +122,18 @@ def test_streaming_response_list(self, client: Finch) -> None: class TestAsyncAutomated: - 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_create(self, client: AsyncFinch) -> None: - automated = await client.jobs.automated.create( + async def test_method_create(self, async_client: AsyncFinch) -> None: + automated = await async_client.jobs.automated.create( type="data_sync_all", ) assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.jobs.automated.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.jobs.automated.with_raw_response.create( type="data_sync_all", ) @@ -149,8 +143,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: assert_matches_type(AutomatedCreateResponse, automated, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.jobs.automated.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.jobs.automated.with_streaming_response.create( type="data_sync_all", ) as response: assert not response.is_closed @@ -162,15 +156,15 @@ async def test_streaming_response_create(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_retrieve(self, client: AsyncFinch) -> None: - automated = await client.jobs.automated.retrieve( + async def test_method_retrieve(self, async_client: AsyncFinch) -> None: + automated = await async_client.jobs.automated.retrieve( "string", ) assert_matches_type(AutomatedAsyncJob, automated, path=["response"]) @parametrize - async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: - response = await client.jobs.automated.with_raw_response.retrieve( + async def test_raw_response_retrieve(self, async_client: AsyncFinch) -> None: + response = await async_client.jobs.automated.with_raw_response.retrieve( "string", ) @@ -180,8 +174,8 @@ async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: assert_matches_type(AutomatedAsyncJob, automated, path=["response"]) @parametrize - async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: - async with client.jobs.automated.with_streaming_response.retrieve( + async def test_streaming_response_retrieve(self, async_client: AsyncFinch) -> None: + async with async_client.jobs.automated.with_streaming_response.retrieve( "string", ) as response: assert not response.is_closed @@ -193,28 +187,28 @@ async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_retrieve(self, client: AsyncFinch) -> None: + async def test_path_params_retrieve(self, async_client: AsyncFinch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await client.jobs.automated.with_raw_response.retrieve( + await async_client.jobs.automated.with_raw_response.retrieve( "", ) @parametrize - async def test_method_list(self, client: AsyncFinch) -> None: - automated = await client.jobs.automated.list() + async def test_method_list(self, async_client: AsyncFinch) -> None: + automated = await async_client.jobs.automated.list() assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncFinch) -> None: - automated = await client.jobs.automated.list( + async def test_method_list_with_all_params(self, async_client: AsyncFinch) -> None: + automated = await async_client.jobs.automated.list( limit=0, offset=0, ) assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncFinch) -> None: - response = await client.jobs.automated.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncFinch) -> None: + response = await async_client.jobs.automated.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -222,8 +216,8 @@ async def test_raw_response_list(self, client: AsyncFinch) -> None: assert_matches_type(AsyncPage[AutomatedAsyncJob], automated, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncFinch) -> None: - async with client.jobs.automated.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncFinch) -> None: + async with async_client.jobs.automated.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/jobs/test_manual.py b/tests/api_resources/jobs/test_manual.py index 5e65b907..f8ab6edf 100644 --- a/tests/api_resources/jobs/test_manual.py +++ b/tests/api_resources/jobs/test_manual.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.jobs import ManualAsyncJob base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestManual: - 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_retrieve(self, client: Finch) -> None: @@ -61,20 +57,18 @@ def test_path_params_retrieve(self, client: Finch) -> None: class TestAsyncManual: - 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_retrieve(self, client: AsyncFinch) -> None: - manual = await client.jobs.manual.retrieve( + async def test_method_retrieve(self, async_client: AsyncFinch) -> None: + manual = await async_client.jobs.manual.retrieve( "string", ) assert_matches_type(ManualAsyncJob, manual, path=["response"]) @parametrize - async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: - response = await client.jobs.manual.with_raw_response.retrieve( + async def test_raw_response_retrieve(self, async_client: AsyncFinch) -> None: + response = await async_client.jobs.manual.with_raw_response.retrieve( "string", ) @@ -84,8 +78,8 @@ async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: assert_matches_type(ManualAsyncJob, manual, path=["response"]) @parametrize - async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: - async with client.jobs.manual.with_streaming_response.retrieve( + async def test_streaming_response_retrieve(self, async_client: AsyncFinch) -> None: + async with async_client.jobs.manual.with_streaming_response.retrieve( "string", ) as response: assert not response.is_closed @@ -97,8 +91,8 @@ async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_retrieve(self, client: AsyncFinch) -> None: + async def test_path_params_retrieve(self, async_client: AsyncFinch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `job_id` but received ''"): - await client.jobs.manual.with_raw_response.retrieve( + await async_client.jobs.manual.with_raw_response.retrieve( "", ) diff --git a/tests/api_resources/sandbox/connections/test_accounts.py b/tests/api_resources/sandbox/connections/test_accounts.py index 16f3496e..1a674794 100644 --- a/tests/api_resources/sandbox/connections/test_accounts.py +++ b/tests/api_resources/sandbox/connections/test_accounts.py @@ -9,20 +9,16 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox.connections import ( AccountCreateResponse, AccountUpdateResponse, ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestAccounts: - 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"]) @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize @@ -106,14 +102,12 @@ def test_streaming_response_update(self, client: Finch) -> None: class TestAsyncAccounts: - 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"]) @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_method_create(self, client: AsyncFinch) -> None: - account = await client.sandbox.connections.accounts.create( + async def test_method_create(self, async_client: AsyncFinch) -> None: + account = await async_client.sandbox.connections.accounts.create( company_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", provider_id="string", ) @@ -121,8 +115,8 @@ async def test_method_create(self, client: AsyncFinch) -> None: @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: - account = await client.sandbox.connections.accounts.create( + async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: + account = await async_client.sandbox.connections.accounts.create( company_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", provider_id="string", authentication_type="credentials", @@ -132,8 +126,8 @@ async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.sandbox.connections.accounts.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.connections.accounts.with_raw_response.create( company_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", provider_id="string", ) @@ -145,8 +139,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.sandbox.connections.accounts.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.connections.accounts.with_streaming_response.create( company_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", provider_id="string", ) as response: @@ -159,20 +153,20 @@ async def test_streaming_response_create(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_update(self, client: AsyncFinch) -> None: - account = await client.sandbox.connections.accounts.update() + async def test_method_update(self, async_client: AsyncFinch) -> None: + account = await async_client.sandbox.connections.accounts.update() assert_matches_type(AccountUpdateResponse, account, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: - account = await client.sandbox.connections.accounts.update( + async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: + account = await async_client.sandbox.connections.accounts.update( connection_status="reauth", ) assert_matches_type(AccountUpdateResponse, account, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.sandbox.connections.accounts.with_raw_response.update() + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.connections.accounts.with_raw_response.update() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -180,8 +174,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(AccountUpdateResponse, account, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.sandbox.connections.accounts.with_streaming_response.update() as response: + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.connections.accounts.with_streaming_response.update() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/sandbox/jobs/test_configuration.py b/tests/api_resources/sandbox/jobs/test_configuration.py index 41aee24e..17d4f21b 100644 --- a/tests/api_resources/sandbox/jobs/test_configuration.py +++ b/tests/api_resources/sandbox/jobs/test_configuration.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox.jobs import SandboxJobConfiguration, ConfigurationRetrieveResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestConfiguration: - 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_retrieve(self, client: Finch) -> None: @@ -82,18 +78,16 @@ def test_streaming_response_update(self, client: Finch) -> None: class TestAsyncConfiguration: - 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_retrieve(self, client: AsyncFinch) -> None: - configuration = await client.sandbox.jobs.configuration.retrieve() + async def test_method_retrieve(self, async_client: AsyncFinch) -> None: + configuration = await async_client.sandbox.jobs.configuration.retrieve() assert_matches_type(ConfigurationRetrieveResponse, configuration, path=["response"]) @parametrize - async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: - response = await client.sandbox.jobs.configuration.with_raw_response.retrieve() + async def test_raw_response_retrieve(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.jobs.configuration.with_raw_response.retrieve() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -101,8 +95,8 @@ async def test_raw_response_retrieve(self, client: AsyncFinch) -> None: assert_matches_type(ConfigurationRetrieveResponse, configuration, path=["response"]) @parametrize - async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: - async with client.sandbox.jobs.configuration.with_streaming_response.retrieve() as response: + async def test_streaming_response_retrieve(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.jobs.configuration.with_streaming_response.retrieve() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -112,16 +106,16 @@ async def test_streaming_response_retrieve(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_update(self, client: AsyncFinch) -> None: - configuration = await client.sandbox.jobs.configuration.update( + async def test_method_update(self, async_client: AsyncFinch) -> None: + configuration = await async_client.sandbox.jobs.configuration.update( completion_status="complete", type="data_sync_all", ) assert_matches_type(SandboxJobConfiguration, configuration, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.sandbox.jobs.configuration.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.jobs.configuration.with_raw_response.update( completion_status="complete", type="data_sync_all", ) @@ -132,8 +126,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(SandboxJobConfiguration, configuration, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.sandbox.jobs.configuration.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.jobs.configuration.with_streaming_response.update( completion_status="complete", type="data_sync_all", ) as response: diff --git a/tests/api_resources/sandbox/test_company.py b/tests/api_resources/sandbox/test_company.py index f4fc204e..c542d166 100644 --- a/tests/api_resources/sandbox/test_company.py +++ b/tests/api_resources/sandbox/test_company.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import CompanyUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestCompany: - 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_update(self, client: Finch) -> None: @@ -158,13 +154,11 @@ def test_streaming_response_update(self, client: Finch) -> None: class TestAsyncCompany: - 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_update(self, client: AsyncFinch) -> None: - company = await client.sandbox.company.update( + async def test_method_update(self, async_client: AsyncFinch) -> None: + company = await async_client.sandbox.company.update( accounts=[{}, {}, {}], departments=[{}, {}, {}], ein="string", @@ -177,8 +171,8 @@ async def test_method_update(self, client: AsyncFinch) -> None: assert_matches_type(CompanyUpdateResponse, company, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: - company = await client.sandbox.company.update( + async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: + company = await async_client.sandbox.company.update( accounts=[ { "routing_number": "string", @@ -260,8 +254,8 @@ async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(CompanyUpdateResponse, company, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.sandbox.company.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.company.with_raw_response.update( accounts=[{}, {}, {}], departments=[{}, {}, {}], ein="string", @@ -278,8 +272,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(CompanyUpdateResponse, company, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.sandbox.company.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.company.with_streaming_response.update( accounts=[{}, {}, {}], departments=[{}, {}, {}], ein="string", diff --git a/tests/api_resources/sandbox/test_connections.py b/tests/api_resources/sandbox/test_connections.py index 3eb39ea9..f0606e33 100644 --- a/tests/api_resources/sandbox/test_connections.py +++ b/tests/api_resources/sandbox/test_connections.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import ConnectionCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestConnections: - 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"]) @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize @@ -68,22 +64,20 @@ def test_streaming_response_create(self, client: Finch) -> None: class TestAsyncConnections: - 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"]) @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_method_create(self, client: AsyncFinch) -> None: - connection = await client.sandbox.connections.create( + async def test_method_create(self, async_client: AsyncFinch) -> None: + connection = await async_client.sandbox.connections.create( provider_id="string", ) assert_matches_type(ConnectionCreateResponse, connection, path=["response"]) @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: - connection = await client.sandbox.connections.create( + async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: + connection = await async_client.sandbox.connections.create( provider_id="string", authentication_type="credentials", employer_size=0, @@ -93,8 +87,8 @@ async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.sandbox.connections.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.connections.with_raw_response.create( provider_id="string", ) @@ -105,8 +99,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: @pytest.mark.skip(reason="Auth isn't setup correctly in this test") @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.sandbox.connections.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.connections.with_streaming_response.create( provider_id="string", ) as response: assert not response.is_closed diff --git a/tests/api_resources/sandbox/test_directory.py b/tests/api_resources/sandbox/test_directory.py index 430b24d6..c73edba0 100644 --- a/tests/api_resources/sandbox/test_directory.py +++ b/tests/api_resources/sandbox/test_directory.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import DirectoryCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestDirectory: - 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_create(self, client: Finch) -> None: @@ -54,20 +50,18 @@ def test_streaming_response_create(self, client: Finch) -> None: class TestAsyncDirectory: - 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_create(self, client: AsyncFinch) -> None: - directory = await client.sandbox.directory.create( + async def test_method_create(self, async_client: AsyncFinch) -> None: + directory = await async_client.sandbox.directory.create( body=[{}], ) assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.sandbox.directory.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.directory.with_raw_response.create( body=[{}], ) @@ -77,8 +71,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: assert_matches_type(DirectoryCreateResponse, directory, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.sandbox.directory.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.directory.with_streaming_response.create( body=[{}], ) as response: assert not response.is_closed diff --git a/tests/api_resources/sandbox/test_employment.py b/tests/api_resources/sandbox/test_employment.py index 13e1930e..f055e7ad 100644 --- a/tests/api_resources/sandbox/test_employment.py +++ b/tests/api_resources/sandbox/test_employment.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import EmploymentUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestEmployment: - 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_update(self, client: Finch) -> None: @@ -133,20 +129,18 @@ def test_path_params_update(self, client: Finch) -> None: class TestAsyncEmployment: - 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_update(self, client: AsyncFinch) -> None: - employment = await client.sandbox.employment.update( + async def test_method_update(self, async_client: AsyncFinch) -> None: + employment = await async_client.sandbox.employment.update( "string", ) assert_matches_type(EmploymentUpdateResponse, employment, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: - employment = await client.sandbox.employment.update( + async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: + employment = await async_client.sandbox.employment.update( "string", class_code="string", custom_fields=[ @@ -217,8 +211,8 @@ async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(EmploymentUpdateResponse, employment, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.sandbox.employment.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.employment.with_raw_response.update( "string", ) @@ -228,8 +222,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(EmploymentUpdateResponse, employment, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.sandbox.employment.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.employment.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -241,8 +235,8 @@ async def test_streaming_response_update(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncFinch) -> None: + async def test_path_params_update(self, async_client: AsyncFinch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `individual_id` but received ''"): - await client.sandbox.employment.with_raw_response.update( + await async_client.sandbox.employment.with_raw_response.update( "", ) diff --git a/tests/api_resources/sandbox/test_individual.py b/tests/api_resources/sandbox/test_individual.py index e4ca9751..7e40c602 100644 --- a/tests/api_resources/sandbox/test_individual.py +++ b/tests/api_resources/sandbox/test_individual.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import IndividualUpdateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestIndividual: - 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_update(self, client: Finch) -> None: @@ -115,20 +111,18 @@ def test_path_params_update(self, client: Finch) -> None: class TestAsyncIndividual: - 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_update(self, client: AsyncFinch) -> None: - individual = await client.sandbox.individual.update( + async def test_method_update(self, async_client: AsyncFinch) -> None: + individual = await async_client.sandbox.individual.update( "string", ) assert_matches_type(IndividualUpdateResponse, individual, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: - individual = await client.sandbox.individual.update( + async def test_method_update_with_all_params(self, async_client: AsyncFinch) -> None: + individual = await async_client.sandbox.individual.update( "string", dob="12/20/1989", emails=[ @@ -181,8 +175,8 @@ async def test_method_update_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(IndividualUpdateResponse, individual, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncFinch) -> None: - response = await client.sandbox.individual.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.individual.with_raw_response.update( "string", ) @@ -192,8 +186,8 @@ async def test_raw_response_update(self, client: AsyncFinch) -> None: assert_matches_type(IndividualUpdateResponse, individual, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncFinch) -> None: - async with client.sandbox.individual.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.individual.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -205,8 +199,8 @@ async def test_streaming_response_update(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncFinch) -> None: + async def test_path_params_update(self, async_client: AsyncFinch) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `individual_id` but received ''"): - await client.sandbox.individual.with_raw_response.update( + await async_client.sandbox.individual.with_raw_response.update( "", ) diff --git a/tests/api_resources/sandbox/test_payment.py b/tests/api_resources/sandbox/test_payment.py index 02caa7fd..86be4bbb 100644 --- a/tests/api_resources/sandbox/test_payment.py +++ b/tests/api_resources/sandbox/test_payment.py @@ -9,17 +9,13 @@ from finch import Finch, AsyncFinch from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.types.sandbox import PaymentCreateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestPayment: - 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_create(self, client: Finch) -> None: @@ -147,18 +143,16 @@ def test_streaming_response_create(self, client: Finch) -> None: class TestAsyncPayment: - 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_create(self, client: AsyncFinch) -> None: - payment = await client.sandbox.payment.create() + async def test_method_create(self, async_client: AsyncFinch) -> None: + payment = await async_client.sandbox.payment.create() assert_matches_type(PaymentCreateResponse, payment, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: - payment = await client.sandbox.payment.create( + async def test_method_create_with_all_params(self, async_client: AsyncFinch) -> None: + payment = await async_client.sandbox.payment.create( end_date="string", pay_statements=[ { @@ -256,8 +250,8 @@ async def test_method_create_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(PaymentCreateResponse, payment, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.sandbox.payment.with_raw_response.create() + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.sandbox.payment.with_raw_response.create() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -265,8 +259,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: assert_matches_type(PaymentCreateResponse, payment, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.sandbox.payment.with_streaming_response.create() as response: + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.sandbox.payment.with_streaming_response.create() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_access_tokens.py b/tests/api_resources/test_access_tokens.py index 6bedf634..b03994d3 100644 --- a/tests/api_resources/test_access_tokens.py +++ b/tests/api_resources/test_access_tokens.py @@ -10,16 +10,12 @@ from finch import Finch, AsyncFinch from finch.types import CreateAccessTokenResponse from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestAccessTokens: - 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_create(self, client: Finch) -> None: @@ -63,13 +59,11 @@ def test_streaming_response_create(self, client: Finch) -> None: class TestAsyncAccessTokens: - 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_create(self, client: AsyncFinch) -> None: - access_token = await client.access_tokens.create( + async def test_method_create(self, async_client: AsyncFinch) -> None: + access_token = await async_client.access_tokens.create( client_id="", client_secret="", code="", @@ -78,8 +72,8 @@ async def test_method_create(self, client: AsyncFinch) -> None: assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncFinch) -> None: - response = await client.access_tokens.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncFinch) -> None: + response = await async_client.access_tokens.with_raw_response.create( client_id="", client_secret="", code="", @@ -92,8 +86,8 @@ async def test_raw_response_create(self, client: AsyncFinch) -> None: assert_matches_type(CreateAccessTokenResponse, access_token, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncFinch) -> None: - async with client.access_tokens.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncFinch) -> None: + async with async_client.access_tokens.with_streaming_response.create( client_id="", client_secret="", code="", diff --git a/tests/api_resources/test_account.py b/tests/api_resources/test_account.py index 28f52433..7dedf857 100644 --- a/tests/api_resources/test_account.py +++ b/tests/api_resources/test_account.py @@ -10,16 +10,12 @@ from finch import Finch, AsyncFinch from finch.types import Introspection, DisconnectResponse from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestAccount: - 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_disconnect(self, client: Finch) -> None: @@ -73,18 +69,16 @@ def test_streaming_response_introspect(self, client: Finch) -> None: class TestAsyncAccount: - 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_disconnect(self, client: AsyncFinch) -> None: - account = await client.account.disconnect() + async def test_method_disconnect(self, async_client: AsyncFinch) -> None: + account = await async_client.account.disconnect() assert_matches_type(DisconnectResponse, account, path=["response"]) @parametrize - async def test_raw_response_disconnect(self, client: AsyncFinch) -> None: - response = await client.account.with_raw_response.disconnect() + async def test_raw_response_disconnect(self, async_client: AsyncFinch) -> None: + response = await async_client.account.with_raw_response.disconnect() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -92,8 +86,8 @@ async def test_raw_response_disconnect(self, client: AsyncFinch) -> None: assert_matches_type(DisconnectResponse, account, path=["response"]) @parametrize - async def test_streaming_response_disconnect(self, client: AsyncFinch) -> None: - async with client.account.with_streaming_response.disconnect() as response: + async def test_streaming_response_disconnect(self, async_client: AsyncFinch) -> None: + async with async_client.account.with_streaming_response.disconnect() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -103,13 +97,13 @@ async def test_streaming_response_disconnect(self, client: AsyncFinch) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_introspect(self, client: AsyncFinch) -> None: - account = await client.account.introspect() + async def test_method_introspect(self, async_client: AsyncFinch) -> None: + account = await async_client.account.introspect() assert_matches_type(Introspection, account, path=["response"]) @parametrize - async def test_raw_response_introspect(self, client: AsyncFinch) -> None: - response = await client.account.with_raw_response.introspect() + async def test_raw_response_introspect(self, async_client: AsyncFinch) -> None: + response = await async_client.account.with_raw_response.introspect() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -117,8 +111,8 @@ async def test_raw_response_introspect(self, client: AsyncFinch) -> None: assert_matches_type(Introspection, account, path=["response"]) @parametrize - async def test_streaming_response_introspect(self, client: AsyncFinch) -> None: - async with client.account.with_streaming_response.introspect() as response: + async def test_streaming_response_introspect(self, async_client: AsyncFinch) -> None: + async with async_client.account.with_streaming_response.introspect() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_providers.py b/tests/api_resources/test_providers.py index c78a5c4b..a9ef8c2b 100644 --- a/tests/api_resources/test_providers.py +++ b/tests/api_resources/test_providers.py @@ -10,17 +10,13 @@ from finch import Finch, AsyncFinch from finch.types import Provider from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch from finch.pagination import SyncSinglePage, AsyncSinglePage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestProviders: - 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_list(self, client: Finch) -> None: @@ -49,18 +45,16 @@ def test_streaming_response_list(self, client: Finch) -> None: class TestAsyncProviders: - 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_list(self, client: AsyncFinch) -> None: - provider = await client.providers.list() + async def test_method_list(self, async_client: AsyncFinch) -> None: + provider = await async_client.providers.list() assert_matches_type(AsyncSinglePage[Provider], provider, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncFinch) -> None: - response = await client.providers.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncFinch) -> None: + response = await async_client.providers.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -68,8 +62,8 @@ async def test_raw_response_list(self, client: AsyncFinch) -> None: assert_matches_type(AsyncSinglePage[Provider], provider, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncFinch) -> None: - async with client.providers.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncFinch) -> None: + async with async_client.providers.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/api_resources/test_request_forwarding.py b/tests/api_resources/test_request_forwarding.py index 541cc151..de68152d 100644 --- a/tests/api_resources/test_request_forwarding.py +++ b/tests/api_resources/test_request_forwarding.py @@ -10,16 +10,12 @@ from finch import Finch, AsyncFinch from finch.types import RequestForwardingForwardResponse from tests.utils import assert_matches_type -from finch._client import Finch, AsyncFinch base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" 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 = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize def test_method_forward(self, client: Finch) -> None: @@ -71,21 +67,19 @@ def test_streaming_response_forward(self, client: Finch) -> None: 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 = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_forward(self, client: AsyncFinch) -> None: - request_forwarding = await client.request_forwarding.forward( + async def test_method_forward(self, async_client: AsyncFinch) -> None: + request_forwarding = await async_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( + async def test_method_forward_with_all_params(self, async_client: AsyncFinch) -> None: + request_forwarding = await async_client.request_forwarding.forward( method="POST", route="/people/search", data=None, @@ -98,8 +92,8 @@ async def test_method_forward_with_all_params(self, client: AsyncFinch) -> None: assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"]) @parametrize - async def test_raw_response_forward(self, client: AsyncFinch) -> None: - response = await client.request_forwarding.with_raw_response.forward( + async def test_raw_response_forward(self, async_client: AsyncFinch) -> None: + response = await async_client.request_forwarding.with_raw_response.forward( method="POST", route="/people/search", ) @@ -110,8 +104,8 @@ async def test_raw_response_forward(self, client: AsyncFinch) -> None: assert_matches_type(RequestForwardingForwardResponse, request_forwarding, path=["response"]) @parametrize - async def test_streaming_response_forward(self, client: AsyncFinch) -> None: - async with client.request_forwarding.with_streaming_response.forward( + async def test_streaming_response_forward(self, async_client: AsyncFinch) -> None: + async with async_client.request_forwarding.with_streaming_response.forward( method="POST", route="/people/search", ) as response: diff --git a/tests/api_resources/test_top_level.py b/tests/api_resources/test_top_level.py index a36d997f..c0752165 100644 --- a/tests/api_resources/test_top_level.py +++ b/tests/api_resources/test_top_level.py @@ -6,20 +6,12 @@ import pytest -from finch import Finch, AsyncFinch -from finch._client import Finch, AsyncFinch - base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestTopLevel: - 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"]) class TestAsyncTopLevel: - 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"]) diff --git a/tests/api_resources/test_webhooks.py b/tests/api_resources/test_webhooks.py index 203deb9c..edcd45f8 100644 --- a/tests/api_resources/test_webhooks.py +++ b/tests/api_resources/test_webhooks.py @@ -12,16 +12,12 @@ from pydantic import BaseModel from finch import Finch, AsyncFinch -from finch._client import Finch, AsyncFinch base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -access_token = "My Access Token" class TestWebhooks: - 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"]) timestamp = "1676312382" fake_now = datetime.fromtimestamp(float(timestamp), tz=timezone.utc) @@ -36,21 +32,21 @@ class TestWebhooks: secret = "5WbX5kEWLlfzsGNjH64I8lOOqUB6e8FH" @time_machine.travel(fake_now) - def test_unwrap(self) -> None: + def test_unwrap(self, client: Finch) -> None: payload = self.payload headers = self.headers secret = self.secret - obj = self.strict_client.webhooks.unwrap(payload, headers, secret=secret) + obj = client.webhooks.unwrap(payload, headers, secret=secret) assert isinstance(obj, BaseModel) @time_machine.travel(fake_now) - def test_verify_signature(self) -> None: + def test_verify_signature(self, client: Finch) -> None: payload = self.payload headers = self.headers secret = self.secret signature = self.signature - verify = self.strict_client.webhooks.verify_signature + verify = client.webhooks.verify_signature assert verify(payload=payload, headers=headers, secret=secret) is None @@ -120,9 +116,7 @@ def test_verify_signature(self) -> None: class TestAsyncWebhooks: - 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"]) timestamp = "1676312382" fake_now = datetime.fromtimestamp(float(timestamp), tz=timezone.utc) @@ -137,21 +131,21 @@ class TestAsyncWebhooks: secret = "5WbX5kEWLlfzsGNjH64I8lOOqUB6e8FH" @time_machine.travel(fake_now) - def test_unwrap(self) -> None: + def test_unwrap(self, async_client: AsyncFinch) -> None: payload = self.payload headers = self.headers secret = self.secret - obj = self.strict_client.webhooks.unwrap(payload, headers, secret=secret) + obj = async_client.webhooks.unwrap(payload, headers, secret=secret) assert isinstance(obj, BaseModel) @time_machine.travel(fake_now) - def test_verify_signature(self) -> None: + def test_verify_signature(self, async_client: AsyncFinch) -> None: payload = self.payload headers = self.headers secret = self.secret signature = self.signature - verify = self.strict_client.webhooks.verify_signature + verify = async_client.webhooks.verify_signature assert verify(payload=payload, headers=headers, secret=secret) is None diff --git a/tests/conftest.py b/tests/conftest.py index f981b45d..2c791d06 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,9 +1,17 @@ +from __future__ import annotations + +import os import asyncio import logging -from typing import Iterator +from typing import TYPE_CHECKING, Iterator, AsyncIterator import pytest +from finch import Finch, AsyncFinch + +if TYPE_CHECKING: + from _pytest.fixtures import FixtureRequest + pytest.register_assert_rewrite("tests.utils") logging.getLogger("finch").setLevel(logging.DEBUG) @@ -14,3 +22,28 @@ def event_loop() -> Iterator[asyncio.AbstractEventLoop]: loop = asyncio.new_event_loop() yield loop loop.close() + + +base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") + +access_token = "My Access Token" + + +@pytest.fixture(scope="session") +def client(request: FixtureRequest) -> Iterator[Finch]: + strict = getattr(request, "param", True) + if not isinstance(strict, bool): + raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}") + + with Finch(base_url=base_url, access_token=access_token, _strict_response_validation=strict) as client: + yield client + + +@pytest.fixture(scope="session") +async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncFinch]: + strict = getattr(request, "param", True) + if not isinstance(strict, bool): + raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}") + + async with AsyncFinch(base_url=base_url, access_token=access_token, _strict_response_validation=strict) as client: + yield client