diff --git a/tests/api_resources/beta/test_price.py b/tests/api_resources/beta/test_price.py index 9c268ffc..35fb4476 100644 --- a/tests/api_resources/beta/test_price.py +++ b/tests/api_resources/beta/test_price.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.types.beta import PriceEvaluateResponse base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestPrice: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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_evaluate(self, client: Orb) -> None: @@ -83,13 +79,11 @@ def test_path_params_evaluate(self, client: Orb) -> None: class TestAsyncPrice: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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_evaluate(self, client: AsyncOrb) -> None: - price = await client.beta.price.evaluate( + async def test_method_evaluate(self, async_client: AsyncOrb) -> None: + price = await async_client.beta.price.evaluate( "string", timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -97,8 +91,8 @@ async def test_method_evaluate(self, client: AsyncOrb) -> None: assert_matches_type(PriceEvaluateResponse, price, path=["response"]) @parametrize - async def test_method_evaluate_with_all_params(self, client: AsyncOrb) -> None: - price = await client.beta.price.evaluate( + async def test_method_evaluate_with_all_params(self, async_client: AsyncOrb) -> None: + price = await async_client.beta.price.evaluate( "string", timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -110,8 +104,8 @@ async def test_method_evaluate_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(PriceEvaluateResponse, price, path=["response"]) @parametrize - async def test_raw_response_evaluate(self, client: AsyncOrb) -> None: - response = await client.beta.price.with_raw_response.evaluate( + async def test_raw_response_evaluate(self, async_client: AsyncOrb) -> None: + response = await async_client.beta.price.with_raw_response.evaluate( "string", timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -123,8 +117,8 @@ async def test_raw_response_evaluate(self, client: AsyncOrb) -> None: assert_matches_type(PriceEvaluateResponse, price, path=["response"]) @parametrize - async def test_streaming_response_evaluate(self, client: AsyncOrb) -> None: - async with client.beta.price.with_streaming_response.evaluate( + async def test_streaming_response_evaluate(self, async_client: AsyncOrb) -> None: + async with async_client.beta.price.with_streaming_response.evaluate( "string", timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -138,9 +132,9 @@ async def test_streaming_response_evaluate(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_evaluate(self, client: AsyncOrb) -> None: + async def test_path_params_evaluate(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `price_id` but received ''"): - await client.beta.price.with_raw_response.evaluate( + await async_client.beta.price.with_raw_response.evaluate( "", timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), diff --git a/tests/api_resources/coupons/test_subscriptions.py b/tests/api_resources/coupons/test_subscriptions.py index c6eb19f4..4cb00cf7 100644 --- a/tests/api_resources/coupons/test_subscriptions.py +++ b/tests/api_resources/coupons/test_subscriptions.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb.types import Subscription -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestSubscriptions: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -71,20 +67,18 @@ def test_path_params_list(self, client: Orb) -> None: class TestAsyncSubscriptions: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - subscription = await client.coupons.subscriptions.list( + async def test_method_list(self, async_client: AsyncOrb) -> None: + subscription = await async_client.coupons.subscriptions.list( "string", ) assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.coupons.subscriptions.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.coupons.subscriptions.list( "string", cursor="string", limit=0, @@ -92,8 +86,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.coupons.subscriptions.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.coupons.subscriptions.with_raw_response.list( "string", ) @@ -103,8 +97,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.coupons.subscriptions.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.coupons.subscriptions.with_streaming_response.list( "string", ) as response: assert not response.is_closed @@ -116,8 +110,8 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list(self, client: AsyncOrb) -> None: + async def test_path_params_list(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `coupon_id` but received ''"): - await client.coupons.subscriptions.with_raw_response.list( + await async_client.coupons.subscriptions.with_raw_response.list( "", ) diff --git a/tests/api_resources/customers/credits/test_ledger.py b/tests/api_resources/customers/credits/test_ledger.py index 9e189c34..ac8c140a 100644 --- a/tests/api_resources/customers/credits/test_ledger.py +++ b/tests/api_resources/customers/credits/test_ledger.py @@ -9,7 +9,6 @@ from orb import Orb, AsyncOrb from orb._utils import parse_date, parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage from orb.types.customers.credits import ( @@ -20,13 +19,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestLedger: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -772,20 +768,18 @@ def test_path_params_list_by_external_id(self, client: Orb) -> None: class TestAsyncLedger: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.list( + async def test_method_list(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.list( "string", ) assert_matches_type(AsyncPage[LedgerListResponse], ledger, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.list( "string", created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -801,8 +795,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[LedgerListResponse], ledger, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.list( "string", ) @@ -812,8 +806,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[LedgerListResponse], ledger, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.list( "string", ) as response: assert not response.is_closed @@ -825,15 +819,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list(self, client: AsyncOrb) -> None: + async def test_path_params_list(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.list( + await async_client.customers.credits.ledger.with_raw_response.list( "", ) @parametrize - async def test_method_create_entry_overload_1(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_overload_1(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, entry_type="increment", @@ -841,8 +835,8 @@ async def test_method_create_entry_overload_1(self, client: AsyncOrb) -> None: assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_with_all_params_overload_1(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_with_all_params_overload_1(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, entry_type="increment", @@ -861,8 +855,8 @@ async def test_method_create_entry_with_all_params_overload_1(self, client: Asyn assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_overload_1(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry( + async def test_raw_response_create_entry_overload_1(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry( "string", amount=0, entry_type="increment", @@ -874,8 +868,8 @@ async def test_raw_response_create_entry_overload_1(self, client: AsyncOrb) -> N assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_overload_1(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry( + async def test_streaming_response_create_entry_overload_1(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry( "string", amount=0, entry_type="increment", @@ -889,17 +883,17 @@ async def test_streaming_response_create_entry_overload_1(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_overload_1(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_overload_1(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry( + await async_client.customers.credits.ledger.with_raw_response.create_entry( "", amount=0, entry_type="increment", ) @parametrize - async def test_method_create_entry_overload_2(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_overload_2(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, entry_type="decrement", @@ -907,8 +901,8 @@ async def test_method_create_entry_overload_2(self, client: AsyncOrb) -> None: assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_with_all_params_overload_2(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_with_all_params_overload_2(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, entry_type="decrement", @@ -919,8 +913,8 @@ async def test_method_create_entry_with_all_params_overload_2(self, client: Asyn assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_overload_2(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry( + async def test_raw_response_create_entry_overload_2(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry( "string", amount=0, entry_type="decrement", @@ -932,8 +926,8 @@ async def test_raw_response_create_entry_overload_2(self, client: AsyncOrb) -> N assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_overload_2(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry( + async def test_streaming_response_create_entry_overload_2(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry( "string", amount=0, entry_type="decrement", @@ -947,17 +941,17 @@ async def test_streaming_response_create_entry_overload_2(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_overload_2(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_overload_2(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry( + await async_client.customers.credits.ledger.with_raw_response.create_entry( "", amount=0, entry_type="decrement", ) @parametrize - async def test_method_create_entry_overload_3(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_overload_3(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -966,8 +960,8 @@ async def test_method_create_entry_overload_3(self, client: AsyncOrb) -> None: assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_with_all_params_overload_3(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_with_all_params_overload_3(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -981,8 +975,8 @@ async def test_method_create_entry_with_all_params_overload_3(self, client: Asyn assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_overload_3(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry( + async def test_raw_response_create_entry_overload_3(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -995,8 +989,8 @@ async def test_raw_response_create_entry_overload_3(self, client: AsyncOrb) -> N assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_overload_3(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry( + async def test_streaming_response_create_entry_overload_3(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1011,9 +1005,9 @@ async def test_streaming_response_create_entry_overload_3(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_overload_3(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_overload_3(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry( + await async_client.customers.credits.ledger.with_raw_response.create_entry( "", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1021,8 +1015,8 @@ async def test_path_params_create_entry_overload_3(self, client: AsyncOrb) -> No ) @parametrize - async def test_method_create_entry_overload_4(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_overload_4(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, block_id="string", @@ -1031,8 +1025,8 @@ async def test_method_create_entry_overload_4(self, client: AsyncOrb) -> None: assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_with_all_params_overload_4(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_with_all_params_overload_4(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, block_id="string", @@ -1045,8 +1039,8 @@ async def test_method_create_entry_with_all_params_overload_4(self, client: Asyn assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_overload_4(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry( + async def test_raw_response_create_entry_overload_4(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry( "string", amount=0, block_id="string", @@ -1059,8 +1053,8 @@ async def test_raw_response_create_entry_overload_4(self, client: AsyncOrb) -> N assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_overload_4(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry( + async def test_streaming_response_create_entry_overload_4(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry( "string", amount=0, block_id="string", @@ -1075,9 +1069,9 @@ async def test_streaming_response_create_entry_overload_4(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_overload_4(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_overload_4(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry( + await async_client.customers.credits.ledger.with_raw_response.create_entry( "", amount=0, block_id="string", @@ -1085,8 +1079,8 @@ async def test_path_params_create_entry_overload_4(self, client: AsyncOrb) -> No ) @parametrize - async def test_method_create_entry_overload_5(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_overload_5(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, block_id="string", @@ -1095,8 +1089,8 @@ async def test_method_create_entry_overload_5(self, client: AsyncOrb) -> None: assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_with_all_params_overload_5(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry( + async def test_method_create_entry_with_all_params_overload_5(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry( "string", amount=0, block_id="string", @@ -1108,8 +1102,8 @@ async def test_method_create_entry_with_all_params_overload_5(self, client: Asyn assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_overload_5(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry( + async def test_raw_response_create_entry_overload_5(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry( "string", amount=0, block_id="string", @@ -1122,8 +1116,8 @@ async def test_raw_response_create_entry_overload_5(self, client: AsyncOrb) -> N assert_matches_type(LedgerCreateEntryResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_overload_5(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry( + async def test_streaming_response_create_entry_overload_5(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry( "string", amount=0, block_id="string", @@ -1138,9 +1132,9 @@ async def test_streaming_response_create_entry_overload_5(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_overload_5(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_overload_5(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry( + await async_client.customers.credits.ledger.with_raw_response.create_entry( "", amount=0, block_id="string", @@ -1148,8 +1142,8 @@ async def test_path_params_create_entry_overload_5(self, client: AsyncOrb) -> No ) @parametrize - async def test_method_create_entry_by_external_id_overload_1(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_overload_1(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, entry_type="increment", @@ -1157,8 +1151,8 @@ async def test_method_create_entry_by_external_id_overload_1(self, client: Async assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_by_external_id_with_all_params_overload_1(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_with_all_params_overload_1(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, entry_type="increment", @@ -1177,8 +1171,8 @@ async def test_method_create_entry_by_external_id_with_all_params_overload_1(sel assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_by_external_id_overload_1(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + async def test_raw_response_create_entry_by_external_id_overload_1(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "string", amount=0, entry_type="increment", @@ -1190,8 +1184,8 @@ async def test_raw_response_create_entry_by_external_id_overload_1(self, client: assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_by_external_id_overload_1(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( + async def test_streaming_response_create_entry_by_external_id_overload_1(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( "string", amount=0, entry_type="increment", @@ -1205,17 +1199,17 @@ async def test_streaming_response_create_entry_by_external_id_overload_1(self, c assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_by_external_id_overload_1(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_by_external_id_overload_1(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "", amount=0, entry_type="increment", ) @parametrize - async def test_method_create_entry_by_external_id_overload_2(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_overload_2(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, entry_type="decrement", @@ -1223,8 +1217,8 @@ async def test_method_create_entry_by_external_id_overload_2(self, client: Async assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_by_external_id_with_all_params_overload_2(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_with_all_params_overload_2(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, entry_type="decrement", @@ -1235,8 +1229,8 @@ async def test_method_create_entry_by_external_id_with_all_params_overload_2(sel assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_by_external_id_overload_2(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + async def test_raw_response_create_entry_by_external_id_overload_2(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "string", amount=0, entry_type="decrement", @@ -1248,8 +1242,8 @@ async def test_raw_response_create_entry_by_external_id_overload_2(self, client: assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_by_external_id_overload_2(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( + async def test_streaming_response_create_entry_by_external_id_overload_2(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( "string", amount=0, entry_type="decrement", @@ -1263,17 +1257,17 @@ async def test_streaming_response_create_entry_by_external_id_overload_2(self, c assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_by_external_id_overload_2(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_by_external_id_overload_2(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "", amount=0, entry_type="decrement", ) @parametrize - async def test_method_create_entry_by_external_id_overload_3(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_overload_3(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1282,8 +1276,8 @@ async def test_method_create_entry_by_external_id_overload_3(self, client: Async assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_by_external_id_with_all_params_overload_3(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_with_all_params_overload_3(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1297,8 +1291,8 @@ async def test_method_create_entry_by_external_id_with_all_params_overload_3(sel assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_by_external_id_overload_3(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + async def test_raw_response_create_entry_by_external_id_overload_3(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1311,8 +1305,8 @@ async def test_raw_response_create_entry_by_external_id_overload_3(self, client: assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_by_external_id_overload_3(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( + async def test_streaming_response_create_entry_by_external_id_overload_3(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( "string", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1327,9 +1321,9 @@ async def test_streaming_response_create_entry_by_external_id_overload_3(self, c assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_by_external_id_overload_3(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_by_external_id_overload_3(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "", entry_type="expiration_change", expiry_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1337,8 +1331,8 @@ async def test_path_params_create_entry_by_external_id_overload_3(self, client: ) @parametrize - async def test_method_create_entry_by_external_id_overload_4(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_overload_4(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1347,8 +1341,8 @@ async def test_method_create_entry_by_external_id_overload_4(self, client: Async assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_by_external_id_with_all_params_overload_4(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_with_all_params_overload_4(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1361,8 +1355,8 @@ async def test_method_create_entry_by_external_id_with_all_params_overload_4(sel assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_by_external_id_overload_4(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + async def test_raw_response_create_entry_by_external_id_overload_4(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1375,8 +1369,8 @@ async def test_raw_response_create_entry_by_external_id_overload_4(self, client: assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_by_external_id_overload_4(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( + async def test_streaming_response_create_entry_by_external_id_overload_4(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1391,9 +1385,9 @@ async def test_streaming_response_create_entry_by_external_id_overload_4(self, c assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_by_external_id_overload_4(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_by_external_id_overload_4(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "", amount=0, block_id="string", @@ -1401,8 +1395,8 @@ async def test_path_params_create_entry_by_external_id_overload_4(self, client: ) @parametrize - async def test_method_create_entry_by_external_id_overload_5(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_overload_5(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1411,8 +1405,8 @@ async def test_method_create_entry_by_external_id_overload_5(self, client: Async assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_method_create_entry_by_external_id_with_all_params_overload_5(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.create_entry_by_external_id( + async def test_method_create_entry_by_external_id_with_all_params_overload_5(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1424,8 +1418,8 @@ async def test_method_create_entry_by_external_id_with_all_params_overload_5(sel assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_raw_response_create_entry_by_external_id_overload_5(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + async def test_raw_response_create_entry_by_external_id_overload_5(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1438,8 +1432,8 @@ async def test_raw_response_create_entry_by_external_id_overload_5(self, client: assert_matches_type(LedgerCreateEntryByExternalIDResponse, ledger, path=["response"]) @parametrize - async def test_streaming_response_create_entry_by_external_id_overload_5(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( + async def test_streaming_response_create_entry_by_external_id_overload_5(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.create_entry_by_external_id( "string", amount=0, block_id="string", @@ -1454,9 +1448,9 @@ async def test_streaming_response_create_entry_by_external_id_overload_5(self, c assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_entry_by_external_id_overload_5(self, client: AsyncOrb) -> None: + async def test_path_params_create_entry_by_external_id_overload_5(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.create_entry_by_external_id( "", amount=0, block_id="string", @@ -1464,15 +1458,15 @@ async def test_path_params_create_entry_by_external_id_overload_5(self, client: ) @parametrize - async def test_method_list_by_external_id(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.list_by_external_id( + async def test_method_list_by_external_id(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.list_by_external_id( "string", ) assert_matches_type(AsyncPage[LedgerListByExternalIDResponse], ledger, path=["response"]) @parametrize - async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb) -> None: - ledger = await client.customers.credits.ledger.list_by_external_id( + async def test_method_list_by_external_id_with_all_params(self, async_client: AsyncOrb) -> None: + ledger = await async_client.customers.credits.ledger.list_by_external_id( "string", created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1488,8 +1482,8 @@ async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb assert_matches_type(AsyncPage[LedgerListByExternalIDResponse], ledger, path=["response"]) @parametrize - async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.credits.ledger.with_raw_response.list_by_external_id( + async def test_raw_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.ledger.with_raw_response.list_by_external_id( "string", ) @@ -1499,8 +1493,8 @@ async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[LedgerListByExternalIDResponse], ledger, path=["response"]) @parametrize - async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.credits.ledger.with_streaming_response.list_by_external_id( + async def test_streaming_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.ledger.with_streaming_response.list_by_external_id( "string", ) as response: assert not response.is_closed @@ -1512,8 +1506,8 @@ async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_list_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.ledger.with_raw_response.list_by_external_id( + await async_client.customers.credits.ledger.with_raw_response.list_by_external_id( "", ) diff --git a/tests/api_resources/customers/test_balance_transactions.py b/tests/api_resources/customers/test_balance_transactions.py index 6758542d..e5657fec 100644 --- a/tests/api_resources/customers/test_balance_transactions.py +++ b/tests/api_resources/customers/test_balance_transactions.py @@ -9,7 +9,6 @@ from orb import Orb, AsyncOrb from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage from orb.types.customers import ( @@ -18,13 +17,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestBalanceTransactions: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -135,13 +131,11 @@ def test_path_params_list(self, client: Orb) -> None: class TestAsyncBalanceTransactions: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - balance_transaction = await client.customers.balance_transactions.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + balance_transaction = await async_client.customers.balance_transactions.create( "string", amount="string", type="increment", @@ -149,8 +143,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(BalanceTransactionCreateResponse, balance_transaction, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - balance_transaction = await client.customers.balance_transactions.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + balance_transaction = await async_client.customers.balance_transactions.create( "string", amount="string", type="increment", @@ -159,8 +153,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(BalanceTransactionCreateResponse, balance_transaction, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.customers.balance_transactions.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.balance_transactions.with_raw_response.create( "string", amount="string", type="increment", @@ -172,8 +166,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(BalanceTransactionCreateResponse, balance_transaction, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.customers.balance_transactions.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.customers.balance_transactions.with_streaming_response.create( "string", amount="string", type="increment", @@ -187,24 +181,24 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create(self, client: AsyncOrb) -> None: + async def test_path_params_create(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.balance_transactions.with_raw_response.create( + await async_client.customers.balance_transactions.with_raw_response.create( "", amount="string", type="increment", ) @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - balance_transaction = await client.customers.balance_transactions.list( + async def test_method_list(self, async_client: AsyncOrb) -> None: + balance_transaction = await async_client.customers.balance_transactions.list( "string", ) assert_matches_type(AsyncPage[BalanceTransactionListResponse], balance_transaction, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - balance_transaction = await client.customers.balance_transactions.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + balance_transaction = await async_client.customers.balance_transactions.list( "string", cursor="string", limit=0, @@ -216,8 +210,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[BalanceTransactionListResponse], balance_transaction, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.customers.balance_transactions.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.balance_transactions.with_raw_response.list( "string", ) @@ -227,8 +221,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[BalanceTransactionListResponse], balance_transaction, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.customers.balance_transactions.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.customers.balance_transactions.with_streaming_response.list( "string", ) as response: assert not response.is_closed @@ -240,8 +234,8 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list(self, client: AsyncOrb) -> None: + async def test_path_params_list(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.balance_transactions.with_raw_response.list( + await async_client.customers.balance_transactions.with_raw_response.list( "", ) diff --git a/tests/api_resources/customers/test_costs.py b/tests/api_resources/customers/test_costs.py index 27120b8d..5837cbf5 100644 --- a/tests/api_resources/customers/test_costs.py +++ b/tests/api_resources/customers/test_costs.py @@ -9,7 +9,6 @@ from orb import Orb, AsyncOrb from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.types.customers import ( CostListResponse, @@ -17,13 +16,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestCosts: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -125,20 +121,18 @@ def test_path_params_list_by_external_id(self, client: Orb) -> None: class TestAsyncCosts: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - cost = await client.customers.costs.list( + async def test_method_list(self, async_client: AsyncOrb) -> None: + cost = await async_client.customers.costs.list( "string", ) assert_matches_type(CostListResponse, cost, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - cost = await client.customers.costs.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + cost = await async_client.customers.costs.list( "string", group_by="string", timeframe_end=parse_datetime("2022-03-01T05:00:00Z"), @@ -148,8 +142,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(CostListResponse, cost, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.customers.costs.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.costs.with_raw_response.list( "string", ) @@ -159,8 +153,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(CostListResponse, cost, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.customers.costs.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.customers.costs.with_streaming_response.list( "string", ) as response: assert not response.is_closed @@ -172,22 +166,22 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list(self, client: AsyncOrb) -> None: + async def test_path_params_list(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.costs.with_raw_response.list( + await async_client.customers.costs.with_raw_response.list( "", ) @parametrize - async def test_method_list_by_external_id(self, client: AsyncOrb) -> None: - cost = await client.customers.costs.list_by_external_id( + async def test_method_list_by_external_id(self, async_client: AsyncOrb) -> None: + cost = await async_client.customers.costs.list_by_external_id( "string", ) assert_matches_type(CostListByExternalIDResponse, cost, path=["response"]) @parametrize - async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb) -> None: - cost = await client.customers.costs.list_by_external_id( + async def test_method_list_by_external_id_with_all_params(self, async_client: AsyncOrb) -> None: + cost = await async_client.customers.costs.list_by_external_id( "string", group_by="string", timeframe_end=parse_datetime("2022-03-01T05:00:00Z"), @@ -197,8 +191,8 @@ async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb assert_matches_type(CostListByExternalIDResponse, cost, path=["response"]) @parametrize - async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.costs.with_raw_response.list_by_external_id( + async def test_raw_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.costs.with_raw_response.list_by_external_id( "string", ) @@ -208,8 +202,8 @@ async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: assert_matches_type(CostListByExternalIDResponse, cost, path=["response"]) @parametrize - async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.costs.with_streaming_response.list_by_external_id( + async def test_streaming_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.costs.with_streaming_response.list_by_external_id( "string", ) as response: assert not response.is_closed @@ -221,8 +215,8 @@ async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_list_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.costs.with_raw_response.list_by_external_id( + await async_client.customers.costs.with_raw_response.list_by_external_id( "", ) diff --git a/tests/api_resources/customers/test_credits.py b/tests/api_resources/customers/test_credits.py index 768b5cd5..11ca278d 100644 --- a/tests/api_resources/customers/test_credits.py +++ b/tests/api_resources/customers/test_credits.py @@ -8,7 +8,6 @@ import pytest from orb import Orb, AsyncOrb -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage from orb.types.customers import ( @@ -17,13 +16,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestCredits: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -123,20 +119,18 @@ def test_path_params_list_by_external_id(self, client: Orb) -> None: class TestAsyncCredits: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - credit = await client.customers.credits.list( + async def test_method_list(self, async_client: AsyncOrb) -> None: + credit = await async_client.customers.credits.list( "string", ) assert_matches_type(AsyncPage[CreditListResponse], credit, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - credit = await client.customers.credits.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + credit = await async_client.customers.credits.list( "string", currency="string", cursor="string", @@ -145,8 +139,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[CreditListResponse], credit, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.customers.credits.with_raw_response.list( + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.with_raw_response.list( "string", ) @@ -156,8 +150,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[CreditListResponse], credit, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.customers.credits.with_streaming_response.list( + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.with_streaming_response.list( "string", ) as response: assert not response.is_closed @@ -169,22 +163,22 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list(self, client: AsyncOrb) -> None: + async def test_path_params_list(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.credits.with_raw_response.list( + await async_client.customers.credits.with_raw_response.list( "", ) @parametrize - async def test_method_list_by_external_id(self, client: AsyncOrb) -> None: - credit = await client.customers.credits.list_by_external_id( + async def test_method_list_by_external_id(self, async_client: AsyncOrb) -> None: + credit = await async_client.customers.credits.list_by_external_id( "string", ) assert_matches_type(AsyncPage[CreditListByExternalIDResponse], credit, path=["response"]) @parametrize - async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb) -> None: - credit = await client.customers.credits.list_by_external_id( + async def test_method_list_by_external_id_with_all_params(self, async_client: AsyncOrb) -> None: + credit = await async_client.customers.credits.list_by_external_id( "string", currency="string", cursor="string", @@ -193,8 +187,8 @@ async def test_method_list_by_external_id_with_all_params(self, client: AsyncOrb assert_matches_type(AsyncPage[CreditListByExternalIDResponse], credit, path=["response"]) @parametrize - async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.credits.with_raw_response.list_by_external_id( + async def test_raw_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.credits.with_raw_response.list_by_external_id( "string", ) @@ -204,8 +198,8 @@ async def test_raw_response_list_by_external_id(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[CreditListByExternalIDResponse], credit, path=["response"]) @parametrize - async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.credits.with_streaming_response.list_by_external_id( + async def test_streaming_response_list_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.credits.with_streaming_response.list_by_external_id( "string", ) as response: assert not response.is_closed @@ -217,8 +211,8 @@ async def test_streaming_response_list_by_external_id(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_list_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_list_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.credits.with_raw_response.list_by_external_id( + await async_client.customers.credits.with_raw_response.list_by_external_id( "", ) diff --git a/tests/api_resources/customers/test_usage.py b/tests/api_resources/customers/test_usage.py index 2d96c522..8eae823f 100644 --- a/tests/api_resources/customers/test_usage.py +++ b/tests/api_resources/customers/test_usage.py @@ -9,7 +9,6 @@ from orb import Orb, AsyncOrb from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.types.customers import ( UsageUpdateResponse, @@ -17,13 +16,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestUsage: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -303,13 +299,11 @@ def test_path_params_update_by_external_id(self, client: Orb) -> None: class TestAsyncUsage: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - usage = await client.customers.usage.update( + async def test_method_update(self, async_client: AsyncOrb) -> None: + usage = await async_client.customers.usage.update( "string", events=[ { @@ -332,8 +326,8 @@ async def test_method_update(self, client: AsyncOrb) -> None: assert_matches_type(UsageUpdateResponse, usage, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: - usage = await client.customers.usage.update( + async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> None: + usage = await async_client.customers.usage.update( "string", events=[ { @@ -364,8 +358,8 @@ async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(UsageUpdateResponse, usage, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncOrb) -> None: - response = await client.customers.usage.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.usage.with_raw_response.update( "string", events=[ { @@ -392,8 +386,8 @@ async def test_raw_response_update(self, client: AsyncOrb) -> None: assert_matches_type(UsageUpdateResponse, usage, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncOrb) -> None: - async with client.customers.usage.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncOrb) -> None: + async with async_client.customers.usage.with_streaming_response.update( "string", events=[ { @@ -422,9 +416,9 @@ async def test_streaming_response_update(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncOrb) -> None: + async def test_path_params_update(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await client.customers.usage.with_raw_response.update( + await async_client.customers.usage.with_raw_response.update( "", events=[ { @@ -446,8 +440,8 @@ async def test_path_params_update(self, client: AsyncOrb) -> None: ) @parametrize - async def test_method_update_by_external_id(self, client: AsyncOrb) -> None: - usage = await client.customers.usage.update_by_external_id( + async def test_method_update_by_external_id(self, async_client: AsyncOrb) -> None: + usage = await async_client.customers.usage.update_by_external_id( "string", events=[ { @@ -470,8 +464,8 @@ async def test_method_update_by_external_id(self, client: AsyncOrb) -> None: assert_matches_type(UsageUpdateByExternalIDResponse, usage, path=["response"]) @parametrize - async def test_method_update_by_external_id_with_all_params(self, client: AsyncOrb) -> None: - usage = await client.customers.usage.update_by_external_id( + async def test_method_update_by_external_id_with_all_params(self, async_client: AsyncOrb) -> None: + usage = await async_client.customers.usage.update_by_external_id( "string", events=[ { @@ -502,8 +496,8 @@ async def test_method_update_by_external_id_with_all_params(self, client: AsyncO assert_matches_type(UsageUpdateByExternalIDResponse, usage, path=["response"]) @parametrize - async def test_raw_response_update_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.usage.with_raw_response.update_by_external_id( + async def test_raw_response_update_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.usage.with_raw_response.update_by_external_id( "string", events=[ { @@ -530,8 +524,8 @@ async def test_raw_response_update_by_external_id(self, client: AsyncOrb) -> Non assert_matches_type(UsageUpdateByExternalIDResponse, usage, path=["response"]) @parametrize - async def test_streaming_response_update_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.usage.with_streaming_response.update_by_external_id( + async def test_streaming_response_update_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.usage.with_streaming_response.update_by_external_id( "string", events=[ { @@ -560,9 +554,9 @@ async def test_streaming_response_update_by_external_id(self, client: AsyncOrb) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_update_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await client.customers.usage.with_raw_response.update_by_external_id( + await async_client.customers.usage.with_raw_response.update_by_external_id( "", events=[ { diff --git a/tests/api_resources/events/test_backfills.py b/tests/api_resources/events/test_backfills.py index cf3535f5..f5df9fdf 100644 --- a/tests/api_resources/events/test_backfills.py +++ b/tests/api_resources/events/test_backfills.py @@ -9,7 +9,6 @@ from orb import Orb, AsyncOrb from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage from orb.types.events import ( @@ -21,13 +20,10 @@ ) base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestBackfills: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -224,21 +220,19 @@ def test_path_params_revert(self, client: Orb) -> None: class TestAsyncBackfills: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - backfill = await client.events.backfills.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.create( timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), ) assert_matches_type(BackfillCreateResponse, backfill, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.create( timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), close_time=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -249,8 +243,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(BackfillCreateResponse, backfill, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.events.backfills.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.events.backfills.with_raw_response.create( timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), ) @@ -261,8 +255,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(BackfillCreateResponse, backfill, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.events.backfills.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.events.backfills.with_streaming_response.create( timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), ) as response: @@ -275,21 +269,21 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.list() assert_matches_type(AsyncPage[BackfillListResponse], backfill, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.list( cursor="string", limit=0, ) assert_matches_type(AsyncPage[BackfillListResponse], backfill, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.events.backfills.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.events.backfills.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -297,8 +291,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[BackfillListResponse], backfill, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.events.backfills.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.events.backfills.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -308,15 +302,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_close(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.close( + async def test_method_close(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.close( "string", ) assert_matches_type(BackfillCloseResponse, backfill, path=["response"]) @parametrize - async def test_raw_response_close(self, client: AsyncOrb) -> None: - response = await client.events.backfills.with_raw_response.close( + async def test_raw_response_close(self, async_client: AsyncOrb) -> None: + response = await async_client.events.backfills.with_raw_response.close( "string", ) @@ -326,8 +320,8 @@ async def test_raw_response_close(self, client: AsyncOrb) -> None: assert_matches_type(BackfillCloseResponse, backfill, path=["response"]) @parametrize - async def test_streaming_response_close(self, client: AsyncOrb) -> None: - async with client.events.backfills.with_streaming_response.close( + async def test_streaming_response_close(self, async_client: AsyncOrb) -> None: + async with async_client.events.backfills.with_streaming_response.close( "string", ) as response: assert not response.is_closed @@ -339,22 +333,22 @@ async def test_streaming_response_close(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_close(self, client: AsyncOrb) -> None: + async def test_path_params_close(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `backfill_id` but received ''"): - await client.events.backfills.with_raw_response.close( + await async_client.events.backfills.with_raw_response.close( "", ) @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.fetch( "string", ) assert_matches_type(BackfillFetchResponse, backfill, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.events.backfills.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.events.backfills.with_raw_response.fetch( "string", ) @@ -364,8 +358,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(BackfillFetchResponse, backfill, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.events.backfills.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.events.backfills.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -377,22 +371,22 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `backfill_id` but received ''"): - await client.events.backfills.with_raw_response.fetch( + await async_client.events.backfills.with_raw_response.fetch( "", ) @parametrize - async def test_method_revert(self, client: AsyncOrb) -> None: - backfill = await client.events.backfills.revert( + async def test_method_revert(self, async_client: AsyncOrb) -> None: + backfill = await async_client.events.backfills.revert( "string", ) assert_matches_type(BackfillRevertResponse, backfill, path=["response"]) @parametrize - async def test_raw_response_revert(self, client: AsyncOrb) -> None: - response = await client.events.backfills.with_raw_response.revert( + async def test_raw_response_revert(self, async_client: AsyncOrb) -> None: + response = await async_client.events.backfills.with_raw_response.revert( "string", ) @@ -402,8 +396,8 @@ async def test_raw_response_revert(self, client: AsyncOrb) -> None: assert_matches_type(BackfillRevertResponse, backfill, path=["response"]) @parametrize - async def test_streaming_response_revert(self, client: AsyncOrb) -> None: - async with client.events.backfills.with_streaming_response.revert( + async def test_streaming_response_revert(self, async_client: AsyncOrb) -> None: + async with async_client.events.backfills.with_streaming_response.revert( "string", ) as response: assert not response.is_closed @@ -415,8 +409,8 @@ async def test_streaming_response_revert(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_revert(self, client: AsyncOrb) -> None: + async def test_path_params_revert(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `backfill_id` but received ''"): - await client.events.backfills.with_raw_response.revert( + await async_client.events.backfills.with_raw_response.revert( "", ) diff --git a/tests/api_resources/plans/test_external_plan_id.py b/tests/api_resources/plans/test_external_plan_id.py index 502b1232..af69bc6c 100644 --- a/tests/api_resources/plans/test_external_plan_id.py +++ b/tests/api_resources/plans/test_external_plan_id.py @@ -9,17 +9,13 @@ from orb import Orb, AsyncOrb from orb.types import Plan -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestExternalPlanID: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -111,20 +107,18 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncExternalPlanID: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - external_plan_id = await client.plans.external_plan_id.update( + async def test_method_update(self, async_client: AsyncOrb) -> None: + external_plan_id = await async_client.plans.external_plan_id.update( "string", ) assert_matches_type(Plan, external_plan_id, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: - external_plan_id = await client.plans.external_plan_id.update( + async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> None: + external_plan_id = await async_client.plans.external_plan_id.update( "string", external_plan_id="string", metadata={"foo": "string"}, @@ -132,8 +126,8 @@ async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Plan, external_plan_id, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncOrb) -> None: - response = await client.plans.external_plan_id.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.external_plan_id.with_raw_response.update( "string", ) @@ -143,8 +137,8 @@ async def test_raw_response_update(self, client: AsyncOrb) -> None: assert_matches_type(Plan, external_plan_id, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncOrb) -> None: - async with client.plans.external_plan_id.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncOrb) -> None: + async with async_client.plans.external_plan_id.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -156,25 +150,25 @@ async def test_streaming_response_update(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncOrb) -> None: + async def test_path_params_update(self, async_client: AsyncOrb) -> None: with pytest.raises( ValueError, match=r"Expected a non-empty value for `other_external_plan_id` but received ''" ): - await client.plans.external_plan_id.with_raw_response.update( + await async_client.plans.external_plan_id.with_raw_response.update( "", external_plan_id="", ) @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - external_plan_id = await client.plans.external_plan_id.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + external_plan_id = await async_client.plans.external_plan_id.fetch( "string", ) assert_matches_type(Plan, external_plan_id, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.plans.external_plan_id.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.external_plan_id.with_raw_response.fetch( "string", ) @@ -184,8 +178,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Plan, external_plan_id, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.plans.external_plan_id.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.plans.external_plan_id.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -197,8 +191,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_plan_id` but received ''"): - await client.plans.external_plan_id.with_raw_response.fetch( + await async_client.plans.external_plan_id.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/prices/test_external_price_id.py b/tests/api_resources/prices/test_external_price_id.py index ffcbf793..dcdffa7a 100644 --- a/tests/api_resources/prices/test_external_price_id.py +++ b/tests/api_resources/prices/test_external_price_id.py @@ -9,17 +9,13 @@ from orb import Orb, AsyncOrb from orb.types import Price -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestExternalPriceID: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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_fetch(self, client: Orb) -> None: @@ -61,20 +57,18 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncExternalPriceID: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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_fetch(self, client: AsyncOrb) -> None: - external_price_id = await client.prices.external_price_id.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + external_price_id = await async_client.prices.external_price_id.fetch( "string", ) assert_matches_type(Price, external_price_id, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.prices.external_price_id.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.external_price_id.with_raw_response.fetch( "string", ) @@ -84,8 +78,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Price, external_price_id, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.prices.external_price_id.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.prices.external_price_id.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -97,8 +91,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_price_id` but received ''"): - await client.prices.external_price_id.with_raw_response.fetch( + await async_client.prices.external_price_id.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_coupons.py b/tests/api_resources/test_coupons.py index 082d0f3b..de10f9ee 100644 --- a/tests/api_resources/test_coupons.py +++ b/tests/api_resources/test_coupons.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb.types import Coupon -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestCoupons: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -196,13 +192,11 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncCoupons: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - coupon = await client.coupons.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.create( discount={ "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], @@ -213,8 +207,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - coupon = await client.coupons.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.create( discount={ "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], @@ -228,8 +222,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.coupons.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.coupons.with_raw_response.create( discount={ "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], @@ -244,8 +238,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.coupons.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.coupons.with_streaming_response.create( discount={ "discount_type": "percentage", "applies_to_price_ids": ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], @@ -262,13 +256,13 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - coupon = await client.coupons.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.list() assert_matches_type(AsyncPage[Coupon], coupon, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - coupon = await client.coupons.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.list( cursor="string", limit=0, redemption_code="string", @@ -277,8 +271,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Coupon], coupon, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.coupons.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.coupons.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -286,8 +280,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Coupon], coupon, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.coupons.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.coupons.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -297,15 +291,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_archive(self, client: AsyncOrb) -> None: - coupon = await client.coupons.archive( + async def test_method_archive(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.archive( "string", ) assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_raw_response_archive(self, client: AsyncOrb) -> None: - response = await client.coupons.with_raw_response.archive( + async def test_raw_response_archive(self, async_client: AsyncOrb) -> None: + response = await async_client.coupons.with_raw_response.archive( "string", ) @@ -315,8 +309,8 @@ async def test_raw_response_archive(self, client: AsyncOrb) -> None: assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_streaming_response_archive(self, client: AsyncOrb) -> None: - async with client.coupons.with_streaming_response.archive( + async def test_streaming_response_archive(self, async_client: AsyncOrb) -> None: + async with async_client.coupons.with_streaming_response.archive( "string", ) as response: assert not response.is_closed @@ -328,22 +322,22 @@ async def test_streaming_response_archive(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_archive(self, client: AsyncOrb) -> None: + async def test_path_params_archive(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `coupon_id` but received ''"): - await client.coupons.with_raw_response.archive( + await async_client.coupons.with_raw_response.archive( "", ) @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - coupon = await client.coupons.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + coupon = await async_client.coupons.fetch( "string", ) assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.coupons.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.coupons.with_raw_response.fetch( "string", ) @@ -353,8 +347,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Coupon, coupon, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.coupons.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.coupons.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -366,8 +360,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `coupon_id` but received ''"): - await client.coupons.with_raw_response.fetch( + await async_client.coupons.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_credit_notes.py b/tests/api_resources/test_credit_notes.py index 78bbabcb..7ffa8fce 100644 --- a/tests/api_resources/test_credit_notes.py +++ b/tests/api_resources/test_credit_notes.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb.types import CreditNote -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestCreditNotes: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -95,26 +91,24 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncCreditNotes: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - credit_note = await client.credit_notes.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + credit_note = await async_client.credit_notes.list() assert_matches_type(AsyncPage[CreditNote], credit_note, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - credit_note = await client.credit_notes.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + credit_note = await async_client.credit_notes.list( cursor="string", limit=0, ) assert_matches_type(AsyncPage[CreditNote], credit_note, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.credit_notes.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.credit_notes.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -122,8 +116,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[CreditNote], credit_note, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.credit_notes.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.credit_notes.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -133,15 +127,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - credit_note = await client.credit_notes.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + credit_note = await async_client.credit_notes.fetch( "string", ) assert_matches_type(CreditNote, credit_note, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.credit_notes.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.credit_notes.with_raw_response.fetch( "string", ) @@ -151,8 +145,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(CreditNote, credit_note, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.credit_notes.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.credit_notes.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -164,8 +158,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `credit_note_id` but received ''"): - await client.credit_notes.with_raw_response.fetch( + await async_client.credit_notes.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_customers.py b/tests/api_resources/test_customers.py index 7816a974..1e0fbc87 100644 --- a/tests/api_resources/test_customers.py +++ b/tests/api_resources/test_customers.py @@ -12,18 +12,14 @@ Customer, ) from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestCustomers: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -454,21 +450,19 @@ def test_path_params_update_by_external_id(self, client: Orb) -> None: class TestAsyncCustomers: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - customer = await client.customers.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.create( email="string", name="string", ) assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - customer = await client.customers.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.create( email="string", name="string", accounting_sync_configuration={ @@ -523,8 +517,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.create( email="string", name="string", ) @@ -535,8 +529,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.create( email="string", name="string", ) as response: @@ -549,15 +543,15 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_update(self, client: AsyncOrb) -> None: - customer = await client.customers.update( + async def test_method_update(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.update( "string", ) assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: - customer = await client.customers.update( + async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.update( "string", accounting_sync_configuration={ "excluded": True, @@ -611,8 +605,8 @@ async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.update( "string", ) @@ -622,8 +616,8 @@ async def test_raw_response_update(self, client: AsyncOrb) -> None: assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -635,20 +629,20 @@ async def test_streaming_response_update(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncOrb) -> None: + async def test_path_params_update(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.with_raw_response.update( + await async_client.customers.with_raw_response.update( "", ) @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - customer = await client.customers.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.list() assert_matches_type(AsyncPage[Customer], customer, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - customer = await client.customers.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.list( created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -659,8 +653,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Customer], customer, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -668,8 +662,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Customer], customer, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -679,15 +673,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_delete(self, client: AsyncOrb) -> None: - customer = await client.customers.delete( + async def test_method_delete(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.delete( "string", ) assert customer is None @parametrize - async def test_raw_response_delete(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.delete( + async def test_raw_response_delete(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.delete( "string", ) @@ -697,8 +691,8 @@ async def test_raw_response_delete(self, client: AsyncOrb) -> None: assert customer is None @parametrize - async def test_streaming_response_delete(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.delete( + async def test_streaming_response_delete(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.delete( "string", ) as response: assert not response.is_closed @@ -710,22 +704,22 @@ async def test_streaming_response_delete(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_delete(self, client: AsyncOrb) -> None: + async def test_path_params_delete(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.with_raw_response.delete( + await async_client.customers.with_raw_response.delete( "", ) @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - customer = await client.customers.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.fetch( "string", ) assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.fetch( "string", ) @@ -735,8 +729,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -748,22 +742,22 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `customer_id` but received ''"): - await client.customers.with_raw_response.fetch( + await async_client.customers.with_raw_response.fetch( "", ) @parametrize - async def test_method_fetch_by_external_id(self, client: AsyncOrb) -> None: - customer = await client.customers.fetch_by_external_id( + async def test_method_fetch_by_external_id(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.fetch_by_external_id( "string", ) assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_raw_response_fetch_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.fetch_by_external_id( + async def test_raw_response_fetch_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.fetch_by_external_id( "string", ) @@ -773,8 +767,8 @@ async def test_raw_response_fetch_by_external_id(self, client: AsyncOrb) -> None assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_streaming_response_fetch_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.fetch_by_external_id( + async def test_streaming_response_fetch_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.fetch_by_external_id( "string", ) as response: assert not response.is_closed @@ -786,22 +780,22 @@ async def test_streaming_response_fetch_by_external_id(self, client: AsyncOrb) - assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_fetch_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `external_customer_id` but received ''"): - await client.customers.with_raw_response.fetch_by_external_id( + await async_client.customers.with_raw_response.fetch_by_external_id( "", ) @parametrize - async def test_method_update_by_external_id(self, client: AsyncOrb) -> None: - customer = await client.customers.update_by_external_id( + async def test_method_update_by_external_id(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.update_by_external_id( "string", ) assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_method_update_by_external_id_with_all_params(self, client: AsyncOrb) -> None: - customer = await client.customers.update_by_external_id( + async def test_method_update_by_external_id_with_all_params(self, async_client: AsyncOrb) -> None: + customer = await async_client.customers.update_by_external_id( "string", accounting_sync_configuration={ "excluded": True, @@ -855,8 +849,8 @@ async def test_method_update_by_external_id_with_all_params(self, client: AsyncO assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_raw_response_update_by_external_id(self, client: AsyncOrb) -> None: - response = await client.customers.with_raw_response.update_by_external_id( + async def test_raw_response_update_by_external_id(self, async_client: AsyncOrb) -> None: + response = await async_client.customers.with_raw_response.update_by_external_id( "string", ) @@ -866,8 +860,8 @@ async def test_raw_response_update_by_external_id(self, client: AsyncOrb) -> Non assert_matches_type(Customer, customer, path=["response"]) @parametrize - async def test_streaming_response_update_by_external_id(self, client: AsyncOrb) -> None: - async with client.customers.with_streaming_response.update_by_external_id( + async def test_streaming_response_update_by_external_id(self, async_client: AsyncOrb) -> None: + async with async_client.customers.with_streaming_response.update_by_external_id( "string", ) as response: assert not response.is_closed @@ -879,8 +873,8 @@ async def test_streaming_response_update_by_external_id(self, client: AsyncOrb) assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update_by_external_id(self, client: AsyncOrb) -> None: + async def test_path_params_update_by_external_id(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): - await client.customers.with_raw_response.update_by_external_id( + await async_client.customers.with_raw_response.update_by_external_id( "", ) diff --git a/tests/api_resources/test_events.py b/tests/api_resources/test_events.py index c74b21c2..924cbe09 100644 --- a/tests/api_resources/test_events.py +++ b/tests/api_resources/test_events.py @@ -15,17 +15,13 @@ EventDeprecateResponse, ) from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestEvents: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -291,13 +287,11 @@ def test_streaming_response_search(self, client: Orb) -> None: class TestAsyncEvents: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - event = await client.events.update( + async def test_method_update(self, async_client: AsyncOrb) -> None: + event = await async_client.events.update( "string", event_name="string", properties={}, @@ -306,8 +300,8 @@ async def test_method_update(self, client: AsyncOrb) -> None: assert_matches_type(EventUpdateResponse, event, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: - event = await client.events.update( + async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> None: + event = await async_client.events.update( "string", event_name="string", properties={}, @@ -318,8 +312,8 @@ async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(EventUpdateResponse, event, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncOrb) -> None: - response = await client.events.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncOrb) -> None: + response = await async_client.events.with_raw_response.update( "string", event_name="string", properties={}, @@ -332,8 +326,8 @@ async def test_raw_response_update(self, client: AsyncOrb) -> None: assert_matches_type(EventUpdateResponse, event, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncOrb) -> None: - async with client.events.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncOrb) -> None: + async with async_client.events.with_streaming_response.update( "string", event_name="string", properties={}, @@ -348,9 +342,9 @@ async def test_streaming_response_update(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncOrb) -> None: + async def test_path_params_update(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): - await client.events.with_raw_response.update( + await async_client.events.with_raw_response.update( "", event_name="string", properties={}, @@ -358,15 +352,15 @@ async def test_path_params_update(self, client: AsyncOrb) -> None: ) @parametrize - async def test_method_deprecate(self, client: AsyncOrb) -> None: - event = await client.events.deprecate( + async def test_method_deprecate(self, async_client: AsyncOrb) -> None: + event = await async_client.events.deprecate( "string", ) assert_matches_type(EventDeprecateResponse, event, path=["response"]) @parametrize - async def test_raw_response_deprecate(self, client: AsyncOrb) -> None: - response = await client.events.with_raw_response.deprecate( + async def test_raw_response_deprecate(self, async_client: AsyncOrb) -> None: + response = await async_client.events.with_raw_response.deprecate( "string", ) @@ -376,8 +370,8 @@ async def test_raw_response_deprecate(self, client: AsyncOrb) -> None: assert_matches_type(EventDeprecateResponse, event, path=["response"]) @parametrize - async def test_streaming_response_deprecate(self, client: AsyncOrb) -> None: - async with client.events.with_streaming_response.deprecate( + async def test_streaming_response_deprecate(self, async_client: AsyncOrb) -> None: + async with async_client.events.with_streaming_response.deprecate( "string", ) as response: assert not response.is_closed @@ -389,15 +383,15 @@ async def test_streaming_response_deprecate(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_deprecate(self, client: AsyncOrb) -> None: + async def test_path_params_deprecate(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `event_id` but received ''"): - await client.events.with_raw_response.deprecate( + await async_client.events.with_raw_response.deprecate( "", ) @parametrize - async def test_method_ingest(self, client: AsyncOrb) -> None: - event = await client.events.ingest( + async def test_method_ingest(self, async_client: AsyncOrb) -> None: + event = await async_client.events.ingest( events=[ { "event_name": "string", @@ -422,8 +416,8 @@ async def test_method_ingest(self, client: AsyncOrb) -> None: assert_matches_type(EventIngestResponse, event, path=["response"]) @parametrize - async def test_method_ingest_with_all_params(self, client: AsyncOrb) -> None: - event = await client.events.ingest( + async def test_method_ingest_with_all_params(self, async_client: AsyncOrb) -> None: + event = await async_client.events.ingest( events=[ { "customer_id": "string", @@ -456,8 +450,8 @@ async def test_method_ingest_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(EventIngestResponse, event, path=["response"]) @parametrize - async def test_raw_response_ingest(self, client: AsyncOrb) -> None: - response = await client.events.with_raw_response.ingest( + async def test_raw_response_ingest(self, async_client: AsyncOrb) -> None: + response = await async_client.events.with_raw_response.ingest( events=[ { "event_name": "string", @@ -486,8 +480,8 @@ async def test_raw_response_ingest(self, client: AsyncOrb) -> None: assert_matches_type(EventIngestResponse, event, path=["response"]) @parametrize - async def test_streaming_response_ingest(self, client: AsyncOrb) -> None: - async with client.events.with_streaming_response.ingest( + async def test_streaming_response_ingest(self, async_client: AsyncOrb) -> None: + async with async_client.events.with_streaming_response.ingest( events=[ { "event_name": "string", @@ -518,15 +512,15 @@ async def test_streaming_response_ingest(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_search(self, client: AsyncOrb) -> None: - event = await client.events.search( + async def test_method_search(self, async_client: AsyncOrb) -> None: + event = await async_client.events.search( event_ids=["string"], ) assert_matches_type(EventSearchResponse, event, path=["response"]) @parametrize - async def test_method_search_with_all_params(self, client: AsyncOrb) -> None: - event = await client.events.search( + async def test_method_search_with_all_params(self, async_client: AsyncOrb) -> None: + event = await async_client.events.search( event_ids=["string"], timeframe_end=parse_datetime("2019-12-27T18:11:19.117Z"), timeframe_start=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -534,8 +528,8 @@ async def test_method_search_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(EventSearchResponse, event, path=["response"]) @parametrize - async def test_raw_response_search(self, client: AsyncOrb) -> None: - response = await client.events.with_raw_response.search( + async def test_raw_response_search(self, async_client: AsyncOrb) -> None: + response = await async_client.events.with_raw_response.search( event_ids=["string"], ) @@ -545,8 +539,8 @@ async def test_raw_response_search(self, client: AsyncOrb) -> None: assert_matches_type(EventSearchResponse, event, path=["response"]) @parametrize - async def test_streaming_response_search(self, client: AsyncOrb) -> None: - async with client.events.with_streaming_response.search( + async def test_streaming_response_search(self, async_client: AsyncOrb) -> None: + async with async_client.events.with_streaming_response.search( event_ids=["string"], ) as response: assert not response.is_closed diff --git a/tests/api_resources/test_invoice_line_items.py b/tests/api_resources/test_invoice_line_items.py index 2f8c8e74..e3a04d1f 100644 --- a/tests/api_resources/test_invoice_line_items.py +++ b/tests/api_resources/test_invoice_line_items.py @@ -10,17 +10,13 @@ from orb import Orb, AsyncOrb from orb.types import InvoiceLineItemCreateResponse from orb._utils import parse_date -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestInvoiceLineItems: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -70,13 +66,11 @@ def test_streaming_response_create(self, client: Orb) -> None: class TestAsyncInvoiceLineItems: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - invoice_line_item = await client.invoice_line_items.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + invoice_line_item = await async_client.invoice_line_items.create( amount="12.00", end_date=parse_date("2023-09-22"), invoice_id="4khy3nwzktxv7", @@ -87,8 +81,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(InvoiceLineItemCreateResponse, invoice_line_item, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.invoice_line_items.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.invoice_line_items.with_raw_response.create( amount="12.00", end_date=parse_date("2023-09-22"), invoice_id="4khy3nwzktxv7", @@ -103,8 +97,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(InvoiceLineItemCreateResponse, invoice_line_item, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.invoice_line_items.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.invoice_line_items.with_streaming_response.create( amount="12.00", end_date=parse_date("2023-09-22"), invoice_id="4khy3nwzktxv7", diff --git a/tests/api_resources/test_invoices.py b/tests/api_resources/test_invoices.py index dfa280a4..1cf44ef7 100644 --- a/tests/api_resources/test_invoices.py +++ b/tests/api_resources/test_invoices.py @@ -13,18 +13,14 @@ InvoiceFetchUpcomingResponse, ) from orb._utils import parse_date, parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestInvoices: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -449,13 +445,11 @@ def test_path_params_void(self, client: Orb) -> None: class TestAsyncInvoices: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - invoice = await client.invoices.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.create( currency="USD", invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ @@ -492,8 +486,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - invoice = await client.invoices.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.create( currency="USD", invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ @@ -543,8 +537,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.create( currency="USD", invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ @@ -585,8 +579,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.create( currency="USD", invoice_date=parse_datetime("2019-12-27T18:11:19.117Z"), line_items=[ @@ -629,13 +623,13 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - invoice = await client.invoices.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.list() assert_matches_type(AsyncPage[Invoice], invoice, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - invoice = await client.invoices.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.list( amount="string", amount_gt="string", amount_lt="string", @@ -659,8 +653,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Invoice], invoice, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -668,8 +662,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Invoice], invoice, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -679,15 +673,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - invoice = await client.invoices.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.fetch( "string", ) assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.fetch( "string", ) @@ -697,8 +691,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -710,27 +704,27 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"): - await client.invoices.with_raw_response.fetch( + await async_client.invoices.with_raw_response.fetch( "", ) @parametrize - async def test_method_fetch_upcoming(self, client: AsyncOrb) -> None: - invoice = await client.invoices.fetch_upcoming() + async def test_method_fetch_upcoming(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.fetch_upcoming() assert_matches_type(InvoiceFetchUpcomingResponse, invoice, path=["response"]) @parametrize - async def test_method_fetch_upcoming_with_all_params(self, client: AsyncOrb) -> None: - invoice = await client.invoices.fetch_upcoming( + async def test_method_fetch_upcoming_with_all_params(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.fetch_upcoming( subscription_id="string", ) assert_matches_type(InvoiceFetchUpcomingResponse, invoice, path=["response"]) @parametrize - async def test_raw_response_fetch_upcoming(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.fetch_upcoming() + async def test_raw_response_fetch_upcoming(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.fetch_upcoming() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -738,8 +732,8 @@ async def test_raw_response_fetch_upcoming(self, client: AsyncOrb) -> None: assert_matches_type(InvoiceFetchUpcomingResponse, invoice, path=["response"]) @parametrize - async def test_streaming_response_fetch_upcoming(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.fetch_upcoming() as response: + async def test_streaming_response_fetch_upcoming(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.fetch_upcoming() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -749,15 +743,15 @@ async def test_streaming_response_fetch_upcoming(self, client: AsyncOrb) -> None assert cast(Any, response.is_closed) is True @parametrize - async def test_method_issue(self, client: AsyncOrb) -> None: - invoice = await client.invoices.issue( + async def test_method_issue(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.issue( "string", ) assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_raw_response_issue(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.issue( + async def test_raw_response_issue(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.issue( "string", ) @@ -767,8 +761,8 @@ async def test_raw_response_issue(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_streaming_response_issue(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.issue( + async def test_streaming_response_issue(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.issue( "string", ) as response: assert not response.is_closed @@ -780,15 +774,15 @@ async def test_streaming_response_issue(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_issue(self, client: AsyncOrb) -> None: + async def test_path_params_issue(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"): - await client.invoices.with_raw_response.issue( + await async_client.invoices.with_raw_response.issue( "", ) @parametrize - async def test_method_mark_paid(self, client: AsyncOrb) -> None: - invoice = await client.invoices.mark_paid( + async def test_method_mark_paid(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.mark_paid( "string", external_id="external_payment_id_123", notes="string", @@ -797,8 +791,8 @@ async def test_method_mark_paid(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_raw_response_mark_paid(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.mark_paid( + async def test_raw_response_mark_paid(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.mark_paid( "string", external_id="external_payment_id_123", notes="string", @@ -811,8 +805,8 @@ async def test_raw_response_mark_paid(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_streaming_response_mark_paid(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.mark_paid( + async def test_streaming_response_mark_paid(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.mark_paid( "string", external_id="external_payment_id_123", notes="string", @@ -827,9 +821,9 @@ async def test_streaming_response_mark_paid(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_mark_paid(self, client: AsyncOrb) -> None: + async def test_path_params_mark_paid(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"): - await client.invoices.with_raw_response.mark_paid( + await async_client.invoices.with_raw_response.mark_paid( "", external_id="external_payment_id_123", notes="string", @@ -837,15 +831,15 @@ async def test_path_params_mark_paid(self, client: AsyncOrb) -> None: ) @parametrize - async def test_method_void(self, client: AsyncOrb) -> None: - invoice = await client.invoices.void( + async def test_method_void(self, async_client: AsyncOrb) -> None: + invoice = await async_client.invoices.void( "string", ) assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_raw_response_void(self, client: AsyncOrb) -> None: - response = await client.invoices.with_raw_response.void( + async def test_raw_response_void(self, async_client: AsyncOrb) -> None: + response = await async_client.invoices.with_raw_response.void( "string", ) @@ -855,8 +849,8 @@ async def test_raw_response_void(self, client: AsyncOrb) -> None: assert_matches_type(Invoice, invoice, path=["response"]) @parametrize - async def test_streaming_response_void(self, client: AsyncOrb) -> None: - async with client.invoices.with_streaming_response.void( + async def test_streaming_response_void(self, async_client: AsyncOrb) -> None: + async with async_client.invoices.with_streaming_response.void( "string", ) as response: assert not response.is_closed @@ -868,8 +862,8 @@ async def test_streaming_response_void(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_void(self, client: AsyncOrb) -> None: + async def test_path_params_void(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `invoice_id` but received ''"): - await client.invoices.with_raw_response.void( + await async_client.invoices.with_raw_response.void( "", ) diff --git a/tests/api_resources/test_items.py b/tests/api_resources/test_items.py index fa261954..4648cfae 100644 --- a/tests/api_resources/test_items.py +++ b/tests/api_resources/test_items.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb.types import Item -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestItems: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -126,20 +122,18 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncItems: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - item = await client.items.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + item = await async_client.items.create( name="API requests", ) assert_matches_type(Item, item, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.items.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.items.with_raw_response.create( name="API requests", ) @@ -149,8 +143,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Item, item, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.items.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.items.with_streaming_response.create( name="API requests", ) as response: assert not response.is_closed @@ -162,21 +156,21 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - item = await client.items.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + item = await async_client.items.list() assert_matches_type(AsyncPage[Item], item, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - item = await client.items.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + item = await async_client.items.list( cursor="string", limit=0, ) assert_matches_type(AsyncPage[Item], item, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.items.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.items.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -184,8 +178,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Item], item, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.items.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.items.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -195,15 +189,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - item = await client.items.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + item = await async_client.items.fetch( "string", ) assert_matches_type(Item, item, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.items.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.items.with_raw_response.fetch( "string", ) @@ -213,8 +207,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Item, item, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.items.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.items.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -226,8 +220,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `item_id` but received ''"): - await client.items.with_raw_response.fetch( + await async_client.items.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_metrics.py b/tests/api_resources/test_metrics.py index cb998e62..2eedca87 100644 --- a/tests/api_resources/test_metrics.py +++ b/tests/api_resources/test_metrics.py @@ -14,18 +14,14 @@ MetricCreateResponse, ) from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestMetrics: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -155,13 +151,11 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncMetrics: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - metric = await client.metrics.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + metric = await async_client.metrics.create( description="Sum of bytes downloaded in fast mode", item_id="string", name="Bytes downloaded", @@ -170,8 +164,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(MetricCreateResponse, metric, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - metric = await client.metrics.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + metric = await async_client.metrics.create( description="Sum of bytes downloaded in fast mode", item_id="string", name="Bytes downloaded", @@ -181,8 +175,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(MetricCreateResponse, metric, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.metrics.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.metrics.with_raw_response.create( description="Sum of bytes downloaded in fast mode", item_id="string", name="Bytes downloaded", @@ -195,8 +189,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(MetricCreateResponse, metric, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.metrics.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.metrics.with_streaming_response.create( description="Sum of bytes downloaded in fast mode", item_id="string", name="Bytes downloaded", @@ -211,13 +205,13 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - metric = await client.metrics.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + metric = await async_client.metrics.list() assert_matches_type(AsyncPage[MetricListResponse], metric, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - metric = await client.metrics.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + metric = await async_client.metrics.list( created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -228,8 +222,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[MetricListResponse], metric, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.metrics.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.metrics.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -237,8 +231,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[MetricListResponse], metric, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.metrics.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.metrics.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -248,15 +242,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - metric = await client.metrics.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + metric = await async_client.metrics.fetch( "string", ) assert_matches_type(MetricFetchResponse, metric, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.metrics.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.metrics.with_raw_response.fetch( "string", ) @@ -266,8 +260,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(MetricFetchResponse, metric, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.metrics.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.metrics.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -279,8 +273,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `metric_id` but received ''"): - await client.metrics.with_raw_response.fetch( + await async_client.metrics.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_plans.py b/tests/api_resources/test_plans.py index 913fa222..8d32aff1 100644 --- a/tests/api_resources/test_plans.py +++ b/tests/api_resources/test_plans.py @@ -10,18 +10,14 @@ from orb import Orb, AsyncOrb from orb.types import Plan from orb._utils import parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestPlans: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -238,13 +234,11 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncPlans: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - plan = await client.plans.create( + async def test_method_create(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.create( currency="string", name="string", prices=[ @@ -260,8 +254,8 @@ async def test_method_create(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - plan = await client.plans.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.create( currency="string", name="string", prices=[ @@ -289,8 +283,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.plans.with_raw_response.create( + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.with_raw_response.create( currency="string", name="string", prices=[ @@ -310,8 +304,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.plans.with_streaming_response.create( + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.plans.with_streaming_response.create( currency="string", name="string", prices=[ @@ -333,15 +327,15 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_update(self, client: AsyncOrb) -> None: - plan = await client.plans.update( + async def test_method_update(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.update( "string", ) assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: - plan = await client.plans.update( + async def test_method_update_with_all_params(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.update( "string", external_plan_id="string", metadata={"foo": "string"}, @@ -349,8 +343,8 @@ async def test_method_update_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_raw_response_update(self, client: AsyncOrb) -> None: - response = await client.plans.with_raw_response.update( + async def test_raw_response_update(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.with_raw_response.update( "string", ) @@ -360,8 +354,8 @@ async def test_raw_response_update(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_streaming_response_update(self, client: AsyncOrb) -> None: - async with client.plans.with_streaming_response.update( + async def test_streaming_response_update(self, async_client: AsyncOrb) -> None: + async with async_client.plans.with_streaming_response.update( "string", ) as response: assert not response.is_closed @@ -373,20 +367,20 @@ async def test_streaming_response_update(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update(self, client: AsyncOrb) -> None: + async def test_path_params_update(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `plan_id` but received ''"): - await client.plans.with_raw_response.update( + await async_client.plans.with_raw_response.update( "", ) @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - plan = await client.plans.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.list() assert_matches_type(AsyncPage[Plan], plan, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - plan = await client.plans.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.list( created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -398,8 +392,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Plan], plan, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.plans.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -407,8 +401,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Plan], plan, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.plans.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.plans.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -418,15 +412,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - plan = await client.plans.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + plan = await async_client.plans.fetch( "string", ) assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.plans.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.plans.with_raw_response.fetch( "string", ) @@ -436,8 +430,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Plan, plan, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.plans.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.plans.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -449,8 +443,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `plan_id` but received ''"): - await client.plans.with_raw_response.fetch( + await async_client.plans.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_prices.py b/tests/api_resources/test_prices.py index e9d9f0c0..b9f2e2e5 100644 --- a/tests/api_resources/test_prices.py +++ b/tests/api_resources/test_prices.py @@ -9,18 +9,14 @@ from orb import Orb, AsyncOrb from orb.types import Price -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestPrices: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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_overload_1(self, client: Orb) -> None: @@ -1094,13 +1090,11 @@ def test_path_params_fetch(self, client: Orb) -> None: class TestAsyncPrices: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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_overload_1(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_1(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1111,8 +1105,8 @@ async def test_method_create_overload_1(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_1(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_1(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1131,8 +1125,8 @@ async def test_method_create_with_all_params_overload_1(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_1(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_1(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1147,8 +1141,8 @@ async def test_raw_response_create_overload_1(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_1(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_1(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1165,8 +1159,8 @@ async def test_streaming_response_create_overload_1(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_2(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_2(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1177,8 +1171,8 @@ async def test_method_create_overload_2(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_2(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_2(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1197,8 +1191,8 @@ async def test_method_create_with_all_params_overload_2(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_2(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_2(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1213,8 +1207,8 @@ async def test_raw_response_create_overload_2(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_2(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_2(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1231,8 +1225,8 @@ async def test_streaming_response_create_overload_2(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_3(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_3(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1260,8 +1254,8 @@ async def test_method_create_overload_3(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_3(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_3(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1298,8 +1292,8 @@ async def test_method_create_with_all_params_overload_3(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_3(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_3(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1331,8 +1325,8 @@ async def test_raw_response_create_overload_3(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_3(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_3(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1366,8 +1360,8 @@ async def test_streaming_response_create_overload_3(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_4(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_4(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1393,8 +1387,8 @@ async def test_method_create_overload_4(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_4(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_4(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1428,8 +1422,8 @@ async def test_method_create_with_all_params_overload_4(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_4(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_4(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1459,8 +1453,8 @@ async def test_raw_response_create_overload_4(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_4(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_4(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1492,8 +1486,8 @@ async def test_streaming_response_create_overload_4(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_5(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_5(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1519,8 +1513,8 @@ async def test_method_create_overload_5(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_5(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_5(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1557,8 +1551,8 @@ async def test_method_create_with_all_params_overload_5(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_5(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_5(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1588,8 +1582,8 @@ async def test_raw_response_create_overload_5(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_5(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_5(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1621,8 +1615,8 @@ async def test_streaming_response_create_overload_5(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_6(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_6(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bps_config={"bps": 0}, cadence="annual", currency="string", @@ -1633,8 +1627,8 @@ async def test_method_create_overload_6(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_6(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_6(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bps_config={ "bps": 0, "per_unit_maximum": "string", @@ -1653,8 +1647,8 @@ async def test_method_create_with_all_params_overload_6(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_6(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_6(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( bps_config={"bps": 0}, cadence="annual", currency="string", @@ -1669,8 +1663,8 @@ async def test_raw_response_create_overload_6(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_6(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_6(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( bps_config={"bps": 0}, cadence="annual", currency="string", @@ -1687,8 +1681,8 @@ async def test_streaming_response_create_overload_6(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_7(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_7(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bulk_bps_config={"tiers": [{"bps": 0}, {"bps": 0}, {"bps": 0}]}, cadence="annual", currency="string", @@ -1699,8 +1693,8 @@ async def test_method_create_overload_7(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_7(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_7(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bulk_bps_config={ "tiers": [ { @@ -1734,8 +1728,8 @@ async def test_method_create_with_all_params_overload_7(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_7(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_7(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( bulk_bps_config={"tiers": [{"bps": 0}, {"bps": 0}, {"bps": 0}]}, cadence="annual", currency="string", @@ -1750,8 +1744,8 @@ async def test_raw_response_create_overload_7(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_7(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_7(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( bulk_bps_config={"tiers": [{"bps": 0}, {"bps": 0}, {"bps": 0}]}, cadence="annual", currency="string", @@ -1768,8 +1762,8 @@ async def test_streaming_response_create_overload_7(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_8(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_8(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bulk_config={"tiers": [{"unit_amount": "string"}, {"unit_amount": "string"}, {"unit_amount": "string"}]}, cadence="annual", currency="string", @@ -1780,8 +1774,8 @@ async def test_method_create_overload_8(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_8(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_8(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( bulk_config={ "tiers": [ { @@ -1812,8 +1806,8 @@ async def test_method_create_with_all_params_overload_8(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_8(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_8(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( bulk_config={"tiers": [{"unit_amount": "string"}, {"unit_amount": "string"}, {"unit_amount": "string"}]}, cadence="annual", currency="string", @@ -1828,8 +1822,8 @@ async def test_raw_response_create_overload_8(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_8(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_8(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( bulk_config={"tiers": [{"unit_amount": "string"}, {"unit_amount": "string"}, {"unit_amount": "string"}]}, cadence="annual", currency="string", @@ -1846,8 +1840,8 @@ async def test_streaming_response_create_overload_8(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_9(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_9(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1858,8 +1852,8 @@ async def test_method_create_overload_9(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_9(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_9(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1875,8 +1869,8 @@ async def test_method_create_with_all_params_overload_9(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_9(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_9(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1891,8 +1885,8 @@ async def test_raw_response_create_overload_9(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_9(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_9(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1909,8 +1903,8 @@ async def test_streaming_response_create_overload_9(self, client: AsyncOrb) -> N assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_10(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_10(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1921,8 +1915,8 @@ async def test_method_create_overload_10(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_10(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_10(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1938,8 +1932,8 @@ async def test_method_create_with_all_params_overload_10(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_10(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_10(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -1954,8 +1948,8 @@ async def test_raw_response_create_overload_10(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_10(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_10(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -1972,8 +1966,8 @@ async def test_streaming_response_create_overload_10(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_11(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_11(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -1984,8 +1978,8 @@ async def test_method_create_overload_11(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_11(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_11(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -2001,8 +1995,8 @@ async def test_method_create_with_all_params_overload_11(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_11(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_11(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -2017,8 +2011,8 @@ async def test_raw_response_create_overload_11(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_11(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_11(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -2035,8 +2029,8 @@ async def test_streaming_response_create_overload_11(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_method_create_overload_12(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_overload_12(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -2047,8 +2041,8 @@ async def test_method_create_overload_12(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_method_create_with_all_params_overload_12(self, client: AsyncOrb) -> None: - price = await client.prices.create( + async def test_method_create_with_all_params_overload_12(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.create( cadence="annual", currency="string", item_id="string", @@ -2064,8 +2058,8 @@ async def test_method_create_with_all_params_overload_12(self, client: AsyncOrb) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_create_overload_12(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.create( + async def test_raw_response_create_overload_12(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.create( cadence="annual", currency="string", item_id="string", @@ -2080,8 +2074,8 @@ async def test_raw_response_create_overload_12(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_create_overload_12(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.create( + async def test_streaming_response_create_overload_12(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.create( cadence="annual", currency="string", item_id="string", @@ -2098,21 +2092,21 @@ async def test_streaming_response_create_overload_12(self, client: AsyncOrb) -> assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - price = await client.prices.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.list() assert_matches_type(AsyncPage[Price], price, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - price = await client.prices.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.list( cursor="string", limit=0, ) assert_matches_type(AsyncPage[Price], price, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -2120,8 +2114,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Price], price, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -2131,15 +2125,15 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - price = await client.prices.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + price = await async_client.prices.fetch( "string", ) assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.prices.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.prices.with_raw_response.fetch( "string", ) @@ -2149,8 +2143,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Price, price, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.prices.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.prices.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -2162,8 +2156,8 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `price_id` but received ''"): - await client.prices.with_raw_response.fetch( + await async_client.prices.with_raw_response.fetch( "", ) diff --git a/tests/api_resources/test_subscriptions.py b/tests/api_resources/test_subscriptions.py index 4bf782b3..e67d6129 100644 --- a/tests/api_resources/test_subscriptions.py +++ b/tests/api_resources/test_subscriptions.py @@ -15,18 +15,14 @@ SubscriptionFetchScheduleResponse, ) from orb._utils import parse_date, parse_datetime -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type from orb.pagination import SyncPage, AsyncPage base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestSubscriptions: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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: Orb) -> None: @@ -1040,18 +1036,16 @@ def test_path_params_update_fixed_fee_quantity(self, client: Orb) -> None: class TestAsyncSubscriptions: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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: AsyncOrb) -> None: - subscription = await client.subscriptions.create() + async def test_method_create(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.create() assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.create( + async def test_method_create_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.create( align_billing_with_subscription_start_date=True, auto_collection=True, aws_region="string", @@ -1134,8 +1128,8 @@ async def test_method_create_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_create(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.create() + async def test_raw_response_create(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.create() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1143,8 +1137,8 @@ async def test_raw_response_create(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_create(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.create() as response: + async def test_streaming_response_create(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.create() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1154,13 +1148,13 @@ async def test_streaming_response_create(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_list(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.list() + async def test_method_list(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.list() assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.list( + async def test_method_list_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.list( created_at_gt=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_gte=parse_datetime("2019-12-27T18:11:19.117Z"), created_at_lt=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1174,8 +1168,8 @@ async def test_method_list_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_raw_response_list(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.list() + async def test_raw_response_list(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.list() assert response.is_closed is True assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1183,8 +1177,8 @@ async def test_raw_response_list(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[Subscription], subscription, path=["response"]) @parametrize - async def test_streaming_response_list(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.list() as response: + async def test_streaming_response_list(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.list() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" @@ -1194,16 +1188,16 @@ async def test_streaming_response_list(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_method_cancel(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.cancel( + async def test_method_cancel(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.cancel( "string", cancel_option="end_of_subscription_term", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_method_cancel_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.cancel( + async def test_method_cancel_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.cancel( "string", cancel_option="end_of_subscription_term", cancellation_date=parse_datetime("2019-12-27T18:11:19.117Z"), @@ -1211,8 +1205,8 @@ async def test_method_cancel_with_all_params(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_cancel(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.cancel( + async def test_raw_response_cancel(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.cancel( "string", cancel_option="end_of_subscription_term", ) @@ -1223,8 +1217,8 @@ async def test_raw_response_cancel(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_cancel(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.cancel( + async def test_streaming_response_cancel(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.cancel( "string", cancel_option="end_of_subscription_term", ) as response: @@ -1237,23 +1231,23 @@ async def test_streaming_response_cancel(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_cancel(self, client: AsyncOrb) -> None: + async def test_path_params_cancel(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.cancel( + await async_client.subscriptions.with_raw_response.cancel( "", cancel_option="end_of_subscription_term", ) @parametrize - async def test_method_fetch(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch( + async def test_method_fetch(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch( "string", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_fetch(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.fetch( + async def test_raw_response_fetch(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.fetch( "string", ) @@ -1263,8 +1257,8 @@ async def test_raw_response_fetch(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.fetch( + async def test_streaming_response_fetch(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.fetch( "string", ) as response: assert not response.is_closed @@ -1276,22 +1270,22 @@ async def test_streaming_response_fetch(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch(self, client: AsyncOrb) -> None: + async def test_path_params_fetch(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.fetch( + await async_client.subscriptions.with_raw_response.fetch( "", ) @parametrize - async def test_method_fetch_costs(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_costs( + async def test_method_fetch_costs(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_costs( "string", ) assert_matches_type(SubscriptionFetchCostsResponse, subscription, path=["response"]) @parametrize - async def test_method_fetch_costs_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_costs( + async def test_method_fetch_costs_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_costs( "string", group_by="string", timeframe_end=parse_datetime("2022-03-01T05:00:00Z"), @@ -1301,8 +1295,8 @@ async def test_method_fetch_costs_with_all_params(self, client: AsyncOrb) -> Non assert_matches_type(SubscriptionFetchCostsResponse, subscription, path=["response"]) @parametrize - async def test_raw_response_fetch_costs(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.fetch_costs( + async def test_raw_response_fetch_costs(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.fetch_costs( "string", ) @@ -1312,8 +1306,8 @@ async def test_raw_response_fetch_costs(self, client: AsyncOrb) -> None: assert_matches_type(SubscriptionFetchCostsResponse, subscription, path=["response"]) @parametrize - async def test_streaming_response_fetch_costs(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.fetch_costs( + async def test_streaming_response_fetch_costs(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.fetch_costs( "string", ) as response: assert not response.is_closed @@ -1325,22 +1319,22 @@ async def test_streaming_response_fetch_costs(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch_costs(self, client: AsyncOrb) -> None: + async def test_path_params_fetch_costs(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.fetch_costs( + await async_client.subscriptions.with_raw_response.fetch_costs( "", ) @parametrize - async def test_method_fetch_schedule(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_schedule( + async def test_method_fetch_schedule(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_schedule( "string", ) assert_matches_type(AsyncPage[SubscriptionFetchScheduleResponse], subscription, path=["response"]) @parametrize - async def test_method_fetch_schedule_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_schedule( + async def test_method_fetch_schedule_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_schedule( "string", cursor="string", limit=0, @@ -1352,8 +1346,8 @@ async def test_method_fetch_schedule_with_all_params(self, client: AsyncOrb) -> assert_matches_type(AsyncPage[SubscriptionFetchScheduleResponse], subscription, path=["response"]) @parametrize - async def test_raw_response_fetch_schedule(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.fetch_schedule( + async def test_raw_response_fetch_schedule(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.fetch_schedule( "string", ) @@ -1363,8 +1357,8 @@ async def test_raw_response_fetch_schedule(self, client: AsyncOrb) -> None: assert_matches_type(AsyncPage[SubscriptionFetchScheduleResponse], subscription, path=["response"]) @parametrize - async def test_streaming_response_fetch_schedule(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.fetch_schedule( + async def test_streaming_response_fetch_schedule(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.fetch_schedule( "string", ) as response: assert not response.is_closed @@ -1376,24 +1370,24 @@ async def test_streaming_response_fetch_schedule(self, client: AsyncOrb) -> None assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_fetch_schedule(self, client: AsyncOrb) -> None: + async def test_path_params_fetch_schedule(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.fetch_schedule( + await async_client.subscriptions.with_raw_response.fetch_schedule( "", ) @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_method_fetch_usage(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_usage( + async def test_method_fetch_usage(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_usage( "string", ) assert_matches_type(SubscriptionUsage, subscription, path=["response"]) @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_method_fetch_usage_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.fetch_usage( + async def test_method_fetch_usage_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.fetch_usage( "string", billable_metric_id="string", cursor="string", @@ -1412,8 +1406,8 @@ async def test_method_fetch_usage_with_all_params(self, client: AsyncOrb) -> Non @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_raw_response_fetch_usage(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.fetch_usage( + async def test_raw_response_fetch_usage(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.fetch_usage( "string", ) @@ -1424,8 +1418,8 @@ async def test_raw_response_fetch_usage(self, client: AsyncOrb) -> None: @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_streaming_response_fetch_usage(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.fetch_usage( + async def test_streaming_response_fetch_usage(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.fetch_usage( "string", ) as response: assert not response.is_closed @@ -1438,24 +1432,24 @@ async def test_streaming_response_fetch_usage(self, client: AsyncOrb) -> None: @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_path_params_fetch_usage(self, client: AsyncOrb) -> None: + async def test_path_params_fetch_usage(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.fetch_usage( + await async_client.subscriptions.with_raw_response.fetch_usage( "", ) @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_method_price_intervals(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.price_intervals( + async def test_method_price_intervals(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.price_intervals( "string", ) assert_matches_type(Subscription, subscription, path=["response"]) @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_method_price_intervals_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.price_intervals( + async def test_method_price_intervals_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.price_intervals( "string", add=[ { @@ -1682,8 +1676,8 @@ async def test_method_price_intervals_with_all_params(self, client: AsyncOrb) -> @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_raw_response_price_intervals(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.price_intervals( + async def test_raw_response_price_intervals(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.price_intervals( "string", ) @@ -1694,8 +1688,8 @@ async def test_raw_response_price_intervals(self, client: AsyncOrb) -> None: @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_streaming_response_price_intervals(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.price_intervals( + async def test_streaming_response_price_intervals(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.price_intervals( "string", ) as response: assert not response.is_closed @@ -1708,23 +1702,23 @@ async def test_streaming_response_price_intervals(self, client: AsyncOrb) -> Non @pytest.mark.skip(reason="Incorrect example breaks Prism") @parametrize - async def test_path_params_price_intervals(self, client: AsyncOrb) -> None: + async def test_path_params_price_intervals(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.price_intervals( + await async_client.subscriptions.with_raw_response.price_intervals( "", ) @parametrize - async def test_method_schedule_plan_change(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.schedule_plan_change( + async def test_method_schedule_plan_change(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.schedule_plan_change( "string", change_option="requested_date", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_method_schedule_plan_change_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.schedule_plan_change( + async def test_method_schedule_plan_change_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.schedule_plan_change( "string", change_option="requested_date", align_billing_with_plan_change_date=True, @@ -1800,8 +1794,8 @@ async def test_method_schedule_plan_change_with_all_params(self, client: AsyncOr assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_schedule_plan_change(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.schedule_plan_change( + async def test_raw_response_schedule_plan_change(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.schedule_plan_change( "string", change_option="requested_date", ) @@ -1812,8 +1806,8 @@ async def test_raw_response_schedule_plan_change(self, client: AsyncOrb) -> None assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_schedule_plan_change(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.schedule_plan_change( + async def test_streaming_response_schedule_plan_change(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.schedule_plan_change( "string", change_option="requested_date", ) as response: @@ -1826,31 +1820,31 @@ async def test_streaming_response_schedule_plan_change(self, client: AsyncOrb) - assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_schedule_plan_change(self, client: AsyncOrb) -> None: + async def test_path_params_schedule_plan_change(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.schedule_plan_change( + await async_client.subscriptions.with_raw_response.schedule_plan_change( "", change_option="requested_date", ) @parametrize - async def test_method_trigger_phase(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.trigger_phase( + async def test_method_trigger_phase(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.trigger_phase( "string", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_method_trigger_phase_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.trigger_phase( + async def test_method_trigger_phase_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.trigger_phase( "string", effective_date=parse_date("2019-12-27"), ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_trigger_phase(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.trigger_phase( + async def test_raw_response_trigger_phase(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.trigger_phase( "string", ) @@ -1860,8 +1854,8 @@ async def test_raw_response_trigger_phase(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_trigger_phase(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.trigger_phase( + async def test_streaming_response_trigger_phase(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.trigger_phase( "string", ) as response: assert not response.is_closed @@ -1873,22 +1867,22 @@ async def test_streaming_response_trigger_phase(self, client: AsyncOrb) -> None: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_trigger_phase(self, client: AsyncOrb) -> None: + async def test_path_params_trigger_phase(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.trigger_phase( + await async_client.subscriptions.with_raw_response.trigger_phase( "", ) @parametrize - async def test_method_unschedule_cancellation(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.unschedule_cancellation( + async def test_method_unschedule_cancellation(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.unschedule_cancellation( "string", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_unschedule_cancellation(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.unschedule_cancellation( + async def test_raw_response_unschedule_cancellation(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.unschedule_cancellation( "string", ) @@ -1898,8 +1892,8 @@ async def test_raw_response_unschedule_cancellation(self, client: AsyncOrb) -> N assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_unschedule_cancellation(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.unschedule_cancellation( + async def test_streaming_response_unschedule_cancellation(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.unschedule_cancellation( "string", ) as response: assert not response.is_closed @@ -1911,23 +1905,23 @@ async def test_streaming_response_unschedule_cancellation(self, client: AsyncOrb assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_unschedule_cancellation(self, client: AsyncOrb) -> None: + async def test_path_params_unschedule_cancellation(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.unschedule_cancellation( + await async_client.subscriptions.with_raw_response.unschedule_cancellation( "", ) @parametrize - async def test_method_unschedule_fixed_fee_quantity_updates(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.unschedule_fixed_fee_quantity_updates( + async def test_method_unschedule_fixed_fee_quantity_updates(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.unschedule_fixed_fee_quantity_updates( "string", price_id="string", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_unschedule_fixed_fee_quantity_updates(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.unschedule_fixed_fee_quantity_updates( + async def test_raw_response_unschedule_fixed_fee_quantity_updates(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.unschedule_fixed_fee_quantity_updates( "string", price_id="string", ) @@ -1938,8 +1932,8 @@ async def test_raw_response_unschedule_fixed_fee_quantity_updates(self, client: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_unschedule_fixed_fee_quantity_updates(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.unschedule_fixed_fee_quantity_updates( + async def test_streaming_response_unschedule_fixed_fee_quantity_updates(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.unschedule_fixed_fee_quantity_updates( "string", price_id="string", ) as response: @@ -1952,23 +1946,23 @@ async def test_streaming_response_unschedule_fixed_fee_quantity_updates(self, cl assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_unschedule_fixed_fee_quantity_updates(self, client: AsyncOrb) -> None: + async def test_path_params_unschedule_fixed_fee_quantity_updates(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.unschedule_fixed_fee_quantity_updates( + await async_client.subscriptions.with_raw_response.unschedule_fixed_fee_quantity_updates( "", price_id="string", ) @parametrize - async def test_method_unschedule_pending_plan_changes(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.unschedule_pending_plan_changes( + async def test_method_unschedule_pending_plan_changes(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.unschedule_pending_plan_changes( "string", ) assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_unschedule_pending_plan_changes(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.unschedule_pending_plan_changes( + async def test_raw_response_unschedule_pending_plan_changes(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.unschedule_pending_plan_changes( "string", ) @@ -1978,8 +1972,8 @@ async def test_raw_response_unschedule_pending_plan_changes(self, client: AsyncO assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_unschedule_pending_plan_changes(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.unschedule_pending_plan_changes( + async def test_streaming_response_unschedule_pending_plan_changes(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.unschedule_pending_plan_changes( "string", ) as response: assert not response.is_closed @@ -1991,15 +1985,15 @@ async def test_streaming_response_unschedule_pending_plan_changes(self, client: assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_unschedule_pending_plan_changes(self, client: AsyncOrb) -> None: + async def test_path_params_unschedule_pending_plan_changes(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.unschedule_pending_plan_changes( + await async_client.subscriptions.with_raw_response.unschedule_pending_plan_changes( "", ) @parametrize - async def test_method_update_fixed_fee_quantity(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.update_fixed_fee_quantity( + async def test_method_update_fixed_fee_quantity(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.update_fixed_fee_quantity( "string", price_id="string", quantity=0, @@ -2007,8 +2001,8 @@ async def test_method_update_fixed_fee_quantity(self, client: AsyncOrb) -> None: assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_method_update_fixed_fee_quantity_with_all_params(self, client: AsyncOrb) -> None: - subscription = await client.subscriptions.update_fixed_fee_quantity( + async def test_method_update_fixed_fee_quantity_with_all_params(self, async_client: AsyncOrb) -> None: + subscription = await async_client.subscriptions.update_fixed_fee_quantity( "string", price_id="string", quantity=0, @@ -2018,8 +2012,8 @@ async def test_method_update_fixed_fee_quantity_with_all_params(self, client: As assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_raw_response_update_fixed_fee_quantity(self, client: AsyncOrb) -> None: - response = await client.subscriptions.with_raw_response.update_fixed_fee_quantity( + async def test_raw_response_update_fixed_fee_quantity(self, async_client: AsyncOrb) -> None: + response = await async_client.subscriptions.with_raw_response.update_fixed_fee_quantity( "string", price_id="string", quantity=0, @@ -2031,8 +2025,8 @@ async def test_raw_response_update_fixed_fee_quantity(self, client: AsyncOrb) -> assert_matches_type(Subscription, subscription, path=["response"]) @parametrize - async def test_streaming_response_update_fixed_fee_quantity(self, client: AsyncOrb) -> None: - async with client.subscriptions.with_streaming_response.update_fixed_fee_quantity( + async def test_streaming_response_update_fixed_fee_quantity(self, async_client: AsyncOrb) -> None: + async with async_client.subscriptions.with_streaming_response.update_fixed_fee_quantity( "string", price_id="string", quantity=0, @@ -2046,9 +2040,9 @@ async def test_streaming_response_update_fixed_fee_quantity(self, client: AsyncO assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_update_fixed_fee_quantity(self, client: AsyncOrb) -> None: + async def test_path_params_update_fixed_fee_quantity(self, async_client: AsyncOrb) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `subscription_id` but received ''"): - await client.subscriptions.with_raw_response.update_fixed_fee_quantity( + await async_client.subscriptions.with_raw_response.update_fixed_fee_quantity( "", price_id="string", quantity=0, diff --git a/tests/api_resources/test_top_level.py b/tests/api_resources/test_top_level.py index 9a785943..01db8377 100644 --- a/tests/api_resources/test_top_level.py +++ b/tests/api_resources/test_top_level.py @@ -9,17 +9,13 @@ from orb import Orb, AsyncOrb from orb.types import TopLevelPingResponse -from orb._client import Orb, AsyncOrb from tests.utils import assert_matches_type base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") -api_key = "My API Key" class TestTopLevel: - strict_client = Orb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = Orb(base_url=base_url, api_key=api_key, _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_ping(self, client: Orb) -> None: @@ -48,18 +44,16 @@ def test_streaming_response_ping(self, client: Orb) -> None: class TestAsyncTopLevel: - strict_client = AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=True) - loose_client = AsyncOrb(base_url=base_url, api_key=api_key, _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_ping(self, client: AsyncOrb) -> None: - top_level = await client.top_level.ping() + async def test_method_ping(self, async_client: AsyncOrb) -> None: + top_level = await async_client.top_level.ping() assert_matches_type(TopLevelPingResponse, top_level, path=["response"]) @parametrize - async def test_raw_response_ping(self, client: AsyncOrb) -> None: - response = await client.top_level.with_raw_response.ping() + async def test_raw_response_ping(self, async_client: AsyncOrb) -> None: + response = await async_client.top_level.with_raw_response.ping() 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_ping(self, client: AsyncOrb) -> None: assert_matches_type(TopLevelPingResponse, top_level, path=["response"]) @parametrize - async def test_streaming_response_ping(self, client: AsyncOrb) -> None: - async with client.top_level.with_streaming_response.ping() as response: + async def test_streaming_response_ping(self, async_client: AsyncOrb) -> None: + async with async_client.top_level.with_streaming_response.ping() as response: assert not response.is_closed assert response.http_request.headers.get("X-Stainless-Lang") == "python" diff --git a/tests/conftest.py b/tests/conftest.py index 6619ac0f..a718a9e3 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 orb import Orb, AsyncOrb + +if TYPE_CHECKING: + from _pytest.fixtures import FixtureRequest + pytest.register_assert_rewrite("tests.utils") logging.getLogger("orb").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") + +api_key = "My API Key" + + +@pytest.fixture(scope="session") +def client(request: FixtureRequest) -> Iterator[Orb]: + strict = getattr(request, "param", True) + if not isinstance(strict, bool): + raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}") + + with Orb(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client: + yield client + + +@pytest.fixture(scope="session") +async def async_client(request: FixtureRequest) -> AsyncIterator[AsyncOrb]: + strict = getattr(request, "param", True) + if not isinstance(strict, bool): + raise TypeError(f"Unexpected fixture parameter type {type(strict)}, expected {bool}") + + async with AsyncOrb(base_url=base_url, api_key=api_key, _strict_response_validation=strict) as client: + yield client