diff --git a/.github/workflows/handle-release-pr-title-edit.yml b/.github/workflows/handle-release-pr-title-edit.yml index 36c3e875..30a9bcd2 100644 --- a/.github/workflows/handle-release-pr-title-edit.yml +++ b/.github/workflows/handle-release-pr-title-edit.yml @@ -14,6 +14,7 @@ jobs: startsWith(github.event.pull_request.head.ref, 'release-please--') && github.event.pull_request.state == 'open' && github.event.sender.login != 'stainless-bot' && + github.event.sender.login != 'stainless-app' && github.repository == 'orbcorp/orb-python' runs-on: ubuntu-latest steps: diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 4d14a67e..c746cd0b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.39.0" + ".": "1.39.1" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a9c8d4f..8c8ede69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # Changelog +## 1.39.1 (2024-01-18) + +Full Changelog: [v1.39.0...v1.39.1](https://github.com/orbcorp/orb-python/compare/v1.39.0...v1.39.1) + +### Bug Fixes + +* **ci:** ignore stainless-app edits to release PR title ([#146](https://github.com/orbcorp/orb-python/issues/146)) ([5a2e2b5](https://github.com/orbcorp/orb-python/commit/5a2e2b58b7763a99907ae3a3a8afd6a19789cb62)) + + +### Chores + +* **internal:** fix typing util function ([#140](https://github.com/orbcorp/orb-python/issues/140)) ([31a83a9](https://github.com/orbcorp/orb-python/commit/31a83a9d24ba25004ab234dc1b555a03d7333a1f)) +* **internal:** remove redundant client test ([#142](https://github.com/orbcorp/orb-python/issues/142)) ([e315f4e](https://github.com/orbcorp/orb-python/commit/e315f4e00c4e2a45a657d56df3a22813264632a3)) +* **internal:** share client instances between all tests ([#145](https://github.com/orbcorp/orb-python/issues/145)) ([64a4cb6](https://github.com/orbcorp/orb-python/commit/64a4cb6dfc3b5947701dba25dbe8c37b6050eb38)) +* **internal:** speculative retry-after-ms support ([#143](https://github.com/orbcorp/orb-python/issues/143)) ([d7affe9](https://github.com/orbcorp/orb-python/commit/d7affe9e3fae951027d43307df10420143e69042)) +* lazy load raw resource class properties ([#144](https://github.com/orbcorp/orb-python/issues/144)) ([72734a3](https://github.com/orbcorp/orb-python/commit/72734a340d158aae1e039d615a72bff2b9d89454)) + ## 1.39.0 (2024-01-17) Full Changelog: [v1.38.1...v1.39.0](https://github.com/orbcorp/orb-python/compare/v1.38.1...v1.39.0) diff --git a/pyproject.toml b/pyproject.toml index 1a237c16..8929d8c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "orb-billing" -version = "1.39.0" +version = "1.39.1" description = "The official Python library for the orb API" readme = "README.md" license = "Apache-2.0" diff --git a/src/orb/_base_client.py b/src/orb/_base_client.py index 1dfbd7df..43fad060 100644 --- a/src/orb/_base_client.py +++ b/src/orb/_base_client.py @@ -73,7 +73,9 @@ from ._constants import ( DEFAULT_LIMITS, DEFAULT_TIMEOUT, + MAX_RETRY_DELAY, DEFAULT_MAX_RETRIES, + INITIAL_RETRY_DELAY, RAW_RESPONSE_HEADER, OVERRIDE_CAST_TO_HEADER, ) @@ -590,6 +592,40 @@ def base_url(self, url: URL | str) -> None: def platform_headers(self) -> Dict[str, str]: return platform_headers(self._version) + def _parse_retry_after_header(self, response_headers: Optional[httpx.Headers] = None) -> float | None: + """Returns a float of the number of seconds (not milliseconds) to wait after retrying, or None if unspecified. + + About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After + See also https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax + """ + if response_headers is None: + return None + + # First, try the non-standard `retry-after-ms` header for milliseconds, + # which is more precise than integer-seconds `retry-after` + try: + retry_ms_header = response_headers.get("retry-after-ms", None) + return float(retry_ms_header) / 1000 + except (TypeError, ValueError): + pass + + # Next, try parsing `retry-after` header as seconds (allowing nonstandard floats). + retry_header = response_headers.get("retry-after") + try: + # note: the spec indicates that this should only ever be an integer + # but if someone sends a float there's no reason for us to not respect it + return float(retry_header) + except (TypeError, ValueError): + pass + + # Last, try parsing `retry-after` as a date. + retry_date_tuple = email.utils.parsedate_tz(retry_header) + if retry_date_tuple is None: + return None + + retry_date = email.utils.mktime_tz(retry_date_tuple) + return float(retry_date - time.time()) + def _calculate_retry_timeout( self, remaining_retries: int, @@ -597,40 +633,16 @@ def _calculate_retry_timeout( response_headers: Optional[httpx.Headers] = None, ) -> float: max_retries = options.get_max_retries(self.max_retries) - try: - # About the Retry-After header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After - # - # ". See https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Retry-After#syntax for - # details. - if response_headers is not None: - retry_header = response_headers.get("retry-after") - try: - # note: the spec indicates that this should only ever be an integer - # but if someone sends a float there's no reason for us to not respect it - retry_after = float(retry_header) - except Exception: - retry_date_tuple = email.utils.parsedate_tz(retry_header) - if retry_date_tuple is None: - retry_after = -1 - else: - retry_date = email.utils.mktime_tz(retry_date_tuple) - retry_after = int(retry_date - time.time()) - else: - retry_after = -1 - - except Exception: - retry_after = -1 # If the API asks us to wait a certain amount of time (and it's a reasonable amount), just do what it says. - if 0 < retry_after <= 60: + retry_after = self._parse_retry_after_header(response_headers) + if retry_after is not None and 0 < retry_after <= 60: return retry_after - initial_retry_delay = 0.5 - max_retry_delay = 8.0 nb_retries = max_retries - remaining_retries # Apply exponential backoff, but not more than the max. - sleep_seconds = min(initial_retry_delay * pow(2.0, nb_retries), max_retry_delay) + sleep_seconds = min(INITIAL_RETRY_DELAY * pow(2.0, nb_retries), MAX_RETRY_DELAY) # Apply some jitter, plus-or-minus half a second. jitter = 1 - 0.25 * random() diff --git a/src/orb/_constants.py b/src/orb/_constants.py index 76b21f0c..bf15141a 100644 --- a/src/orb/_constants.py +++ b/src/orb/_constants.py @@ -9,3 +9,6 @@ DEFAULT_TIMEOUT = httpx.Timeout(timeout=60.0, connect=5.0) DEFAULT_MAX_RETRIES = 2 DEFAULT_LIMITS = httpx.Limits(max_connections=100, max_keepalive_connections=20) + +INITIAL_RETRY_DELAY = 0.5 +MAX_RETRY_DELAY = 8.0 diff --git a/src/orb/_utils/_typing.py b/src/orb/_utils/_typing.py index b5e2c2e3..a020822b 100644 --- a/src/orb/_utils/_typing.py +++ b/src/orb/_utils/_typing.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Any, cast +from typing import Any, TypeVar, cast from typing_extensions import Required, Annotated, get_args, get_origin from .._types import InheritsGeneric @@ -23,6 +23,12 @@ def is_required_type(typ: type) -> bool: return get_origin(typ) == Required +def is_typevar(typ: type) -> bool: + # type ignore is required because type checkers + # think this expression will always return False + return type(typ) == TypeVar # type: ignore + + # Extracts T from Annotated[T, ...] or from Required[Annotated[T, ...]] def strip_annotated_type(typ: type) -> type: if is_required_type(typ) or is_annotated_type(typ): @@ -49,6 +55,15 @@ class MyResponse(Foo[bytes]): extract_type_var(MyResponse, bases=(Foo,), index=0) -> bytes ``` + + And where a generic subclass is given: + ```py + _T = TypeVar('_T') + class MyResponse(Foo[_T]): + ... + + extract_type_var(MyResponse[bytes], bases=(Foo,), index=0) -> bytes + ``` """ cls = cast(object, get_origin(typ) or typ) if cls in generic_bases: @@ -75,6 +90,18 @@ class MyResponse(Foo[bytes]): f"Does {cls} inherit from one of {generic_bases} ?" ) - return extract_type_arg(target_base_class, index) + extracted = extract_type_arg(target_base_class, index) + if is_typevar(extracted): + # If the extracted type argument is itself a type variable + # then that means the subclass itself is generic, so we have + # to resolve the type argument from the class itself, not + # the base class. + # + # Note: if there is more than 1 type argument, the subclass could + # change the ordering of the type arguments, this is not currently + # supported. + return extract_type_arg(typ, index) + + return extracted raise RuntimeError(f"Could not resolve inner type variable at index {index} for {typ}") diff --git a/src/orb/_version.py b/src/orb/_version.py index 1fc6dedb..c0ec83e5 100644 --- a/src/orb/_version.py +++ b/src/orb/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. __title__ = "orb" -__version__ = "1.39.0" # x-release-please-version +__version__ = "1.39.1" # x-release-please-version diff --git a/src/orb/resources/beta/beta.py b/src/orb/resources/beta/beta.py index 212a1bce..c75b2e07 100644 --- a/src/orb/resources/beta/beta.py +++ b/src/orb/resources/beta/beta.py @@ -46,19 +46,35 @@ def with_streaming_response(self) -> AsyncBetaWithStreamingResponse: class BetaWithRawResponse: def __init__(self, beta: Beta) -> None: - self.price = PriceWithRawResponse(beta.price) + self._beta = beta + + @cached_property + def price(self) -> PriceWithRawResponse: + return PriceWithRawResponse(self._beta.price) class AsyncBetaWithRawResponse: def __init__(self, beta: AsyncBeta) -> None: - self.price = AsyncPriceWithRawResponse(beta.price) + self._beta = beta + + @cached_property + def price(self) -> AsyncPriceWithRawResponse: + return AsyncPriceWithRawResponse(self._beta.price) class BetaWithStreamingResponse: def __init__(self, beta: Beta) -> None: - self.price = PriceWithStreamingResponse(beta.price) + self._beta = beta + + @cached_property + def price(self) -> PriceWithStreamingResponse: + return PriceWithStreamingResponse(self._beta.price) class AsyncBetaWithStreamingResponse: def __init__(self, beta: AsyncBeta) -> None: - self.price = AsyncPriceWithStreamingResponse(beta.price) + self._beta = beta + + @cached_property + def price(self) -> AsyncPriceWithStreamingResponse: + return AsyncPriceWithStreamingResponse(self._beta.price) diff --git a/src/orb/resources/beta/price.py b/src/orb/resources/beta/price.py index d38b8f09..c2458e49 100644 --- a/src/orb/resources/beta/price.py +++ b/src/orb/resources/beta/price.py @@ -229,6 +229,8 @@ async def evaluate( class PriceWithRawResponse: def __init__(self, price: Price) -> None: + self._price = price + self.evaluate = _legacy_response.to_raw_response_wrapper( price.evaluate, ) @@ -236,6 +238,8 @@ def __init__(self, price: Price) -> None: class AsyncPriceWithRawResponse: def __init__(self, price: AsyncPrice) -> None: + self._price = price + self.evaluate = _legacy_response.async_to_raw_response_wrapper( price.evaluate, ) @@ -243,6 +247,8 @@ def __init__(self, price: AsyncPrice) -> None: class PriceWithStreamingResponse: def __init__(self, price: Price) -> None: + self._price = price + self.evaluate = to_streamed_response_wrapper( price.evaluate, ) @@ -250,6 +256,8 @@ def __init__(self, price: Price) -> None: class AsyncPriceWithStreamingResponse: def __init__(self, price: AsyncPrice) -> None: + self._price = price + self.evaluate = async_to_streamed_response_wrapper( price.evaluate, ) diff --git a/src/orb/resources/coupons/coupons.py b/src/orb/resources/coupons/coupons.py index 83f82cda..5e4b5d1f 100644 --- a/src/orb/resources/coupons/coupons.py +++ b/src/orb/resources/coupons/coupons.py @@ -460,7 +460,7 @@ async def fetch( class CouponsWithRawResponse: def __init__(self, coupons: Coupons) -> None: - self.subscriptions = SubscriptionsWithRawResponse(coupons.subscriptions) + self._coupons = coupons self.create = _legacy_response.to_raw_response_wrapper( coupons.create, @@ -475,10 +475,14 @@ def __init__(self, coupons: Coupons) -> None: coupons.fetch, ) + @cached_property + def subscriptions(self) -> SubscriptionsWithRawResponse: + return SubscriptionsWithRawResponse(self._coupons.subscriptions) + class AsyncCouponsWithRawResponse: def __init__(self, coupons: AsyncCoupons) -> None: - self.subscriptions = AsyncSubscriptionsWithRawResponse(coupons.subscriptions) + self._coupons = coupons self.create = _legacy_response.async_to_raw_response_wrapper( coupons.create, @@ -493,10 +497,14 @@ def __init__(self, coupons: AsyncCoupons) -> None: coupons.fetch, ) + @cached_property + def subscriptions(self) -> AsyncSubscriptionsWithRawResponse: + return AsyncSubscriptionsWithRawResponse(self._coupons.subscriptions) + class CouponsWithStreamingResponse: def __init__(self, coupons: Coupons) -> None: - self.subscriptions = SubscriptionsWithStreamingResponse(coupons.subscriptions) + self._coupons = coupons self.create = to_streamed_response_wrapper( coupons.create, @@ -511,10 +519,14 @@ def __init__(self, coupons: Coupons) -> None: coupons.fetch, ) + @cached_property + def subscriptions(self) -> SubscriptionsWithStreamingResponse: + return SubscriptionsWithStreamingResponse(self._coupons.subscriptions) + class AsyncCouponsWithStreamingResponse: def __init__(self, coupons: AsyncCoupons) -> None: - self.subscriptions = AsyncSubscriptionsWithStreamingResponse(coupons.subscriptions) + self._coupons = coupons self.create = async_to_streamed_response_wrapper( coupons.create, @@ -528,3 +540,7 @@ def __init__(self, coupons: AsyncCoupons) -> None: self.fetch = async_to_streamed_response_wrapper( coupons.fetch, ) + + @cached_property + def subscriptions(self) -> AsyncSubscriptionsWithStreamingResponse: + return AsyncSubscriptionsWithStreamingResponse(self._coupons.subscriptions) diff --git a/src/orb/resources/coupons/subscriptions.py b/src/orb/resources/coupons/subscriptions.py index 3af0a335..65cb0cca 100644 --- a/src/orb/resources/coupons/subscriptions.py +++ b/src/orb/resources/coupons/subscriptions.py @@ -153,6 +153,8 @@ def list( class SubscriptionsWithRawResponse: def __init__(self, subscriptions: Subscriptions) -> None: + self._subscriptions = subscriptions + self.list = _legacy_response.to_raw_response_wrapper( subscriptions.list, ) @@ -160,6 +162,8 @@ def __init__(self, subscriptions: Subscriptions) -> None: class AsyncSubscriptionsWithRawResponse: def __init__(self, subscriptions: AsyncSubscriptions) -> None: + self._subscriptions = subscriptions + self.list = _legacy_response.async_to_raw_response_wrapper( subscriptions.list, ) @@ -167,6 +171,8 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None: class SubscriptionsWithStreamingResponse: def __init__(self, subscriptions: Subscriptions) -> None: + self._subscriptions = subscriptions + self.list = to_streamed_response_wrapper( subscriptions.list, ) @@ -174,6 +180,8 @@ def __init__(self, subscriptions: Subscriptions) -> None: class AsyncSubscriptionsWithStreamingResponse: def __init__(self, subscriptions: AsyncSubscriptions) -> None: + self._subscriptions = subscriptions + self.list = async_to_streamed_response_wrapper( subscriptions.list, ) diff --git a/src/orb/resources/credit_notes.py b/src/orb/resources/credit_notes.py index 6d7fcf94..5222da7a 100644 --- a/src/orb/resources/credit_notes.py +++ b/src/orb/resources/credit_notes.py @@ -214,6 +214,8 @@ async def fetch( class CreditNotesWithRawResponse: def __init__(self, credit_notes: CreditNotes) -> None: + self._credit_notes = credit_notes + self.list = _legacy_response.to_raw_response_wrapper( credit_notes.list, ) @@ -224,6 +226,8 @@ def __init__(self, credit_notes: CreditNotes) -> None: class AsyncCreditNotesWithRawResponse: def __init__(self, credit_notes: AsyncCreditNotes) -> None: + self._credit_notes = credit_notes + self.list = _legacy_response.async_to_raw_response_wrapper( credit_notes.list, ) @@ -234,6 +238,8 @@ def __init__(self, credit_notes: AsyncCreditNotes) -> None: class CreditNotesWithStreamingResponse: def __init__(self, credit_notes: CreditNotes) -> None: + self._credit_notes = credit_notes + self.list = to_streamed_response_wrapper( credit_notes.list, ) @@ -244,6 +250,8 @@ def __init__(self, credit_notes: CreditNotes) -> None: class AsyncCreditNotesWithStreamingResponse: def __init__(self, credit_notes: AsyncCreditNotes) -> None: + self._credit_notes = credit_notes + self.list = async_to_streamed_response_wrapper( credit_notes.list, ) diff --git a/src/orb/resources/customers/balance_transactions.py b/src/orb/resources/customers/balance_transactions.py index 6b65692d..bbe4b2f3 100644 --- a/src/orb/resources/customers/balance_transactions.py +++ b/src/orb/resources/customers/balance_transactions.py @@ -331,6 +331,8 @@ def list( class BalanceTransactionsWithRawResponse: def __init__(self, balance_transactions: BalanceTransactions) -> None: + self._balance_transactions = balance_transactions + self.create = _legacy_response.to_raw_response_wrapper( balance_transactions.create, ) @@ -341,6 +343,8 @@ def __init__(self, balance_transactions: BalanceTransactions) -> None: class AsyncBalanceTransactionsWithRawResponse: def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None: + self._balance_transactions = balance_transactions + self.create = _legacy_response.async_to_raw_response_wrapper( balance_transactions.create, ) @@ -351,6 +355,8 @@ def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None: class BalanceTransactionsWithStreamingResponse: def __init__(self, balance_transactions: BalanceTransactions) -> None: + self._balance_transactions = balance_transactions + self.create = to_streamed_response_wrapper( balance_transactions.create, ) @@ -361,6 +367,8 @@ def __init__(self, balance_transactions: BalanceTransactions) -> None: class AsyncBalanceTransactionsWithStreamingResponse: def __init__(self, balance_transactions: AsyncBalanceTransactions) -> None: + self._balance_transactions = balance_transactions + self.create = async_to_streamed_response_wrapper( balance_transactions.create, ) diff --git a/src/orb/resources/customers/costs.py b/src/orb/resources/customers/costs.py index 506bede7..f01a7445 100644 --- a/src/orb/resources/customers/costs.py +++ b/src/orb/resources/customers/costs.py @@ -825,6 +825,8 @@ async def list_by_external_id( class CostsWithRawResponse: def __init__(self, costs: Costs) -> None: + self._costs = costs + self.list = _legacy_response.to_raw_response_wrapper( costs.list, ) @@ -835,6 +837,8 @@ def __init__(self, costs: Costs) -> None: class AsyncCostsWithRawResponse: def __init__(self, costs: AsyncCosts) -> None: + self._costs = costs + self.list = _legacy_response.async_to_raw_response_wrapper( costs.list, ) @@ -845,6 +849,8 @@ def __init__(self, costs: AsyncCosts) -> None: class CostsWithStreamingResponse: def __init__(self, costs: Costs) -> None: + self._costs = costs + self.list = to_streamed_response_wrapper( costs.list, ) @@ -855,6 +861,8 @@ def __init__(self, costs: Costs) -> None: class AsyncCostsWithStreamingResponse: def __init__(self, costs: AsyncCosts) -> None: + self._costs = costs + self.list = async_to_streamed_response_wrapper( costs.list, ) diff --git a/src/orb/resources/customers/credits/credits.py b/src/orb/resources/customers/credits/credits.py index 371d9426..ea24d01d 100644 --- a/src/orb/resources/customers/credits/credits.py +++ b/src/orb/resources/customers/credits/credits.py @@ -289,7 +289,7 @@ def list_by_external_id( class CreditsWithRawResponse: def __init__(self, credits: Credits) -> None: - self.ledger = LedgerWithRawResponse(credits.ledger) + self._credits = credits self.list = _legacy_response.to_raw_response_wrapper( credits.list, @@ -298,10 +298,14 @@ def __init__(self, credits: Credits) -> None: credits.list_by_external_id, ) + @cached_property + def ledger(self) -> LedgerWithRawResponse: + return LedgerWithRawResponse(self._credits.ledger) + class AsyncCreditsWithRawResponse: def __init__(self, credits: AsyncCredits) -> None: - self.ledger = AsyncLedgerWithRawResponse(credits.ledger) + self._credits = credits self.list = _legacy_response.async_to_raw_response_wrapper( credits.list, @@ -310,10 +314,14 @@ def __init__(self, credits: AsyncCredits) -> None: credits.list_by_external_id, ) + @cached_property + def ledger(self) -> AsyncLedgerWithRawResponse: + return AsyncLedgerWithRawResponse(self._credits.ledger) + class CreditsWithStreamingResponse: def __init__(self, credits: Credits) -> None: - self.ledger = LedgerWithStreamingResponse(credits.ledger) + self._credits = credits self.list = to_streamed_response_wrapper( credits.list, @@ -322,10 +330,14 @@ def __init__(self, credits: Credits) -> None: credits.list_by_external_id, ) + @cached_property + def ledger(self) -> LedgerWithStreamingResponse: + return LedgerWithStreamingResponse(self._credits.ledger) + class AsyncCreditsWithStreamingResponse: def __init__(self, credits: AsyncCredits) -> None: - self.ledger = AsyncLedgerWithStreamingResponse(credits.ledger) + self._credits = credits self.list = async_to_streamed_response_wrapper( credits.list, @@ -333,3 +345,7 @@ def __init__(self, credits: AsyncCredits) -> None: self.list_by_external_id = async_to_streamed_response_wrapper( credits.list_by_external_id, ) + + @cached_property + def ledger(self) -> AsyncLedgerWithStreamingResponse: + return AsyncLedgerWithStreamingResponse(self._credits.ledger) diff --git a/src/orb/resources/customers/credits/ledger.py b/src/orb/resources/customers/credits/ledger.py index e1d64934..1c15e2d2 100644 --- a/src/orb/resources/customers/credits/ledger.py +++ b/src/orb/resources/customers/credits/ledger.py @@ -4279,6 +4279,8 @@ def list_by_external_id( class LedgerWithRawResponse: def __init__(self, ledger: Ledger) -> None: + self._ledger = ledger + self.list = _legacy_response.to_raw_response_wrapper( ledger.list, ) @@ -4295,6 +4297,8 @@ def __init__(self, ledger: Ledger) -> None: class AsyncLedgerWithRawResponse: def __init__(self, ledger: AsyncLedger) -> None: + self._ledger = ledger + self.list = _legacy_response.async_to_raw_response_wrapper( ledger.list, ) @@ -4311,6 +4315,8 @@ def __init__(self, ledger: AsyncLedger) -> None: class LedgerWithStreamingResponse: def __init__(self, ledger: Ledger) -> None: + self._ledger = ledger + self.list = to_streamed_response_wrapper( ledger.list, ) @@ -4327,6 +4333,8 @@ def __init__(self, ledger: Ledger) -> None: class AsyncLedgerWithStreamingResponse: def __init__(self, ledger: AsyncLedger) -> None: + self._ledger = ledger + self.list = async_to_streamed_response_wrapper( ledger.list, ) diff --git a/src/orb/resources/customers/customers.py b/src/orb/resources/customers/customers.py index cdbadd70..3be85261 100644 --- a/src/orb/resources/customers/customers.py +++ b/src/orb/resources/customers/customers.py @@ -1695,10 +1695,7 @@ async def update_by_external_id( class CustomersWithRawResponse: def __init__(self, customers: Customers) -> None: - self.costs = CostsWithRawResponse(customers.costs) - self.usage = UsageWithRawResponse(customers.usage) - self.credits = CreditsWithRawResponse(customers.credits) - self.balance_transactions = BalanceTransactionsWithRawResponse(customers.balance_transactions) + self._customers = customers self.create = _legacy_response.to_raw_response_wrapper( customers.create, @@ -1722,13 +1719,26 @@ def __init__(self, customers: Customers) -> None: customers.update_by_external_id, ) + @cached_property + def costs(self) -> CostsWithRawResponse: + return CostsWithRawResponse(self._customers.costs) + + @cached_property + def usage(self) -> UsageWithRawResponse: + return UsageWithRawResponse(self._customers.usage) + + @cached_property + def credits(self) -> CreditsWithRawResponse: + return CreditsWithRawResponse(self._customers.credits) + + @cached_property + def balance_transactions(self) -> BalanceTransactionsWithRawResponse: + return BalanceTransactionsWithRawResponse(self._customers.balance_transactions) + class AsyncCustomersWithRawResponse: def __init__(self, customers: AsyncCustomers) -> None: - self.costs = AsyncCostsWithRawResponse(customers.costs) - self.usage = AsyncUsageWithRawResponse(customers.usage) - self.credits = AsyncCreditsWithRawResponse(customers.credits) - self.balance_transactions = AsyncBalanceTransactionsWithRawResponse(customers.balance_transactions) + self._customers = customers self.create = _legacy_response.async_to_raw_response_wrapper( customers.create, @@ -1752,13 +1762,26 @@ def __init__(self, customers: AsyncCustomers) -> None: customers.update_by_external_id, ) + @cached_property + def costs(self) -> AsyncCostsWithRawResponse: + return AsyncCostsWithRawResponse(self._customers.costs) + + @cached_property + def usage(self) -> AsyncUsageWithRawResponse: + return AsyncUsageWithRawResponse(self._customers.usage) + + @cached_property + def credits(self) -> AsyncCreditsWithRawResponse: + return AsyncCreditsWithRawResponse(self._customers.credits) + + @cached_property + def balance_transactions(self) -> AsyncBalanceTransactionsWithRawResponse: + return AsyncBalanceTransactionsWithRawResponse(self._customers.balance_transactions) + class CustomersWithStreamingResponse: def __init__(self, customers: Customers) -> None: - self.costs = CostsWithStreamingResponse(customers.costs) - self.usage = UsageWithStreamingResponse(customers.usage) - self.credits = CreditsWithStreamingResponse(customers.credits) - self.balance_transactions = BalanceTransactionsWithStreamingResponse(customers.balance_transactions) + self._customers = customers self.create = to_streamed_response_wrapper( customers.create, @@ -1782,13 +1805,26 @@ def __init__(self, customers: Customers) -> None: customers.update_by_external_id, ) + @cached_property + def costs(self) -> CostsWithStreamingResponse: + return CostsWithStreamingResponse(self._customers.costs) + + @cached_property + def usage(self) -> UsageWithStreamingResponse: + return UsageWithStreamingResponse(self._customers.usage) + + @cached_property + def credits(self) -> CreditsWithStreamingResponse: + return CreditsWithStreamingResponse(self._customers.credits) + + @cached_property + def balance_transactions(self) -> BalanceTransactionsWithStreamingResponse: + return BalanceTransactionsWithStreamingResponse(self._customers.balance_transactions) + class AsyncCustomersWithStreamingResponse: def __init__(self, customers: AsyncCustomers) -> None: - self.costs = AsyncCostsWithStreamingResponse(customers.costs) - self.usage = AsyncUsageWithStreamingResponse(customers.usage) - self.credits = AsyncCreditsWithStreamingResponse(customers.credits) - self.balance_transactions = AsyncBalanceTransactionsWithStreamingResponse(customers.balance_transactions) + self._customers = customers self.create = async_to_streamed_response_wrapper( customers.create, @@ -1811,3 +1847,19 @@ def __init__(self, customers: AsyncCustomers) -> None: self.update_by_external_id = async_to_streamed_response_wrapper( customers.update_by_external_id, ) + + @cached_property + def costs(self) -> AsyncCostsWithStreamingResponse: + return AsyncCostsWithStreamingResponse(self._customers.costs) + + @cached_property + def usage(self) -> AsyncUsageWithStreamingResponse: + return AsyncUsageWithStreamingResponse(self._customers.usage) + + @cached_property + def credits(self) -> AsyncCreditsWithStreamingResponse: + return AsyncCreditsWithStreamingResponse(self._customers.credits) + + @cached_property + def balance_transactions(self) -> AsyncBalanceTransactionsWithStreamingResponse: + return AsyncBalanceTransactionsWithStreamingResponse(self._customers.balance_transactions) diff --git a/src/orb/resources/customers/usage.py b/src/orb/resources/customers/usage.py index d137dc6d..6294b568 100644 --- a/src/orb/resources/customers/usage.py +++ b/src/orb/resources/customers/usage.py @@ -660,6 +660,8 @@ async def update_by_external_id( class UsageWithRawResponse: def __init__(self, usage: Usage) -> None: + self._usage = usage + self.update = _legacy_response.to_raw_response_wrapper( usage.update, ) @@ -670,6 +672,8 @@ def __init__(self, usage: Usage) -> None: class AsyncUsageWithRawResponse: def __init__(self, usage: AsyncUsage) -> None: + self._usage = usage + self.update = _legacy_response.async_to_raw_response_wrapper( usage.update, ) @@ -680,6 +684,8 @@ def __init__(self, usage: AsyncUsage) -> None: class UsageWithStreamingResponse: def __init__(self, usage: Usage) -> None: + self._usage = usage + self.update = to_streamed_response_wrapper( usage.update, ) @@ -690,6 +696,8 @@ def __init__(self, usage: Usage) -> None: class AsyncUsageWithStreamingResponse: def __init__(self, usage: AsyncUsage) -> None: + self._usage = usage + self.update = async_to_streamed_response_wrapper( usage.update, ) diff --git a/src/orb/resources/events/backfills.py b/src/orb/resources/events/backfills.py index 9242da94..0c0867d2 100644 --- a/src/orb/resources/events/backfills.py +++ b/src/orb/resources/events/backfills.py @@ -595,6 +595,8 @@ async def revert( class BackfillsWithRawResponse: def __init__(self, backfills: Backfills) -> None: + self._backfills = backfills + self.create = _legacy_response.to_raw_response_wrapper( backfills.create, ) @@ -614,6 +616,8 @@ def __init__(self, backfills: Backfills) -> None: class AsyncBackfillsWithRawResponse: def __init__(self, backfills: AsyncBackfills) -> None: + self._backfills = backfills + self.create = _legacy_response.async_to_raw_response_wrapper( backfills.create, ) @@ -633,6 +637,8 @@ def __init__(self, backfills: AsyncBackfills) -> None: class BackfillsWithStreamingResponse: def __init__(self, backfills: Backfills) -> None: + self._backfills = backfills + self.create = to_streamed_response_wrapper( backfills.create, ) @@ -652,6 +658,8 @@ def __init__(self, backfills: Backfills) -> None: class AsyncBackfillsWithStreamingResponse: def __init__(self, backfills: AsyncBackfills) -> None: + self._backfills = backfills + self.create = async_to_streamed_response_wrapper( backfills.create, ) diff --git a/src/orb/resources/events/events.py b/src/orb/resources/events/events.py index 022642ce..a47cf782 100644 --- a/src/orb/resources/events/events.py +++ b/src/orb/resources/events/events.py @@ -1089,7 +1089,7 @@ async def search( class EventsWithRawResponse: def __init__(self, events: Events) -> None: - self.backfills = BackfillsWithRawResponse(events.backfills) + self._events = events self.update = _legacy_response.to_raw_response_wrapper( events.update, @@ -1104,10 +1104,14 @@ def __init__(self, events: Events) -> None: events.search, ) + @cached_property + def backfills(self) -> BackfillsWithRawResponse: + return BackfillsWithRawResponse(self._events.backfills) + class AsyncEventsWithRawResponse: def __init__(self, events: AsyncEvents) -> None: - self.backfills = AsyncBackfillsWithRawResponse(events.backfills) + self._events = events self.update = _legacy_response.async_to_raw_response_wrapper( events.update, @@ -1122,10 +1126,14 @@ def __init__(self, events: AsyncEvents) -> None: events.search, ) + @cached_property + def backfills(self) -> AsyncBackfillsWithRawResponse: + return AsyncBackfillsWithRawResponse(self._events.backfills) + class EventsWithStreamingResponse: def __init__(self, events: Events) -> None: - self.backfills = BackfillsWithStreamingResponse(events.backfills) + self._events = events self.update = to_streamed_response_wrapper( events.update, @@ -1140,10 +1148,14 @@ def __init__(self, events: Events) -> None: events.search, ) + @cached_property + def backfills(self) -> BackfillsWithStreamingResponse: + return BackfillsWithStreamingResponse(self._events.backfills) + class AsyncEventsWithStreamingResponse: def __init__(self, events: AsyncEvents) -> None: - self.backfills = AsyncBackfillsWithStreamingResponse(events.backfills) + self._events = events self.update = async_to_streamed_response_wrapper( events.update, @@ -1157,3 +1169,7 @@ def __init__(self, events: AsyncEvents) -> None: self.search = async_to_streamed_response_wrapper( events.search, ) + + @cached_property + def backfills(self) -> AsyncBackfillsWithStreamingResponse: + return AsyncBackfillsWithStreamingResponse(self._events.backfills) diff --git a/src/orb/resources/invoice_line_items.py b/src/orb/resources/invoice_line_items.py index 5e17dc15..a22613d8 100644 --- a/src/orb/resources/invoice_line_items.py +++ b/src/orb/resources/invoice_line_items.py @@ -181,6 +181,8 @@ async def create( class InvoiceLineItemsWithRawResponse: def __init__(self, invoice_line_items: InvoiceLineItems) -> None: + self._invoice_line_items = invoice_line_items + self.create = _legacy_response.to_raw_response_wrapper( invoice_line_items.create, ) @@ -188,6 +190,8 @@ def __init__(self, invoice_line_items: InvoiceLineItems) -> None: class AsyncInvoiceLineItemsWithRawResponse: def __init__(self, invoice_line_items: AsyncInvoiceLineItems) -> None: + self._invoice_line_items = invoice_line_items + self.create = _legacy_response.async_to_raw_response_wrapper( invoice_line_items.create, ) @@ -195,6 +199,8 @@ def __init__(self, invoice_line_items: AsyncInvoiceLineItems) -> None: class InvoiceLineItemsWithStreamingResponse: def __init__(self, invoice_line_items: InvoiceLineItems) -> None: + self._invoice_line_items = invoice_line_items + self.create = to_streamed_response_wrapper( invoice_line_items.create, ) @@ -202,6 +208,8 @@ def __init__(self, invoice_line_items: InvoiceLineItems) -> None: class AsyncInvoiceLineItemsWithStreamingResponse: def __init__(self, invoice_line_items: AsyncInvoiceLineItems) -> None: + self._invoice_line_items = invoice_line_items + self.create = async_to_streamed_response_wrapper( invoice_line_items.create, ) diff --git a/src/orb/resources/invoices.py b/src/orb/resources/invoices.py index ff251cc1..153bf2b3 100644 --- a/src/orb/resources/invoices.py +++ b/src/orb/resources/invoices.py @@ -843,6 +843,8 @@ async def void( class InvoicesWithRawResponse: def __init__(self, invoices: Invoices) -> None: + self._invoices = invoices + self.create = _legacy_response.to_raw_response_wrapper( invoices.create, ) @@ -868,6 +870,8 @@ def __init__(self, invoices: Invoices) -> None: class AsyncInvoicesWithRawResponse: def __init__(self, invoices: AsyncInvoices) -> None: + self._invoices = invoices + self.create = _legacy_response.async_to_raw_response_wrapper( invoices.create, ) @@ -893,6 +897,8 @@ def __init__(self, invoices: AsyncInvoices) -> None: class InvoicesWithStreamingResponse: def __init__(self, invoices: Invoices) -> None: + self._invoices = invoices + self.create = to_streamed_response_wrapper( invoices.create, ) @@ -918,6 +924,8 @@ def __init__(self, invoices: Invoices) -> None: class AsyncInvoicesWithStreamingResponse: def __init__(self, invoices: AsyncInvoices) -> None: + self._invoices = invoices + self.create = async_to_streamed_response_wrapper( invoices.create, ) diff --git a/src/orb/resources/items.py b/src/orb/resources/items.py index 0107eb2b..b10e4b10 100644 --- a/src/orb/resources/items.py +++ b/src/orb/resources/items.py @@ -290,6 +290,8 @@ async def fetch( class ItemsWithRawResponse: def __init__(self, items: Items) -> None: + self._items = items + self.create = _legacy_response.to_raw_response_wrapper( items.create, ) @@ -303,6 +305,8 @@ def __init__(self, items: Items) -> None: class AsyncItemsWithRawResponse: def __init__(self, items: AsyncItems) -> None: + self._items = items + self.create = _legacy_response.async_to_raw_response_wrapper( items.create, ) @@ -316,6 +320,8 @@ def __init__(self, items: AsyncItems) -> None: class ItemsWithStreamingResponse: def __init__(self, items: Items) -> None: + self._items = items + self.create = to_streamed_response_wrapper( items.create, ) @@ -329,6 +335,8 @@ def __init__(self, items: Items) -> None: class AsyncItemsWithStreamingResponse: def __init__(self, items: AsyncItems) -> None: + self._items = items + self.create = async_to_streamed_response_wrapper( items.create, ) diff --git a/src/orb/resources/metrics.py b/src/orb/resources/metrics.py index da2c9ec3..21dabdda 100644 --- a/src/orb/resources/metrics.py +++ b/src/orb/resources/metrics.py @@ -371,6 +371,8 @@ async def fetch( class MetricsWithRawResponse: def __init__(self, metrics: Metrics) -> None: + self._metrics = metrics + self.create = _legacy_response.to_raw_response_wrapper( metrics.create, ) @@ -384,6 +386,8 @@ def __init__(self, metrics: Metrics) -> None: class AsyncMetricsWithRawResponse: def __init__(self, metrics: AsyncMetrics) -> None: + self._metrics = metrics + self.create = _legacy_response.async_to_raw_response_wrapper( metrics.create, ) @@ -397,6 +401,8 @@ def __init__(self, metrics: AsyncMetrics) -> None: class MetricsWithStreamingResponse: def __init__(self, metrics: Metrics) -> None: + self._metrics = metrics + self.create = to_streamed_response_wrapper( metrics.create, ) @@ -410,6 +416,8 @@ def __init__(self, metrics: Metrics) -> None: class AsyncMetricsWithStreamingResponse: def __init__(self, metrics: AsyncMetrics) -> None: + self._metrics = metrics + self.create = async_to_streamed_response_wrapper( metrics.create, ) diff --git a/src/orb/resources/plans/external_plan_id.py b/src/orb/resources/plans/external_plan_id.py index 58cbf198..a23386f9 100644 --- a/src/orb/resources/plans/external_plan_id.py +++ b/src/orb/resources/plans/external_plan_id.py @@ -271,6 +271,8 @@ async def fetch( class ExternalPlanIDWithRawResponse: def __init__(self, external_plan_id: ExternalPlanID) -> None: + self._external_plan_id = external_plan_id + self.update = _legacy_response.to_raw_response_wrapper( external_plan_id.update, ) @@ -281,6 +283,8 @@ def __init__(self, external_plan_id: ExternalPlanID) -> None: class AsyncExternalPlanIDWithRawResponse: def __init__(self, external_plan_id: AsyncExternalPlanID) -> None: + self._external_plan_id = external_plan_id + self.update = _legacy_response.async_to_raw_response_wrapper( external_plan_id.update, ) @@ -291,6 +295,8 @@ def __init__(self, external_plan_id: AsyncExternalPlanID) -> None: class ExternalPlanIDWithStreamingResponse: def __init__(self, external_plan_id: ExternalPlanID) -> None: + self._external_plan_id = external_plan_id + self.update = to_streamed_response_wrapper( external_plan_id.update, ) @@ -301,6 +307,8 @@ def __init__(self, external_plan_id: ExternalPlanID) -> None: class AsyncExternalPlanIDWithStreamingResponse: def __init__(self, external_plan_id: AsyncExternalPlanID) -> None: + self._external_plan_id = external_plan_id + self.update = async_to_streamed_response_wrapper( external_plan_id.update, ) diff --git a/src/orb/resources/plans/plans.py b/src/orb/resources/plans/plans.py index 502ecc27..05096d62 100644 --- a/src/orb/resources/plans/plans.py +++ b/src/orb/resources/plans/plans.py @@ -552,7 +552,7 @@ async def fetch( class PlansWithRawResponse: def __init__(self, plans: Plans) -> None: - self.external_plan_id = ExternalPlanIDWithRawResponse(plans.external_plan_id) + self._plans = plans self.create = _legacy_response.to_raw_response_wrapper( plans.create, @@ -567,10 +567,14 @@ def __init__(self, plans: Plans) -> None: plans.fetch, ) + @cached_property + def external_plan_id(self) -> ExternalPlanIDWithRawResponse: + return ExternalPlanIDWithRawResponse(self._plans.external_plan_id) + class AsyncPlansWithRawResponse: def __init__(self, plans: AsyncPlans) -> None: - self.external_plan_id = AsyncExternalPlanIDWithRawResponse(plans.external_plan_id) + self._plans = plans self.create = _legacy_response.async_to_raw_response_wrapper( plans.create, @@ -585,10 +589,14 @@ def __init__(self, plans: AsyncPlans) -> None: plans.fetch, ) + @cached_property + def external_plan_id(self) -> AsyncExternalPlanIDWithRawResponse: + return AsyncExternalPlanIDWithRawResponse(self._plans.external_plan_id) + class PlansWithStreamingResponse: def __init__(self, plans: Plans) -> None: - self.external_plan_id = ExternalPlanIDWithStreamingResponse(plans.external_plan_id) + self._plans = plans self.create = to_streamed_response_wrapper( plans.create, @@ -603,10 +611,14 @@ def __init__(self, plans: Plans) -> None: plans.fetch, ) + @cached_property + def external_plan_id(self) -> ExternalPlanIDWithStreamingResponse: + return ExternalPlanIDWithStreamingResponse(self._plans.external_plan_id) + class AsyncPlansWithStreamingResponse: def __init__(self, plans: AsyncPlans) -> None: - self.external_plan_id = AsyncExternalPlanIDWithStreamingResponse(plans.external_plan_id) + self._plans = plans self.create = async_to_streamed_response_wrapper( plans.create, @@ -620,3 +632,7 @@ def __init__(self, plans: AsyncPlans) -> None: self.fetch = async_to_streamed_response_wrapper( plans.fetch, ) + + @cached_property + def external_plan_id(self) -> AsyncExternalPlanIDWithStreamingResponse: + return AsyncExternalPlanIDWithStreamingResponse(self._plans.external_plan_id) diff --git a/src/orb/resources/prices/external_price_id.py b/src/orb/resources/prices/external_price_id.py index 19417a25..b498681f 100644 --- a/src/orb/resources/prices/external_price_id.py +++ b/src/orb/resources/prices/external_price_id.py @@ -119,6 +119,8 @@ async def fetch( class ExternalPriceIDWithRawResponse: def __init__(self, external_price_id: ExternalPriceID) -> None: + self._external_price_id = external_price_id + self.fetch = _legacy_response.to_raw_response_wrapper( external_price_id.fetch, ) @@ -126,6 +128,8 @@ def __init__(self, external_price_id: ExternalPriceID) -> None: class AsyncExternalPriceIDWithRawResponse: def __init__(self, external_price_id: AsyncExternalPriceID) -> None: + self._external_price_id = external_price_id + self.fetch = _legacy_response.async_to_raw_response_wrapper( external_price_id.fetch, ) @@ -133,6 +137,8 @@ def __init__(self, external_price_id: AsyncExternalPriceID) -> None: class ExternalPriceIDWithStreamingResponse: def __init__(self, external_price_id: ExternalPriceID) -> None: + self._external_price_id = external_price_id + self.fetch = to_streamed_response_wrapper( external_price_id.fetch, ) @@ -140,6 +146,8 @@ def __init__(self, external_price_id: ExternalPriceID) -> None: class AsyncExternalPriceIDWithStreamingResponse: def __init__(self, external_price_id: AsyncExternalPriceID) -> None: + self._external_price_id = external_price_id + self.fetch = async_to_streamed_response_wrapper( external_price_id.fetch, ) diff --git a/src/orb/resources/prices/prices.py b/src/orb/resources/prices/prices.py index edf766c5..834c1759 100644 --- a/src/orb/resources/prices/prices.py +++ b/src/orb/resources/prices/prices.py @@ -2111,7 +2111,7 @@ async def fetch( class PricesWithRawResponse: def __init__(self, prices: Prices) -> None: - self.external_price_id = ExternalPriceIDWithRawResponse(prices.external_price_id) + self._prices = prices self.create = _legacy_response.to_raw_response_wrapper( prices.create, @@ -2123,10 +2123,14 @@ def __init__(self, prices: Prices) -> None: prices.fetch, ) + @cached_property + def external_price_id(self) -> ExternalPriceIDWithRawResponse: + return ExternalPriceIDWithRawResponse(self._prices.external_price_id) + class AsyncPricesWithRawResponse: def __init__(self, prices: AsyncPrices) -> None: - self.external_price_id = AsyncExternalPriceIDWithRawResponse(prices.external_price_id) + self._prices = prices self.create = _legacy_response.async_to_raw_response_wrapper( prices.create, @@ -2138,10 +2142,14 @@ def __init__(self, prices: AsyncPrices) -> None: prices.fetch, ) + @cached_property + def external_price_id(self) -> AsyncExternalPriceIDWithRawResponse: + return AsyncExternalPriceIDWithRawResponse(self._prices.external_price_id) + class PricesWithStreamingResponse: def __init__(self, prices: Prices) -> None: - self.external_price_id = ExternalPriceIDWithStreamingResponse(prices.external_price_id) + self._prices = prices self.create = to_streamed_response_wrapper( prices.create, @@ -2153,10 +2161,14 @@ def __init__(self, prices: Prices) -> None: prices.fetch, ) + @cached_property + def external_price_id(self) -> ExternalPriceIDWithStreamingResponse: + return ExternalPriceIDWithStreamingResponse(self._prices.external_price_id) + class AsyncPricesWithStreamingResponse: def __init__(self, prices: AsyncPrices) -> None: - self.external_price_id = AsyncExternalPriceIDWithStreamingResponse(prices.external_price_id) + self._prices = prices self.create = async_to_streamed_response_wrapper( prices.create, @@ -2167,3 +2179,7 @@ def __init__(self, prices: AsyncPrices) -> None: self.fetch = async_to_streamed_response_wrapper( prices.fetch, ) + + @cached_property + def external_price_id(self) -> AsyncExternalPriceIDWithStreamingResponse: + return AsyncExternalPriceIDWithStreamingResponse(self._prices.external_price_id) diff --git a/src/orb/resources/subscriptions.py b/src/orb/resources/subscriptions.py index 921e8f99..fd1e2b11 100644 --- a/src/orb/resources/subscriptions.py +++ b/src/orb/resources/subscriptions.py @@ -3308,6 +3308,8 @@ async def update_fixed_fee_quantity( class SubscriptionsWithRawResponse: def __init__(self, subscriptions: Subscriptions) -> None: + self._subscriptions = subscriptions + self.create = _legacy_response.to_raw_response_wrapper( subscriptions.create, ) @@ -3354,6 +3356,8 @@ def __init__(self, subscriptions: Subscriptions) -> None: class AsyncSubscriptionsWithRawResponse: def __init__(self, subscriptions: AsyncSubscriptions) -> None: + self._subscriptions = subscriptions + self.create = _legacy_response.async_to_raw_response_wrapper( subscriptions.create, ) @@ -3400,6 +3404,8 @@ def __init__(self, subscriptions: AsyncSubscriptions) -> None: class SubscriptionsWithStreamingResponse: def __init__(self, subscriptions: Subscriptions) -> None: + self._subscriptions = subscriptions + self.create = to_streamed_response_wrapper( subscriptions.create, ) @@ -3446,6 +3452,8 @@ def __init__(self, subscriptions: Subscriptions) -> None: class AsyncSubscriptionsWithStreamingResponse: def __init__(self, subscriptions: AsyncSubscriptions) -> None: + self._subscriptions = subscriptions + self.create = async_to_streamed_response_wrapper( subscriptions.create, ) diff --git a/src/orb/resources/top_level.py b/src/orb/resources/top_level.py index bb96d6a7..59b404ab 100644 --- a/src/orb/resources/top_level.py +++ b/src/orb/resources/top_level.py @@ -91,6 +91,8 @@ async def ping( class TopLevelWithRawResponse: def __init__(self, top_level: TopLevel) -> None: + self._top_level = top_level + self.ping = _legacy_response.to_raw_response_wrapper( top_level.ping, ) @@ -98,6 +100,8 @@ def __init__(self, top_level: TopLevel) -> None: class AsyncTopLevelWithRawResponse: def __init__(self, top_level: AsyncTopLevel) -> None: + self._top_level = top_level + self.ping = _legacy_response.async_to_raw_response_wrapper( top_level.ping, ) @@ -105,6 +109,8 @@ def __init__(self, top_level: AsyncTopLevel) -> None: class TopLevelWithStreamingResponse: def __init__(self, top_level: TopLevel) -> None: + self._top_level = top_level + self.ping = to_streamed_response_wrapper( top_level.ping, ) @@ -112,6 +118,8 @@ def __init__(self, top_level: TopLevel) -> None: class AsyncTopLevelWithStreamingResponse: def __init__(self, top_level: AsyncTopLevel) -> None: + self._top_level = top_level + self.ping = async_to_streamed_response_wrapper( top_level.ping, ) 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 diff --git a/tests/test_client.py b/tests/test_client.py index 4abc0f03..bc6164e8 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -19,7 +19,6 @@ from orb import Orb, AsyncOrb, APIResponseValidationError from orb._client import Orb, AsyncOrb from orb._models import BaseModel, FinalRequestOptions -from orb._response import APIResponse, AsyncAPIResponse from orb._constants import RAW_RESPONSE_HEADER from orb._exceptions import OrbError, APIStatusError, APITimeoutError, APIResponseValidationError from orb._base_client import DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, make_request_options @@ -676,25 +675,6 @@ def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str calculated = client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) - @pytest.mark.respx(base_url=base_url) - def test_streaming_response(self) -> None: - response = self.client.post( - "/customers", - body=dict(email="example-customer@withorb.com", name="My Customer"), - cast_to=APIResponse[bytes], - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, - ) - - assert not cast(Any, response.is_closed) - assert _get_open_connections(self.client) == 1 - - for _ in response.iter_bytes(): - ... - - assert cast(Any, response.is_closed) - assert _get_open_connections(self.client) == 0 - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: @@ -1370,25 +1350,6 @@ async def test_parse_retry_after_header(self, remaining_retries: int, retry_afte calculated = client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) - @pytest.mark.respx(base_url=base_url) - async def test_streaming_response(self) -> None: - response = await self.client.post( - "/customers", - body=dict(email="example-customer@withorb.com", name="My Customer"), - cast_to=AsyncAPIResponse[bytes], - options={"headers": {RAW_RESPONSE_HEADER: "stream"}}, - ) - - assert not cast(Any, response.is_closed) - assert _get_open_connections(self.client) == 1 - - async for _ in response.iter_bytes(): - ... - - assert cast(Any, response.is_closed) - assert _get_open_connections(self.client) == 0 - @mock.patch("orb._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) async def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter) -> None: diff --git a/tests/test_utils/test_typing.py b/tests/test_utils/test_typing.py new file mode 100644 index 00000000..c3e42410 --- /dev/null +++ b/tests/test_utils/test_typing.py @@ -0,0 +1,78 @@ +from __future__ import annotations + +from typing import Generic, TypeVar, cast + +from orb._utils import extract_type_var_from_base + +_T = TypeVar("_T") +_T2 = TypeVar("_T2") +_T3 = TypeVar("_T3") + + +class BaseGeneric(Generic[_T]): + ... + + +class SubclassGeneric(BaseGeneric[_T]): + ... + + +class BaseGenericMultipleTypeArgs(Generic[_T, _T2, _T3]): + ... + + +class SubclassGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T, _T2, _T3]): + ... + + +class SubclassDifferentOrderGenericMultipleTypeArgs(BaseGenericMultipleTypeArgs[_T2, _T, _T3]): + ... + + +def test_extract_type_var() -> None: + assert ( + extract_type_var_from_base( + BaseGeneric[int], + index=0, + generic_bases=cast("tuple[type, ...]", (BaseGeneric,)), + ) + == int + ) + + +def test_extract_type_var_generic_subclass() -> None: + assert ( + extract_type_var_from_base( + SubclassGeneric[int], + index=0, + generic_bases=cast("tuple[type, ...]", (BaseGeneric,)), + ) + == int + ) + + +def test_extract_type_var_multiple() -> None: + typ = BaseGenericMultipleTypeArgs[int, str, None] + + generic_bases = cast("tuple[type, ...]", (BaseGenericMultipleTypeArgs,)) + assert extract_type_var_from_base(typ, index=0, generic_bases=generic_bases) == int + assert extract_type_var_from_base(typ, index=1, generic_bases=generic_bases) == str + assert extract_type_var_from_base(typ, index=2, generic_bases=generic_bases) == type(None) + + +def test_extract_type_var_generic_subclass_multiple() -> None: + typ = SubclassGenericMultipleTypeArgs[int, str, None] + + generic_bases = cast("tuple[type, ...]", (BaseGenericMultipleTypeArgs,)) + assert extract_type_var_from_base(typ, index=0, generic_bases=generic_bases) == int + assert extract_type_var_from_base(typ, index=1, generic_bases=generic_bases) == str + assert extract_type_var_from_base(typ, index=2, generic_bases=generic_bases) == type(None) + + +def test_extract_type_var_generic_subclass_different_ordering_multiple() -> None: + typ = SubclassDifferentOrderGenericMultipleTypeArgs[int, str, None] + + generic_bases = cast("tuple[type, ...]", (BaseGenericMultipleTypeArgs,)) + assert extract_type_var_from_base(typ, index=0, generic_bases=generic_bases) == int + assert extract_type_var_from_base(typ, index=1, generic_bases=generic_bases) == str + assert extract_type_var_from_base(typ, index=2, generic_bases=generic_bases) == type(None)