diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b7fd5a5..f2dde44 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,24 +35,40 @@ jobs: - name: Run lints run: ./scripts/lint - upload: - if: github.repository == 'stainless-sdks/zbd-payments-python' && (github.event_name == 'push' || github.event.pull_request.head.repo.fork) + build: + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork timeout-minutes: 10 - name: upload + name: build permissions: contents: read id-token: write - runs-on: depot-ubuntu-24.04 + runs-on: ${{ github.repository == 'stainless-sdks/zbd-payments-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} steps: - uses: actions/checkout@v4 + - name: Install Rye + run: | + curl -sSf https://rye.astral.sh/get | bash + echo "$HOME/.rye/shims" >> $GITHUB_PATH + env: + RYE_VERSION: '0.44.0' + RYE_INSTALL_OPTION: '--yes' + + - name: Install dependencies + run: rye sync --all-features + + - name: Run build + run: rye build + - name: Get GitHub OIDC Token + if: github.repository == 'stainless-sdks/zbd-payments-python' id: github-oidc uses: actions/github-script@v6 with: script: core.setOutput('github_token', await core.getIDToken()); - name: Upload tarball + if: github.repository == 'stainless-sdks/zbd-payments-python' env: URL: https://pkg.stainless.com/s AUTH: ${{ steps.github-oidc.outputs.github_token }} diff --git a/.gitignore b/.gitignore index 8779740..95ceb18 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ .prism.log -.vscode _dev __pycache__ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ba6c348..f14b480 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.1.0-alpha.1" + ".": "0.1.0-alpha.2" } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..5b01030 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "python.analysis.importFormat": "relative", +} diff --git a/CHANGELOG.md b/CHANGELOG.md index ff5a4a9..18cf7f6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,53 @@ # Changelog +## 0.1.0-alpha.2 (2025-11-04) + +Full Changelog: [v0.1.0-alpha.1...v0.1.0-alpha.2](https://github.com/zbdpay/zbd-payments-python-sdk/compare/v0.1.0-alpha.1...v0.1.0-alpha.2) + +### Features + +* clean up environment call outs ([535e5ab](https://github.com/zbdpay/zbd-payments-python-sdk/commit/535e5abe6894630fd12397c95e9fdcb0bdfcf658)) +* **client:** support file upload requests ([b3a0224](https://github.com/zbdpay/zbd-payments-python-sdk/commit/b3a02242d357e96493899e6acb0f283b83060aef)) +* improve future compat with pydantic v3 ([1c2b2a0](https://github.com/zbdpay/zbd-payments-python-sdk/commit/1c2b2a067518c006ed2ea1d5e3f3c28f2868b55e)) +* **types:** replace List[str] with SequenceNotStr in params ([3a6e9d2](https://github.com/zbdpay/zbd-payments-python-sdk/commit/3a6e9d20ae545ee635cd86b7ae4b7b1f4705763f)) + + +### Bug Fixes + +* avoid newer type syntax ([5b84026](https://github.com/zbdpay/zbd-payments-python-sdk/commit/5b840269faac165f86335e1177eccbc3d47651c0)) +* **client:** close streams without requiring full consumption ([5f08b58](https://github.com/zbdpay/zbd-payments-python-sdk/commit/5f08b58994542a3fb4b2f9a4a766f545b1c8d809)) +* **client:** don't send Content-Type header on GET requests ([288eb7d](https://github.com/zbdpay/zbd-payments-python-sdk/commit/288eb7dbc10084e010006e07a0b6ae8bc31830f8)) +* **parsing:** correctly handle nested discriminated unions ([2ba6e54](https://github.com/zbdpay/zbd-payments-python-sdk/commit/2ba6e54f3688d3606a32b54e67858a9c1121ed03)) +* **parsing:** ignore empty metadata ([6810653](https://github.com/zbdpay/zbd-payments-python-sdk/commit/6810653d722e8eb4b5531d1a120035001942e039)) +* **parsing:** parse extra field types ([f952799](https://github.com/zbdpay/zbd-payments-python-sdk/commit/f9527997050c628fee3f05b76420e1449238d13b)) + + +### Chores + +* bump `httpx-aiohttp` version to 0.1.9 ([127bafc](https://github.com/zbdpay/zbd-payments-python-sdk/commit/127bafcd8d74f9dffa1c574b9b3cccc92e7f18ef)) +* **ci:** change upload type ([9c44657](https://github.com/zbdpay/zbd-payments-python-sdk/commit/9c4465773de134e1ecacb494a4f3f3c5f174146b)) +* do not install brew dependencies in ./scripts/bootstrap by default ([fea8954](https://github.com/zbdpay/zbd-payments-python-sdk/commit/fea89541e9d5e4373720e0639d09d574b6b681be)) +* **internal/tests:** avoid race condition with implicit client cleanup ([81b1d27](https://github.com/zbdpay/zbd-payments-python-sdk/commit/81b1d27d18635a5ee76009d44be19da36b3ccaf8)) +* **internal:** add Sequence related utils ([9159c6d](https://github.com/zbdpay/zbd-payments-python-sdk/commit/9159c6d5474db3fb12ec5597b817c17c4151230a)) +* **internal:** bump pinned h11 dep ([3938712](https://github.com/zbdpay/zbd-payments-python-sdk/commit/3938712b4835065e531e220a3e277bd84c0a6cf8)) +* **internal:** change ci workflow machines ([94573cf](https://github.com/zbdpay/zbd-payments-python-sdk/commit/94573cffbdaaa47ea3c04c8c08594ef8bcf515a9)) +* **internal:** codegen related update ([b0af041](https://github.com/zbdpay/zbd-payments-python-sdk/commit/b0af041c74a92ea2be802ba5470c1f76a6b6c22d)) +* **internal:** codegen related update ([281314a](https://github.com/zbdpay/zbd-payments-python-sdk/commit/281314a9a7b24c8e61947df03ec796e162475447)) +* **internal:** codegen related update ([f6b6595](https://github.com/zbdpay/zbd-payments-python-sdk/commit/f6b6595872a031ad6fa6dd2b48f3ed7259fcdd55)) +* **internal:** detect missing future annotations with ruff ([8c6c43a](https://github.com/zbdpay/zbd-payments-python-sdk/commit/8c6c43a7f9ecb965948a2c0c4e45ede5929e3f2d)) +* **internal:** fix ruff target version ([bfb7eb6](https://github.com/zbdpay/zbd-payments-python-sdk/commit/bfb7eb6f5f90f2eef5be4714c25d2335cd340956)) +* **internal:** grammar fix (it's -> its) ([5aa138a](https://github.com/zbdpay/zbd-payments-python-sdk/commit/5aa138a2baca8ff95452be8dd90cb916d909a09d)) +* **internal:** update comment in script ([da3e700](https://github.com/zbdpay/zbd-payments-python-sdk/commit/da3e7007adac9551b21b7525c895538b0072e3de)) +* **internal:** update pydantic dependency ([6febfc0](https://github.com/zbdpay/zbd-payments-python-sdk/commit/6febfc07161f1678bd35a446b2fd618a7c08fc8d)) +* **internal:** update pyright exclude list ([e087e8a](https://github.com/zbdpay/zbd-payments-python-sdk/commit/e087e8abacb81f209f9a9746ee4f5e666d21d36d)) +* **package:** mark python 3.13 as supported ([ca53a0e](https://github.com/zbdpay/zbd-payments-python-sdk/commit/ca53a0eaa744e881b8d24a05f2d35049a9815682)) +* **project:** add settings file for vscode ([36c1d48](https://github.com/zbdpay/zbd-payments-python-sdk/commit/36c1d48714b6c9750dd885ee93c5e041f4a6e59e)) +* **readme:** fix version rendering on pypi ([337d17e](https://github.com/zbdpay/zbd-payments-python-sdk/commit/337d17e1d4ad645f55793d615ebd9f328fdef08a)) +* **tests:** simplify `get_platform` test ([c354e32](https://github.com/zbdpay/zbd-payments-python-sdk/commit/c354e32d12201983196cde30acd370ee6e6c0941)) +* **types:** change optional parameter type from NotGiven to Omit ([037353e](https://github.com/zbdpay/zbd-payments-python-sdk/commit/037353e3016446a51197a1dafdb9f50ca4156804)) +* update @stainless-api/prism-cli to v5.15.0 ([f365ac1](https://github.com/zbdpay/zbd-payments-python-sdk/commit/f365ac1076dab4f1f57bb95878560a7eb94731a1)) +* update github action ([cc78ddf](https://github.com/zbdpay/zbd-payments-python-sdk/commit/cc78ddff5b244d94a49e6558dfe665d156791c58)) + ## 0.1.0-alpha.1 (2025-06-30) Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/zbdpay/zbd-payments-python-sdk/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) diff --git a/README.md b/README.md index e542d16..55d4625 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ # ZBD Payments Python API library -[![PyPI version]()](https://pypi.org/project/zbdpay/) + +[![PyPI version](https://img.shields.io/pypi/v/zbdpay.svg?label=pypi%20(stable))](https://pypi.org/project/zbdpay/) The ZBD Payments Python library provides convenient access to the ZBD Payments REST API from any Python 3.8+ application. The library includes type definitions for all request params and response fields, @@ -82,7 +83,6 @@ pip install --pre zbdpay[aiohttp] Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`: ```python -import os import asyncio from zbdpay import DefaultAioHttpClient from zbdpay import AsyncZbdPayments @@ -90,7 +90,7 @@ from zbdpay import AsyncZbdPayments async def main() -> None: async with AsyncZbdPayments( - apikey=os.environ.get("ZBD_PAYMENTS_API_KEY"), # This is the default and can be omitted + apikey="My Apikey", http_client=DefaultAioHttpClient(), ) as client: await client.lightning_address.send_payment( diff --git a/mypy.ini b/mypy.ini deleted file mode 100644 index 3b7f727..0000000 --- a/mypy.ini +++ /dev/null @@ -1,50 +0,0 @@ -[mypy] -pretty = True -show_error_codes = True - -# Exclude _files.py because mypy isn't smart enough to apply -# the correct type narrowing and as this is an internal module -# it's fine to just use Pyright. -# -# We also exclude our `tests` as mypy doesn't always infer -# types correctly and Pyright will still catch any type errors. -exclude = ^(src/zbdpay/_files\.py|_dev/.*\.py|tests/.*)$ - -strict_equality = True -implicit_reexport = True -check_untyped_defs = True -no_implicit_optional = True - -warn_return_any = True -warn_unreachable = True -warn_unused_configs = True - -# Turn these options off as it could cause conflicts -# with the Pyright options. -warn_unused_ignores = False -warn_redundant_casts = False - -disallow_any_generics = True -disallow_untyped_defs = True -disallow_untyped_calls = True -disallow_subclassing_any = True -disallow_incomplete_defs = True -disallow_untyped_decorators = True -cache_fine_grained = True - -# By default, mypy reports an error if you assign a value to the result -# of a function call that doesn't return anything. We do this in our test -# cases: -# ``` -# result = ... -# assert result is None -# ``` -# Changing this codegen to make mypy happy would increase complexity -# and would not be worth it. -disable_error_code = func-returns-value,overload-cannot-match - -# https://github.com/python/mypy/issues/12162 -[mypy.overrides] -module = "black.files.*" -ignore_errors = true -ignore_missing_imports = true diff --git a/pyproject.toml b/pyproject.toml index b98948b..237f5ea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "zbdpay" -version = "0.1.0-alpha.1" +version = "0.1.0-alpha.2" description = "The official Python library for the zbd-payments API" dynamic = ["readme"] license = "MIT" @@ -24,6 +24,7 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Operating System :: OS Independent", "Operating System :: POSIX", "Operating System :: MacOS", @@ -38,7 +39,7 @@ Homepage = "https://github.com/zbdpay/zbd-payments-python-sdk" Repository = "https://github.com/zbdpay/zbd-payments-python-sdk" [project.optional-dependencies] -aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"] +aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.9"] [tool.rye] managed = true @@ -55,7 +56,6 @@ dev-dependencies = [ "dirty-equals>=0.6.0", "importlib-metadata>=6.7.0", "rich>=13.7.1", - "nest_asyncio==1.6.0", "pytest-xdist>=3.6.1", ] @@ -147,6 +147,7 @@ exclude = [ "_dev", ".venv", ".nox", + ".git", ] reportImplicitOverride = true @@ -155,10 +156,62 @@ reportOverlappingOverload = false reportImportCycles = false reportPrivateUsage = false +[tool.mypy] +pretty = true +show_error_codes = true + +# Exclude _files.py because mypy isn't smart enough to apply +# the correct type narrowing and as this is an internal module +# it's fine to just use Pyright. +# +# We also exclude our `tests` as mypy doesn't always infer +# types correctly and Pyright will still catch any type errors. +exclude = ['src/zbdpay/_files.py', '_dev/.*.py', 'tests/.*'] + +strict_equality = true +implicit_reexport = true +check_untyped_defs = true +no_implicit_optional = true + +warn_return_any = true +warn_unreachable = true +warn_unused_configs = true + +# Turn these options off as it could cause conflicts +# with the Pyright options. +warn_unused_ignores = false +warn_redundant_casts = false + +disallow_any_generics = true +disallow_untyped_defs = true +disallow_untyped_calls = true +disallow_subclassing_any = true +disallow_incomplete_defs = true +disallow_untyped_decorators = true +cache_fine_grained = true + +# By default, mypy reports an error if you assign a value to the result +# of a function call that doesn't return anything. We do this in our test +# cases: +# ``` +# result = ... +# assert result is None +# ``` +# Changing this codegen to make mypy happy would increase complexity +# and would not be worth it. +disable_error_code = "func-returns-value,overload-cannot-match" + +# https://github.com/python/mypy/issues/12162 +[[tool.mypy.overrides]] +module = "black.files.*" +ignore_errors = true +ignore_missing_imports = true + + [tool.ruff] line-length = 120 output-format = "grouped" -target-version = "py37" +target-version = "py38" [tool.ruff.format] docstring-code-format = true @@ -171,6 +224,8 @@ select = [ "B", # remove unused imports "F401", + # check for missing future annotations + "FA102", # bare except statements "E722", # unused arguments @@ -193,6 +248,8 @@ unfixable = [ "T203", ] +extend-safe-fixes = ["FA102"] + [tool.ruff.lint.flake8-tidy-imports.banned-api] "functools.lru_cache".msg = "This function does not retain type information for the wrapped function's arguments; The `lru_cache` function from `_utils` should be used instead" diff --git a/requirements-dev.lock b/requirements-dev.lock index 3b58ba1..880e4e3 100644 --- a/requirements-dev.lock +++ b/requirements-dev.lock @@ -48,15 +48,15 @@ filelock==3.12.4 frozenlist==1.6.2 # via aiohttp # via aiosignal -h11==0.14.0 +h11==0.16.0 # via httpcore -httpcore==1.0.2 +httpcore==1.0.9 # via httpx httpx==0.28.1 # via httpx-aiohttp # via respx # via zbdpay -httpx-aiohttp==0.1.6 +httpx-aiohttp==0.1.9 # via zbdpay idna==3.4 # via anyio @@ -75,7 +75,6 @@ multidict==6.4.4 mypy==1.14.1 mypy-extensions==1.0.0 # via mypy -nest-asyncio==1.6.0 nodeenv==1.8.0 # via pyright nox==2023.4.22 @@ -89,9 +88,9 @@ pluggy==1.5.0 propcache==0.3.1 # via aiohttp # via yarl -pydantic==2.10.3 +pydantic==2.11.9 # via zbdpay -pydantic-core==2.27.1 +pydantic-core==2.33.2 # via pydantic pygments==2.18.0 # via rich @@ -126,7 +125,10 @@ typing-extensions==4.12.2 # via pydantic # via pydantic-core # via pyright + # via typing-inspection # via zbdpay +typing-inspection==0.4.1 + # via pydantic virtualenv==20.24.5 # via nox yarl==1.20.0 diff --git a/requirements.lock b/requirements.lock index 8e652de..46e9a67 100644 --- a/requirements.lock +++ b/requirements.lock @@ -36,14 +36,14 @@ exceptiongroup==1.2.2 frozenlist==1.6.2 # via aiohttp # via aiosignal -h11==0.14.0 +h11==0.16.0 # via httpcore -httpcore==1.0.2 +httpcore==1.0.9 # via httpx httpx==0.28.1 # via httpx-aiohttp # via zbdpay -httpx-aiohttp==0.1.6 +httpx-aiohttp==0.1.9 # via zbdpay idna==3.4 # via anyio @@ -55,9 +55,9 @@ multidict==6.4.4 propcache==0.3.1 # via aiohttp # via yarl -pydantic==2.10.3 +pydantic==2.11.9 # via zbdpay -pydantic-core==2.27.1 +pydantic-core==2.33.2 # via pydantic sniffio==1.3.0 # via anyio @@ -67,6 +67,9 @@ typing-extensions==4.12.2 # via multidict # via pydantic # via pydantic-core + # via typing-inspection # via zbdpay +typing-inspection==0.4.1 + # via pydantic yarl==1.20.0 # via aiohttp diff --git a/scripts/bootstrap b/scripts/bootstrap index e84fe62..b430fee 100755 --- a/scripts/bootstrap +++ b/scripts/bootstrap @@ -4,10 +4,18 @@ set -e cd "$(dirname "$0")/.." -if ! command -v rye >/dev/null 2>&1 && [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ]; then +if [ -f "Brewfile" ] && [ "$(uname -s)" = "Darwin" ] && [ "$SKIP_BREW" != "1" ] && [ -t 0 ]; then brew bundle check >/dev/null 2>&1 || { - echo "==> Installing Homebrew dependencies…" - brew bundle + echo -n "==> Install Homebrew dependencies? (y/N): " + read -r response + case "$response" in + [yY][eE][sS]|[yY]) + brew bundle + ;; + *) + ;; + esac + echo } fi diff --git a/scripts/mock b/scripts/mock index d2814ae..0b28f6e 100755 --- a/scripts/mock +++ b/scripts/mock @@ -21,7 +21,7 @@ echo "==> Starting mock server with URL ${URL}" # Run prism mock on the given spec if [ "$1" == "--daemon" ]; then - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" &> .prism.log & + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" &> .prism.log & # Wait for server to come online echo -n "Waiting for server" @@ -37,5 +37,5 @@ if [ "$1" == "--daemon" ]; then echo else - npm exec --package=@stainless-api/prism-cli@5.8.5 -- prism mock "$URL" + npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock "$URL" fi diff --git a/scripts/test b/scripts/test index 2b87845..dbeda2d 100755 --- a/scripts/test +++ b/scripts/test @@ -43,7 +43,7 @@ elif ! prism_is_running ; then echo -e "To run the server, pass in the path or url of your OpenAPI" echo -e "spec to the prism command:" echo - echo -e " \$ ${YELLOW}npm exec --package=@stoplight/prism-cli@~5.3.2 -- prism mock path/to/your.openapi.yml${NC}" + echo -e " \$ ${YELLOW}npm exec --package=@stainless-api/prism-cli@5.15.0 -- prism mock path/to/your.openapi.yml${NC}" echo exit 1 diff --git a/scripts/utils/upload-artifact.sh b/scripts/utils/upload-artifact.sh index 2d61a83..9d9d441 100755 --- a/scripts/utils/upload-artifact.sh +++ b/scripts/utils/upload-artifact.sh @@ -1,7 +1,9 @@ #!/usr/bin/env bash set -exuo pipefail -RESPONSE=$(curl -X POST "$URL" \ +FILENAME=$(basename dist/*.whl) + +RESPONSE=$(curl -X POST "$URL?filename=$FILENAME" \ -H "Authorization: Bearer $AUTH" \ -H "Content-Type: application/json") @@ -12,13 +14,13 @@ if [[ "$SIGNED_URL" == "null" ]]; then exit 1 fi -UPLOAD_RESPONSE=$(tar -cz . | curl -v -X PUT \ - -H "Content-Type: application/gzip" \ - --data-binary @- "$SIGNED_URL" 2>&1) +UPLOAD_RESPONSE=$(curl -v -X PUT \ + -H "Content-Type: binary/octet-stream" \ + --data-binary "@dist/$FILENAME" "$SIGNED_URL" 2>&1) if echo "$UPLOAD_RESPONSE" | grep -q "HTTP/[0-9.]* 200"; then echo -e "\033[32mUploaded build to Stainless storage.\033[0m" - echo -e "\033[32mInstallation: pip install --pre 'https://pkg.stainless.com/s/zbd-payments-python/$SHA'\033[0m" + echo -e "\033[32mInstallation: pip install 'https://pkg.stainless.com/s/zbd-payments-python/$SHA/$FILENAME'\033[0m" else echo -e "\033[31mFailed to upload artifact.\033[0m" exit 1 diff --git a/src/zbdpay/__init__.py b/src/zbdpay/__init__.py index f16e3ad..f4e0ea5 100644 --- a/src/zbdpay/__init__.py +++ b/src/zbdpay/__init__.py @@ -3,7 +3,7 @@ import typing as _t from . import types -from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes +from ._types import NOT_GIVEN, Omit, NoneType, NotGiven, Transport, ProxiesTypes, omit, not_given from ._utils import file_from_path from ._client import ( Client, @@ -48,7 +48,9 @@ "ProxiesTypes", "NotGiven", "NOT_GIVEN", + "not_given", "Omit", + "omit", "ZbdPaymentsError", "APIError", "APIStatusError", diff --git a/src/zbdpay/_base_client.py b/src/zbdpay/_base_client.py index 36ba603..c56ccb9 100644 --- a/src/zbdpay/_base_client.py +++ b/src/zbdpay/_base_client.py @@ -42,7 +42,6 @@ from ._qs import Querystring from ._files import to_httpx_files, async_to_httpx_files from ._types import ( - NOT_GIVEN, Body, Omit, Query, @@ -57,9 +56,10 @@ RequestOptions, HttpxRequestFiles, ModelBuilderProtocol, + not_given, ) from ._utils import is_dict, is_list, asyncify, is_given, lru_cache, is_mapping -from ._compat import PYDANTIC_V2, model_copy, model_dump +from ._compat import PYDANTIC_V1, model_copy, model_dump from ._models import GenericModel, FinalRequestOptions, validate_type, construct_type from ._response import ( APIResponse, @@ -145,9 +145,9 @@ def __init__( def __init__( self, *, - url: URL | NotGiven = NOT_GIVEN, - json: Body | NotGiven = NOT_GIVEN, - params: Query | NotGiven = NOT_GIVEN, + url: URL | NotGiven = not_given, + json: Body | NotGiven = not_given, + params: Query | NotGiven = not_given, ) -> None: self.url = url self.json = json @@ -232,7 +232,7 @@ def _set_private_attributes( model: Type[_T], options: FinalRequestOptions, ) -> None: - if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None: self.__pydantic_private__ = {} self._model = model @@ -320,7 +320,7 @@ def _set_private_attributes( client: AsyncAPIClient, options: FinalRequestOptions, ) -> None: - if PYDANTIC_V2 and getattr(self, "__pydantic_private__", None) is None: + if (not PYDANTIC_V1) and getattr(self, "__pydantic_private__", None) is None: self.__pydantic_private__ = {} self._model = model @@ -529,6 +529,18 @@ def _build_request( # work around https://github.com/encode/httpx/discussions/2880 kwargs["extensions"] = {"sni_hostname": prepared_url.host.replace("_", "-")} + is_body_allowed = options.method.lower() != "get" + + if is_body_allowed: + if isinstance(json_data, bytes): + kwargs["content"] = json_data + else: + kwargs["json"] = json_data if is_given(json_data) else None + kwargs["files"] = files + else: + headers.pop("Content-Type", None) + kwargs.pop("data", None) + # TODO: report this error to httpx return self._client.build_request( # pyright: ignore[reportUnknownMemberType] headers=headers, @@ -540,8 +552,6 @@ def _build_request( # so that passing a `TypedDict` doesn't cause an error. # https://github.com/microsoft/pyright/issues/3526#event-6715453066 params=self.qs.stringify(cast(Mapping[str, Any], params)) if params else None, - json=json_data if is_given(json_data) else None, - files=files, **kwargs, ) @@ -585,7 +595,7 @@ def _maybe_override_cast_to(self, cast_to: type[ResponseT], options: FinalReques # we internally support defining a temporary header to override the # default `cast_to` type for use with `.with_raw_response` and `.with_streaming_response` # see _response.py for implementation details - override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, NOT_GIVEN) + override_cast_to = headers.pop(OVERRIDE_CAST_TO_HEADER, not_given) if is_given(override_cast_to): options.headers = headers return cast(Type[ResponseT], override_cast_to) @@ -815,7 +825,7 @@ def __init__( version: str, base_url: str | URL, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, @@ -1346,7 +1356,7 @@ def __init__( base_url: str | URL, _strict_response_validation: bool, max_retries: int = DEFAULT_MAX_RETRIES, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, custom_headers: Mapping[str, str] | None = None, custom_query: Mapping[str, object] | None = None, @@ -1808,8 +1818,8 @@ def make_request_options( extra_query: Query | None = None, extra_body: Body | None = None, idempotency_key: str | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - post_parser: PostParser | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, + post_parser: PostParser | NotGiven = not_given, ) -> RequestOptions: """Create a dict of type RequestOptions without keys of NotGiven values.""" options: RequestOptions = {} diff --git a/src/zbdpay/_client.py b/src/zbdpay/_client.py index 7af0e3c..25a37dd 100644 --- a/src/zbdpay/_client.py +++ b/src/zbdpay/_client.py @@ -3,7 +3,7 @@ from __future__ import annotations import os -from typing import Any, Union, Mapping +from typing import Any, Mapping from typing_extensions import Self, override import httpx @@ -11,7 +11,6 @@ from . import _exceptions from ._qs import Querystring from ._types import ( - NOT_GIVEN, Omit, Headers, Timeout, @@ -19,6 +18,7 @@ Transport, ProxiesTypes, RequestOptions, + not_given, ) from ._utils import is_given, get_async_library from ._version import __version__ @@ -82,7 +82,7 @@ def __init__( *, apikey: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -178,9 +178,9 @@ def copy( *, apikey: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.Client | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -283,7 +283,7 @@ def __init__( *, apikey: str | None = None, base_url: str | httpx.URL | None = None, - timeout: Union[float, Timeout, None, NotGiven] = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, max_retries: int = DEFAULT_MAX_RETRIES, default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, @@ -379,9 +379,9 @@ def copy( *, apikey: str | None = None, base_url: str | httpx.URL | None = None, - timeout: float | Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | Timeout | None | NotGiven = not_given, http_client: httpx.AsyncClient | None = None, - max_retries: int | NotGiven = NOT_GIVEN, + max_retries: int | NotGiven = not_given, default_headers: Mapping[str, str] | None = None, set_default_headers: Mapping[str, str] | None = None, default_query: Mapping[str, object] | None = None, diff --git a/src/zbdpay/_compat.py b/src/zbdpay/_compat.py index 92d9ee6..bdef67f 100644 --- a/src/zbdpay/_compat.py +++ b/src/zbdpay/_compat.py @@ -12,14 +12,13 @@ _T = TypeVar("_T") _ModelT = TypeVar("_ModelT", bound=pydantic.BaseModel) -# --------------- Pydantic v2 compatibility --------------- +# --------------- Pydantic v2, v3 compatibility --------------- # Pyright incorrectly reports some of our functions as overriding a method when they don't # pyright: reportIncompatibleMethodOverride=false -PYDANTIC_V2 = pydantic.VERSION.startswith("2.") +PYDANTIC_V1 = pydantic.VERSION.startswith("1.") -# v1 re-exports if TYPE_CHECKING: def parse_date(value: date | StrBytesIntFloat) -> date: # noqa: ARG001 @@ -44,90 +43,92 @@ def is_typeddict(type_: type[Any]) -> bool: # noqa: ARG001 ... else: - if PYDANTIC_V2: - from pydantic.v1.typing import ( + # v1 re-exports + if PYDANTIC_V1: + from pydantic.typing import ( get_args as get_args, is_union as is_union, get_origin as get_origin, is_typeddict as is_typeddict, is_literal_type as is_literal_type, ) - from pydantic.v1.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime + from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime else: - from pydantic.typing import ( + from ._utils import ( get_args as get_args, is_union as is_union, get_origin as get_origin, + parse_date as parse_date, is_typeddict as is_typeddict, + parse_datetime as parse_datetime, is_literal_type as is_literal_type, ) - from pydantic.datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime # refactored config if TYPE_CHECKING: from pydantic import ConfigDict as ConfigDict else: - if PYDANTIC_V2: - from pydantic import ConfigDict - else: + if PYDANTIC_V1: # TODO: provide an error message here? ConfigDict = None + else: + from pydantic import ConfigDict as ConfigDict # renamed methods / properties def parse_obj(model: type[_ModelT], value: object) -> _ModelT: - if PYDANTIC_V2: - return model.model_validate(value) - else: + if PYDANTIC_V1: return cast(_ModelT, model.parse_obj(value)) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + else: + return model.model_validate(value) def field_is_required(field: FieldInfo) -> bool: - if PYDANTIC_V2: - return field.is_required() - return field.required # type: ignore + if PYDANTIC_V1: + return field.required # type: ignore + return field.is_required() def field_get_default(field: FieldInfo) -> Any: value = field.get_default() - if PYDANTIC_V2: - from pydantic_core import PydanticUndefined - - if value == PydanticUndefined: - return None + if PYDANTIC_V1: return value + from pydantic_core import PydanticUndefined + + if value == PydanticUndefined: + return None return value def field_outer_type(field: FieldInfo) -> Any: - if PYDANTIC_V2: - return field.annotation - return field.outer_type_ # type: ignore + if PYDANTIC_V1: + return field.outer_type_ # type: ignore + return field.annotation def get_model_config(model: type[pydantic.BaseModel]) -> Any: - if PYDANTIC_V2: - return model.model_config - return model.__config__ # type: ignore + if PYDANTIC_V1: + return model.__config__ # type: ignore + return model.model_config def get_model_fields(model: type[pydantic.BaseModel]) -> dict[str, FieldInfo]: - if PYDANTIC_V2: - return model.model_fields - return model.__fields__ # type: ignore + if PYDANTIC_V1: + return model.__fields__ # type: ignore + return model.model_fields def model_copy(model: _ModelT, *, deep: bool = False) -> _ModelT: - if PYDANTIC_V2: - return model.model_copy(deep=deep) - return model.copy(deep=deep) # type: ignore + if PYDANTIC_V1: + return model.copy(deep=deep) # type: ignore + return model.model_copy(deep=deep) def model_json(model: pydantic.BaseModel, *, indent: int | None = None) -> str: - if PYDANTIC_V2: - return model.model_dump_json(indent=indent) - return model.json(indent=indent) # type: ignore + if PYDANTIC_V1: + return model.json(indent=indent) # type: ignore + return model.model_dump_json(indent=indent) def model_dump( @@ -139,14 +140,14 @@ def model_dump( warnings: bool = True, mode: Literal["json", "python"] = "python", ) -> dict[str, Any]: - if PYDANTIC_V2 or hasattr(model, "model_dump"): + if (not PYDANTIC_V1) or hasattr(model, "model_dump"): return model.model_dump( mode=mode, exclude=exclude, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, # warnings are not supported in Pydantic v1 - warnings=warnings if PYDANTIC_V2 else True, + warnings=True if PYDANTIC_V1 else warnings, ) return cast( "dict[str, Any]", @@ -159,9 +160,9 @@ def model_dump( def model_parse(model: type[_ModelT], data: Any) -> _ModelT: - if PYDANTIC_V2: - return model.model_validate(data) - return model.parse_obj(data) # pyright: ignore[reportDeprecated] + if PYDANTIC_V1: + return model.parse_obj(data) # pyright: ignore[reportDeprecated] + return model.model_validate(data) # generic models @@ -170,17 +171,16 @@ def model_parse(model: type[_ModelT], data: Any) -> _ModelT: class GenericModel(pydantic.BaseModel): ... else: - if PYDANTIC_V2: + if PYDANTIC_V1: + import pydantic.generics + + class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ... + else: # there no longer needs to be a distinction in v2 but # we still have to create our own subclass to avoid # inconsistent MRO ordering errors class GenericModel(pydantic.BaseModel): ... - else: - import pydantic.generics - - class GenericModel(pydantic.generics.GenericModel, pydantic.BaseModel): ... - # cached properties if TYPE_CHECKING: diff --git a/src/zbdpay/_files.py b/src/zbdpay/_files.py index 715cc20..cc14c14 100644 --- a/src/zbdpay/_files.py +++ b/src/zbdpay/_files.py @@ -69,12 +69,12 @@ def _transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], _read_file_content(file[1]), *file[2:]) + return (file[0], read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -def _read_file_content(file: FileContent) -> HttpxFileContent: +def read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return pathlib.Path(file).read_bytes() return file @@ -111,12 +111,12 @@ async def _async_transform_file(file: FileTypes) -> HttpxFileTypes: return file if is_tuple_t(file): - return (file[0], await _async_read_file_content(file[1]), *file[2:]) + return (file[0], await async_read_file_content(file[1]), *file[2:]) raise TypeError(f"Expected file types input to be a FileContent type or to be a tuple") -async def _async_read_file_content(file: FileContent) -> HttpxFileContent: +async def async_read_file_content(file: FileContent) -> HttpxFileContent: if isinstance(file, os.PathLike): return await anyio.Path(file).read_bytes() diff --git a/src/zbdpay/_models.py b/src/zbdpay/_models.py index 4f21498..6a3cd1d 100644 --- a/src/zbdpay/_models.py +++ b/src/zbdpay/_models.py @@ -2,9 +2,10 @@ import os import inspect -from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, cast +from typing import TYPE_CHECKING, Any, Type, Union, Generic, TypeVar, Callable, Optional, cast from datetime import date, datetime from typing_extensions import ( + List, Unpack, Literal, ClassVar, @@ -49,7 +50,7 @@ strip_annotated_type, ) from ._compat import ( - PYDANTIC_V2, + PYDANTIC_V1, ConfigDict, GenericModel as BaseGenericModel, get_args, @@ -80,11 +81,7 @@ class _ConfigProtocol(Protocol): class BaseModel(pydantic.BaseModel): - if PYDANTIC_V2: - model_config: ClassVar[ConfigDict] = ConfigDict( - extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")) - ) - else: + if PYDANTIC_V1: @property @override @@ -94,6 +91,10 @@ def model_fields_set(self) -> set[str]: class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated] extra: Any = pydantic.Extra.allow # type: ignore + else: + model_config: ClassVar[ConfigDict] = ConfigDict( + extra="allow", defer_build=coerce_boolean(os.environ.get("DEFER_PYDANTIC_BUILD", "true")) + ) def to_dict( self, @@ -207,28 +208,32 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride] else: fields_values[name] = field_get_default(field) + extra_field_type = _get_extra_fields_type(__cls) + _extra = {} for key, value in values.items(): if key not in model_fields: - if PYDANTIC_V2: - _extra[key] = value - else: + parsed = construct_type(value=value, type_=extra_field_type) if extra_field_type is not None else value + + if PYDANTIC_V1: _fields_set.add(key) - fields_values[key] = value + fields_values[key] = parsed + else: + _extra[key] = parsed object.__setattr__(m, "__dict__", fields_values) - if PYDANTIC_V2: - # these properties are copied from Pydantic's `model_construct()` method - object.__setattr__(m, "__pydantic_private__", None) - object.__setattr__(m, "__pydantic_extra__", _extra) - object.__setattr__(m, "__pydantic_fields_set__", _fields_set) - else: + if PYDANTIC_V1: # init_private_attributes() does not exist in v2 m._init_private_attributes() # type: ignore # copied from Pydantic v1's `construct()` method object.__setattr__(m, "__fields_set__", _fields_set) + else: + # these properties are copied from Pydantic's `model_construct()` method + object.__setattr__(m, "__pydantic_private__", None) + object.__setattr__(m, "__pydantic_extra__", _extra) + object.__setattr__(m, "__pydantic_fields_set__", _fields_set) return m @@ -238,7 +243,7 @@ def construct( # pyright: ignore[reportIncompatibleMethodOverride] # although not in practice model_construct = construct - if not PYDANTIC_V2: + if PYDANTIC_V1: # we define aliases for some of the new pydantic v2 methods so # that we can just document these methods without having to specify # a specific pydantic version as some users may not know which @@ -251,7 +256,7 @@ def model_dump( mode: Literal["json", "python"] | str = "python", include: IncEx | None = None, exclude: IncEx | None = None, - by_alias: bool = False, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, @@ -259,6 +264,7 @@ def model_dump( warnings: bool | Literal["none", "warn", "error"] = True, context: dict[str, Any] | None = None, serialize_as_any: bool = False, + fallback: Callable[[Any], Any] | None = None, ) -> dict[str, Any]: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump @@ -290,16 +296,18 @@ def model_dump( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") dumped = super().dict( # pyright: ignore[reportDeprecated] include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, ) - return cast(dict[str, Any], json_safe(dumped)) if mode == "json" else dumped + return cast("dict[str, Any]", json_safe(dumped)) if mode == "json" else dumped @override def model_dump_json( @@ -308,13 +316,14 @@ def model_dump_json( indent: int | None = None, include: IncEx | None = None, exclude: IncEx | None = None, - by_alias: bool = False, + by_alias: bool | None = None, exclude_unset: bool = False, exclude_defaults: bool = False, exclude_none: bool = False, round_trip: bool = False, warnings: bool | Literal["none", "warn", "error"] = True, context: dict[str, Any] | None = None, + fallback: Callable[[Any], Any] | None = None, serialize_as_any: bool = False, ) -> str: """Usage docs: https://docs.pydantic.dev/2.4/concepts/serialization/#modelmodel_dump_json @@ -343,11 +352,13 @@ def model_dump_json( raise ValueError("context is only supported in Pydantic v2") if serialize_as_any != False: raise ValueError("serialize_as_any is only supported in Pydantic v2") + if fallback is not None: + raise ValueError("fallback is only supported in Pydantic v2") return super().json( # type: ignore[reportDeprecated] indent=indent, include=include, exclude=exclude, - by_alias=by_alias, + by_alias=by_alias if by_alias is not None else False, exclude_unset=exclude_unset, exclude_defaults=exclude_defaults, exclude_none=exclude_none, @@ -358,15 +369,32 @@ def _construct_field(value: object, field: FieldInfo, key: str) -> object: if value is None: return field_get_default(field) - if PYDANTIC_V2: - type_ = field.annotation - else: + if PYDANTIC_V1: type_ = cast(type, field.outer_type_) # type: ignore + else: + type_ = field.annotation # type: ignore if type_ is None: raise RuntimeError(f"Unexpected field type is None for {key}") - return construct_type(value=value, type_=type_) + return construct_type(value=value, type_=type_, metadata=getattr(field, "metadata", None)) + + +def _get_extra_fields_type(cls: type[pydantic.BaseModel]) -> type | None: + if PYDANTIC_V1: + # TODO + return None + + schema = cls.__pydantic_core_schema__ + if schema["type"] == "model": + fields = schema["schema"] + if fields["type"] == "model-fields": + extras = fields.get("extras_schema") + if extras and "cls" in extras: + # mypy can't narrow the type + return extras["cls"] # type: ignore[no-any-return] + + return None def is_basemodel(type_: type) -> bool: @@ -420,7 +448,7 @@ def construct_type_unchecked(*, value: object, type_: type[_T]) -> _T: return cast(_T, construct_type(value=value, type_=type_)) -def construct_type(*, value: object, type_: object) -> object: +def construct_type(*, value: object, type_: object, metadata: Optional[List[Any]] = None) -> object: """Loose coercion to the expected type with construction of nested values. If the given value does not match the expected type then it is returned as-is. @@ -438,8 +466,10 @@ def construct_type(*, value: object, type_: object) -> object: type_ = type_.__value__ # type: ignore[unreachable] # unwrap `Annotated[T, ...]` -> `T` - if is_annotated_type(type_): - meta: tuple[Any, ...] = get_args(type_)[1:] + if metadata is not None and len(metadata) > 0: + meta: tuple[Any, ...] = tuple(metadata) + elif is_annotated_type(type_): + meta = get_args(type_)[1:] type_ = extract_type_arg(type_, 0) else: meta = tuple() @@ -604,30 +634,30 @@ def _build_discriminated_union_meta(*, union: type, meta_annotations: tuple[Any, for variant in get_args(union): variant = strip_annotated_type(variant) if is_basemodel_type(variant): - if PYDANTIC_V2: - field = _extract_field_schema_pv2(variant, discriminator_field_name) - if not field: + if PYDANTIC_V1: + field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] + if not field_info: continue # Note: if one variant defines an alias then they all should - discriminator_alias = field.get("serialization_alias") - - field_schema = field["schema"] + discriminator_alias = field_info.alias - if field_schema["type"] == "literal": - for entry in cast("LiteralSchema", field_schema)["expected"]: + if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation): + for entry in get_args(annotation): if isinstance(entry, str): mapping[entry] = variant else: - field_info = cast("dict[str, FieldInfo]", variant.__fields__).get(discriminator_field_name) # pyright: ignore[reportDeprecated, reportUnnecessaryCast] - if not field_info: + field = _extract_field_schema_pv2(variant, discriminator_field_name) + if not field: continue # Note: if one variant defines an alias then they all should - discriminator_alias = field_info.alias + discriminator_alias = field.get("serialization_alias") - if (annotation := getattr(field_info, "annotation", None)) and is_literal_type(annotation): - for entry in get_args(annotation): + field_schema = field["schema"] + + if field_schema["type"] == "literal": + for entry in cast("LiteralSchema", field_schema)["expected"]: if isinstance(entry, str): mapping[entry] = variant @@ -690,7 +720,7 @@ class GenericModel(BaseGenericModel, BaseModel): pass -if PYDANTIC_V2: +if not PYDANTIC_V1: from pydantic import TypeAdapter as _TypeAdapter _CachedTypeAdapter = cast("TypeAdapter[object]", lru_cache(maxsize=None)(_TypeAdapter)) @@ -758,12 +788,12 @@ class FinalRequestOptions(pydantic.BaseModel): json_data: Union[Body, None] = None extra_json: Union[AnyMapping, None] = None - if PYDANTIC_V2: - model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) - else: + if PYDANTIC_V1: class Config(pydantic.BaseConfig): # pyright: ignore[reportDeprecated] arbitrary_types_allowed: bool = True + else: + model_config: ClassVar[ConfigDict] = ConfigDict(arbitrary_types_allowed=True) def get_max_retries(self, max_retries: int) -> int: if isinstance(self.max_retries, NotGiven): @@ -796,9 +826,9 @@ def construct( # type: ignore key: strip_not_given(value) for key, value in values.items() } - if PYDANTIC_V2: - return super().model_construct(_fields_set, **kwargs) - return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated] + if PYDANTIC_V1: + return cast(FinalRequestOptions, super().construct(_fields_set, **kwargs)) # pyright: ignore[reportDeprecated] + return super().model_construct(_fields_set, **kwargs) if not TYPE_CHECKING: # type checkers incorrectly complain about this assignment diff --git a/src/zbdpay/_qs.py b/src/zbdpay/_qs.py index 274320c..ada6fd3 100644 --- a/src/zbdpay/_qs.py +++ b/src/zbdpay/_qs.py @@ -4,7 +4,7 @@ from urllib.parse import parse_qs, urlencode from typing_extensions import Literal, get_args -from ._types import NOT_GIVEN, NotGiven, NotGivenOr +from ._types import NotGiven, not_given from ._utils import flatten _T = TypeVar("_T") @@ -41,8 +41,8 @@ def stringify( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> str: return urlencode( self.stringify_items( @@ -56,8 +56,8 @@ def stringify_items( self, params: Params, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> list[tuple[str, str]]: opts = Options( qs=self, @@ -143,8 +143,8 @@ def __init__( self, qs: Querystring = _qs, *, - array_format: NotGivenOr[ArrayFormat] = NOT_GIVEN, - nested_format: NotGivenOr[NestedFormat] = NOT_GIVEN, + array_format: ArrayFormat | NotGiven = not_given, + nested_format: NestedFormat | NotGiven = not_given, ) -> None: self.array_format = qs.array_format if isinstance(array_format, NotGiven) else array_format self.nested_format = qs.nested_format if isinstance(nested_format, NotGiven) else nested_format diff --git a/src/zbdpay/_streaming.py b/src/zbdpay/_streaming.py index c5a457a..9f05e10 100644 --- a/src/zbdpay/_streaming.py +++ b/src/zbdpay/_streaming.py @@ -57,9 +57,8 @@ def __stream__(self) -> Iterator[_T]: for sse in iterator: yield process_data(data=sse.json(), cast_to=cast_to, response=response) - # Ensure the entire stream is consumed - for _sse in iterator: - ... + # As we might not fully consume the response stream, we need to close it explicitly + response.close() def __enter__(self) -> Self: return self @@ -121,9 +120,8 @@ async def __stream__(self) -> AsyncIterator[_T]: async for sse in iterator: yield process_data(data=sse.json(), cast_to=cast_to, response=response) - # Ensure the entire stream is consumed - async for _sse in iterator: - ... + # As we might not fully consume the response stream, we need to close it explicitly + await response.aclose() async def __aenter__(self) -> Self: return self diff --git a/src/zbdpay/_types.py b/src/zbdpay/_types.py index c7f711f..797861e 100644 --- a/src/zbdpay/_types.py +++ b/src/zbdpay/_types.py @@ -13,10 +13,21 @@ Mapping, TypeVar, Callable, + Iterator, Optional, Sequence, ) -from typing_extensions import Set, Literal, Protocol, TypeAlias, TypedDict, override, runtime_checkable +from typing_extensions import ( + Set, + Literal, + Protocol, + TypeAlias, + TypedDict, + SupportsIndex, + overload, + override, + runtime_checkable, +) import httpx import pydantic @@ -106,18 +117,21 @@ class RequestOptions(TypedDict, total=False): # Sentinel class used until PEP 0661 is accepted class NotGiven: """ - A sentinel singleton class used to distinguish omitted keyword arguments - from those passed in with the value None (which may have different behavior). + For parameters with a meaningful None value, we need to distinguish between + the user explicitly passing None, and the user not passing the parameter at + all. + + User code shouldn't need to use not_given directly. For example: ```py - def get(timeout: Union[int, NotGiven, None] = NotGiven()) -> Response: ... + def create(timeout: Timeout | None | NotGiven = not_given): ... - get(timeout=1) # 1s timeout - get(timeout=None) # No timeout - get() # Default timeout behavior, which may not be statically known at the method definition. + create(timeout=1) # 1s timeout + create(timeout=None) # No timeout + create() # Default timeout behavior ``` """ @@ -129,13 +143,14 @@ def __repr__(self) -> str: return "NOT_GIVEN" -NotGivenOr = Union[_T, NotGiven] +not_given = NotGiven() +# for backwards compatibility: NOT_GIVEN = NotGiven() class Omit: - """In certain situations you need to be able to represent a case where a default value has - to be explicitly removed and `None` is not an appropriate substitute, for example: + """ + To explicitly omit something from being sent in a request, use `omit`. ```py # as the default `Content-Type` header is `application/json` that will be sent @@ -145,8 +160,8 @@ class Omit: # to look something like: 'multipart/form-data; boundary=0d8382fcf5f8c3be01ca2e11002d2983' client.post(..., headers={"Content-Type": "multipart/form-data"}) - # instead you can remove the default `application/json` header by passing Omit - client.post(..., headers={"Content-Type": Omit()}) + # instead you can remove the default `application/json` header by passing omit + client.post(..., headers={"Content-Type": omit}) ``` """ @@ -154,6 +169,9 @@ def __bool__(self) -> Literal[False]: return False +omit = Omit() + + @runtime_checkable class ModelBuilderProtocol(Protocol): @classmethod @@ -217,3 +235,26 @@ class _GenericAlias(Protocol): class HttpxSendArgs(TypedDict, total=False): auth: httpx.Auth follow_redirects: bool + + +_T_co = TypeVar("_T_co", covariant=True) + + +if TYPE_CHECKING: + # This works because str.__contains__ does not accept object (either in typeshed or at runtime) + # https://github.com/hauntsaninja/useful_types/blob/5e9710f3875107d068e7679fd7fec9cfab0eff3b/useful_types/__init__.py#L285 + class SequenceNotStr(Protocol[_T_co]): + @overload + def __getitem__(self, index: SupportsIndex, /) -> _T_co: ... + @overload + def __getitem__(self, index: slice, /) -> Sequence[_T_co]: ... + def __contains__(self, value: object, /) -> bool: ... + def __len__(self) -> int: ... + def __iter__(self) -> Iterator[_T_co]: ... + def index(self, value: Any, start: int = 0, stop: int = ..., /) -> int: ... + def count(self, value: Any, /) -> int: ... + def __reversed__(self) -> Iterator[_T_co]: ... +else: + # just point this to a normal `Sequence` at runtime to avoid having to special case + # deserializing our custom sequence type + SequenceNotStr = Sequence diff --git a/src/zbdpay/_utils/__init__.py b/src/zbdpay/_utils/__init__.py index d4fda26..dc64e29 100644 --- a/src/zbdpay/_utils/__init__.py +++ b/src/zbdpay/_utils/__init__.py @@ -10,7 +10,6 @@ lru_cache as lru_cache, is_mapping as is_mapping, is_tuple_t as is_tuple_t, - parse_date as parse_date, is_iterable as is_iterable, is_sequence as is_sequence, coerce_float as coerce_float, @@ -23,7 +22,6 @@ coerce_boolean as coerce_boolean, coerce_integer as coerce_integer, file_from_path as file_from_path, - parse_datetime as parse_datetime, strip_not_given as strip_not_given, deepcopy_minimal as deepcopy_minimal, get_async_library as get_async_library, @@ -32,12 +30,20 @@ maybe_coerce_boolean as maybe_coerce_boolean, maybe_coerce_integer as maybe_coerce_integer, ) +from ._compat import ( + get_args as get_args, + is_union as is_union, + get_origin as get_origin, + is_typeddict as is_typeddict, + is_literal_type as is_literal_type, +) from ._typing import ( is_list_type as is_list_type, is_union_type as is_union_type, extract_type_arg as extract_type_arg, is_iterable_type as is_iterable_type, is_required_type as is_required_type, + is_sequence_type as is_sequence_type, is_annotated_type as is_annotated_type, is_type_alias_type as is_type_alias_type, strip_annotated_type as strip_annotated_type, @@ -55,3 +61,4 @@ function_has_argument as function_has_argument, assert_signatures_in_sync as assert_signatures_in_sync, ) +from ._datetime_parse import parse_date as parse_date, parse_datetime as parse_datetime diff --git a/src/zbdpay/_utils/_compat.py b/src/zbdpay/_utils/_compat.py new file mode 100644 index 0000000..dd70323 --- /dev/null +++ b/src/zbdpay/_utils/_compat.py @@ -0,0 +1,45 @@ +from __future__ import annotations + +import sys +import typing_extensions +from typing import Any, Type, Union, Literal, Optional +from datetime import date, datetime +from typing_extensions import get_args as _get_args, get_origin as _get_origin + +from .._types import StrBytesIntFloat +from ._datetime_parse import parse_date as _parse_date, parse_datetime as _parse_datetime + +_LITERAL_TYPES = {Literal, typing_extensions.Literal} + + +def get_args(tp: type[Any]) -> tuple[Any, ...]: + return _get_args(tp) + + +def get_origin(tp: type[Any]) -> type[Any] | None: + return _get_origin(tp) + + +def is_union(tp: Optional[Type[Any]]) -> bool: + if sys.version_info < (3, 10): + return tp is Union # type: ignore[comparison-overlap] + else: + import types + + return tp is Union or tp is types.UnionType + + +def is_typeddict(tp: Type[Any]) -> bool: + return typing_extensions.is_typeddict(tp) + + +def is_literal_type(tp: Type[Any]) -> bool: + return get_origin(tp) in _LITERAL_TYPES + + +def parse_date(value: Union[date, StrBytesIntFloat]) -> date: + return _parse_date(value) + + +def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: + return _parse_datetime(value) diff --git a/src/zbdpay/_utils/_datetime_parse.py b/src/zbdpay/_utils/_datetime_parse.py new file mode 100644 index 0000000..7cb9d9e --- /dev/null +++ b/src/zbdpay/_utils/_datetime_parse.py @@ -0,0 +1,136 @@ +""" +This file contains code from https://github.com/pydantic/pydantic/blob/main/pydantic/v1/datetime_parse.py +without the Pydantic v1 specific errors. +""" + +from __future__ import annotations + +import re +from typing import Dict, Union, Optional +from datetime import date, datetime, timezone, timedelta + +from .._types import StrBytesIntFloat + +date_expr = r"(?P\d{4})-(?P\d{1,2})-(?P\d{1,2})" +time_expr = ( + r"(?P\d{1,2}):(?P\d{1,2})" + r"(?::(?P\d{1,2})(?:\.(?P\d{1,6})\d{0,6})?)?" + r"(?PZ|[+-]\d{2}(?::?\d{2})?)?$" +) + +date_re = re.compile(f"{date_expr}$") +datetime_re = re.compile(f"{date_expr}[T ]{time_expr}") + + +EPOCH = datetime(1970, 1, 1) +# if greater than this, the number is in ms, if less than or equal it's in seconds +# (in seconds this is 11th October 2603, in ms it's 20th August 1970) +MS_WATERSHED = int(2e10) +# slightly more than datetime.max in ns - (datetime.max - EPOCH).total_seconds() * 1e9 +MAX_NUMBER = int(3e20) + + +def _get_numeric(value: StrBytesIntFloat, native_expected_type: str) -> Union[None, int, float]: + if isinstance(value, (int, float)): + return value + try: + return float(value) + except ValueError: + return None + except TypeError: + raise TypeError(f"invalid type; expected {native_expected_type}, string, bytes, int or float") from None + + +def _from_unix_seconds(seconds: Union[int, float]) -> datetime: + if seconds > MAX_NUMBER: + return datetime.max + elif seconds < -MAX_NUMBER: + return datetime.min + + while abs(seconds) > MS_WATERSHED: + seconds /= 1000 + dt = EPOCH + timedelta(seconds=seconds) + return dt.replace(tzinfo=timezone.utc) + + +def _parse_timezone(value: Optional[str]) -> Union[None, int, timezone]: + if value == "Z": + return timezone.utc + elif value is not None: + offset_mins = int(value[-2:]) if len(value) > 3 else 0 + offset = 60 * int(value[1:3]) + offset_mins + if value[0] == "-": + offset = -offset + return timezone(timedelta(minutes=offset)) + else: + return None + + +def parse_datetime(value: Union[datetime, StrBytesIntFloat]) -> datetime: + """ + Parse a datetime/int/float/string and return a datetime.datetime. + + This function supports time zone offsets. When the input contains one, + the output uses a timezone with a fixed offset from UTC. + + Raise ValueError if the input is well formatted but not a valid datetime. + Raise ValueError if the input isn't well formatted. + """ + if isinstance(value, datetime): + return value + + number = _get_numeric(value, "datetime") + if number is not None: + return _from_unix_seconds(number) + + if isinstance(value, bytes): + value = value.decode() + + assert not isinstance(value, (float, int)) + + match = datetime_re.match(value) + if match is None: + raise ValueError("invalid datetime format") + + kw = match.groupdict() + if kw["microsecond"]: + kw["microsecond"] = kw["microsecond"].ljust(6, "0") + + tzinfo = _parse_timezone(kw.pop("tzinfo")) + kw_: Dict[str, Union[None, int, timezone]] = {k: int(v) for k, v in kw.items() if v is not None} + kw_["tzinfo"] = tzinfo + + return datetime(**kw_) # type: ignore + + +def parse_date(value: Union[date, StrBytesIntFloat]) -> date: + """ + Parse a date/int/float/string and return a datetime.date. + + Raise ValueError if the input is well formatted but not a valid date. + Raise ValueError if the input isn't well formatted. + """ + if isinstance(value, date): + if isinstance(value, datetime): + return value.date() + else: + return value + + number = _get_numeric(value, "date") + if number is not None: + return _from_unix_seconds(number).date() + + if isinstance(value, bytes): + value = value.decode() + + assert not isinstance(value, (float, int)) + match = date_re.match(value) + if match is None: + raise ValueError("invalid date format") + + kw = {k: int(v) for k, v in match.groupdict().items()} + + try: + return date(**kw) + except ValueError: + raise ValueError("invalid date format") from None diff --git a/src/zbdpay/_utils/_transform.py b/src/zbdpay/_utils/_transform.py index b0cc20a..5207549 100644 --- a/src/zbdpay/_utils/_transform.py +++ b/src/zbdpay/_utils/_transform.py @@ -16,18 +16,20 @@ lru_cache, is_mapping, is_iterable, + is_sequence, ) from .._files import is_base64_file_input +from ._compat import get_origin, is_typeddict from ._typing import ( is_list_type, is_union_type, extract_type_arg, is_iterable_type, is_required_type, + is_sequence_type, is_annotated_type, strip_annotated_type, ) -from .._compat import get_origin, model_dump, is_typeddict _T = TypeVar("_T") @@ -167,6 +169,8 @@ def _transform_recursive( Defaults to the same value as the `annotation` argument. """ + from .._compat import model_dump + if inner_type is None: inner_type = annotation @@ -184,6 +188,8 @@ def _transform_recursive( (is_list_type(stripped_type) and is_list(data)) # Iterable[T] or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str)) + # Sequence[T] + or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str)) ): # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually # intended as an iterable, so we don't transform it. @@ -262,7 +268,7 @@ def _transform_typeddict( annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): if not is_given(value): - # we don't need to include `NotGiven` values here as they'll + # we don't need to include omitted values here as they'll # be stripped out before the request is sent anyway continue @@ -329,6 +335,8 @@ async def _async_transform_recursive( Defaults to the same value as the `annotation` argument. """ + from .._compat import model_dump + if inner_type is None: inner_type = annotation @@ -346,6 +354,8 @@ async def _async_transform_recursive( (is_list_type(stripped_type) and is_list(data)) # Iterable[T] or (is_iterable_type(stripped_type) and is_iterable(data) and not isinstance(data, str)) + # Sequence[T] + or (is_sequence_type(stripped_type) and is_sequence(data) and not isinstance(data, str)) ): # dicts are technically iterable, but it is an iterable on the keys of the dict and is not usually # intended as an iterable, so we don't transform it. @@ -424,7 +434,7 @@ async def _async_transform_typeddict( annotations = get_type_hints(expected_type, include_extras=True) for key, value in data.items(): if not is_given(value): - # we don't need to include `NotGiven` values here as they'll + # we don't need to include omitted values here as they'll # be stripped out before the request is sent anyway continue diff --git a/src/zbdpay/_utils/_typing.py b/src/zbdpay/_utils/_typing.py index 1bac954..193109f 100644 --- a/src/zbdpay/_utils/_typing.py +++ b/src/zbdpay/_utils/_typing.py @@ -15,7 +15,7 @@ from ._utils import lru_cache from .._types import InheritsGeneric -from .._compat import is_union as _is_union +from ._compat import is_union as _is_union def is_annotated_type(typ: type) -> bool: @@ -26,6 +26,11 @@ def is_list_type(typ: type) -> bool: return (get_origin(typ) or typ) == list +def is_sequence_type(typ: type) -> bool: + origin = get_origin(typ) or typ + return origin == typing_extensions.Sequence or origin == typing.Sequence or origin == _c_abc.Sequence + + def is_iterable_type(typ: type) -> bool: """If the given type is `typing.Iterable[T]`""" origin = get_origin(typ) or typ diff --git a/src/zbdpay/_utils/_utils.py b/src/zbdpay/_utils/_utils.py index ea3cf3f..eec7f4a 100644 --- a/src/zbdpay/_utils/_utils.py +++ b/src/zbdpay/_utils/_utils.py @@ -21,8 +21,7 @@ import sniffio -from .._types import NotGiven, FileTypes, NotGivenOr, HeadersLike -from .._compat import parse_date as parse_date, parse_datetime as parse_datetime +from .._types import Omit, NotGiven, FileTypes, HeadersLike _T = TypeVar("_T") _TupleT = TypeVar("_TupleT", bound=Tuple[object, ...]) @@ -64,7 +63,7 @@ def _extract_items( try: key = path[index] except IndexError: - if isinstance(obj, NotGiven): + if not is_given(obj): # no value was provided - we can safely ignore return [] @@ -127,14 +126,14 @@ def _extract_items( return [] -def is_given(obj: NotGivenOr[_T]) -> TypeGuard[_T]: - return not isinstance(obj, NotGiven) +def is_given(obj: _T | NotGiven | Omit) -> TypeGuard[_T]: + return not isinstance(obj, NotGiven) and not isinstance(obj, Omit) # Type safe methods for narrowing types with TypeVars. # The default narrowing for isinstance(obj, dict) is dict[unknown, unknown], # however this cause Pyright to rightfully report errors. As we know we don't -# care about the contained types we can safely use `object` in it's place. +# care about the contained types we can safely use `object` in its place. # # There are two separate functions defined, `is_*` and `is_*_t` for different use cases. # `is_*` is for when you're dealing with an unknown input diff --git a/src/zbdpay/_version.py b/src/zbdpay/_version.py index af6ad7d..5d73cda 100644 --- a/src/zbdpay/_version.py +++ b/src/zbdpay/_version.py @@ -1,4 +1,4 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. __title__ = "zbdpay" -__version__ = "0.1.0-alpha.1" # x-release-please-version +__version__ = "0.1.0-alpha.2" # x-release-please-version diff --git a/src/zbdpay/resources/email_payments.py b/src/zbdpay/resources/email_payments.py index 1ed3e3a..d8e28ac 100644 --- a/src/zbdpay/resources/email_payments.py +++ b/src/zbdpay/resources/email_payments.py @@ -5,7 +5,7 @@ import httpx from ..types import email_payment_send_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,15 +43,15 @@ def with_streaming_response(self) -> EmailPaymentsResourceWithStreamingResponse: def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - comment: str | NotGiven = NOT_GIVEN, - email: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + comment: str | Omit = omit, + email: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to any email. @@ -112,15 +112,15 @@ def with_streaming_response(self) -> AsyncEmailPaymentsResourceWithStreamingResp async def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - comment: str | NotGiven = NOT_GIVEN, - email: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + comment: str | Omit = omit, + email: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to any email. diff --git a/src/zbdpay/resources/gamertags.py b/src/zbdpay/resources/gamertags.py index 5f26196..83514bc 100644 --- a/src/zbdpay/resources/gamertags.py +++ b/src/zbdpay/resources/gamertags.py @@ -5,7 +5,7 @@ import httpx from ..types import gamertag_send_payment_params, gamertag_create_charge_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,18 +43,18 @@ def with_streaming_response(self) -> GamertagsResourceWithStreamingResponse: def create_charge( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - gamertag: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + gamertag: str | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Generate a payment request for a ZBD User. @@ -109,7 +109,7 @@ def retrieve_by_gamertag( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve Gamertag from a ZBD user ID. @@ -143,7 +143,7 @@ def retrieve_by_zbd_id( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve ZBD user ID from a Gamertag. @@ -177,7 +177,7 @@ def retrieve_payment( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a Payment sent to ZBD User. @@ -205,15 +205,15 @@ def retrieve_payment( def send_payment( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - gamertag: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, + gamertag: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to ZBD Users. @@ -274,18 +274,18 @@ def with_streaming_response(self) -> AsyncGamertagsResourceWithStreamingResponse async def create_charge( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - gamertag: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + gamertag: str | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Generate a payment request for a ZBD User. @@ -340,7 +340,7 @@ async def retrieve_by_gamertag( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve Gamertag from a ZBD user ID. @@ -374,7 +374,7 @@ async def retrieve_by_zbd_id( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve ZBD user ID from a Gamertag. @@ -408,7 +408,7 @@ async def retrieve_payment( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a Payment sent to ZBD User. @@ -436,15 +436,15 @@ async def retrieve_payment( async def send_payment( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - gamertag: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, + gamertag: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to ZBD Users. diff --git a/src/zbdpay/resources/internal_transfer.py b/src/zbdpay/resources/internal_transfer.py index 6f00955..fc7ed57 100644 --- a/src/zbdpay/resources/internal_transfer.py +++ b/src/zbdpay/resources/internal_transfer.py @@ -5,7 +5,7 @@ import httpx from ..types import internal_transfer_initiate_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,14 +43,14 @@ def with_streaming_response(self) -> InternalTransferResourceWithStreamingRespon def initiate( self, *, - amount: str | NotGiven = NOT_GIVEN, - receiver_wallet_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + receiver_wallet_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Performs a transfer of funds between two Projects. @@ -108,14 +108,14 @@ def with_streaming_response(self) -> AsyncInternalTransferResourceWithStreamingR async def initiate( self, *, - amount: str | NotGiven = NOT_GIVEN, - receiver_wallet_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + receiver_wallet_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Performs a transfer of funds between two Projects. diff --git a/src/zbdpay/resources/keysend_payments.py b/src/zbdpay/resources/keysend_payments.py index c461d5b..4156bd6 100644 --- a/src/zbdpay/resources/keysend_payments.py +++ b/src/zbdpay/resources/keysend_payments.py @@ -2,12 +2,10 @@ from __future__ import annotations -from typing import List - import httpx from ..types import keysend_payment_send_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, SequenceNotStr, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -45,18 +43,18 @@ def with_streaming_response(self) -> KeysendPaymentsResourceWithStreamingRespons def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - metadata: object | NotGiven = NOT_GIVEN, - pubkey: str | NotGiven = NOT_GIVEN, - tlv_records: List[str] | NotGiven = NOT_GIVEN, - value: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + metadata: object | Omit = omit, + pubkey: str | Omit = omit, + tlv_records: SequenceNotStr[str] | Omit = omit, + value: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start sending Keysend payments on the Lightning Network. @@ -128,18 +126,18 @@ def with_streaming_response(self) -> AsyncKeysendPaymentsResourceWithStreamingRe async def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - metadata: object | NotGiven = NOT_GIVEN, - pubkey: str | NotGiven = NOT_GIVEN, - tlv_records: List[str] | NotGiven = NOT_GIVEN, - value: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + metadata: object | Omit = omit, + pubkey: str | Omit = omit, + tlv_records: SequenceNotStr[str] | Omit = omit, + value: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start sending Keysend payments on the Lightning Network. diff --git a/src/zbdpay/resources/lightning_address.py b/src/zbdpay/resources/lightning_address.py index 7cc9e5f..d5b8ce5 100644 --- a/src/zbdpay/resources/lightning_address.py +++ b/src/zbdpay/resources/lightning_address.py @@ -5,7 +5,7 @@ import httpx from ..types import lightning_address_send_payment_params, lightning_address_create_charge_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,15 +43,15 @@ def with_streaming_response(self) -> LightningAddressResourceWithStreamingRespon def create_charge( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - lnaddress: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, + lnaddress: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Generate a payment request for a Lightning Address. @@ -91,17 +91,17 @@ def create_charge( def send_payment( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - comment: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - ln_address: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + comment: str | Omit = omit, + internal_id: str | Omit = omit, + ln_address: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to any Lightning Address. @@ -153,7 +153,7 @@ def validate( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Verify the validity of a Lightning Address. @@ -202,15 +202,15 @@ def with_streaming_response(self) -> AsyncLightningAddressResourceWithStreamingR async def create_charge( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - lnaddress: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, + lnaddress: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Generate a payment request for a Lightning Address. @@ -250,17 +250,17 @@ async def create_charge( async def send_payment( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - comment: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - ln_address: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + comment: str | Omit = omit, + internal_id: str | Omit = omit, + ln_address: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Send instant Bitcoin payments to any Lightning Address. @@ -312,7 +312,7 @@ async def validate( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Verify the validity of a Lightning Address. diff --git a/src/zbdpay/resources/lightning_charges.py b/src/zbdpay/resources/lightning_charges.py index 1751a40..307a470 100644 --- a/src/zbdpay/resources/lightning_charges.py +++ b/src/zbdpay/resources/lightning_charges.py @@ -5,7 +5,7 @@ import httpx from ..types import lightning_charge_create_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,17 +43,17 @@ def with_streaming_response(self) -> LightningChargesResourceWithStreamingRespon def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start receiving instant Bitcoin payments through the ZBD API. @@ -105,7 +105,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Charge. @@ -154,17 +154,17 @@ def with_streaming_response(self) -> AsyncLightningChargesResourceWithStreamingR async def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start receiving instant Bitcoin payments through the ZBD API. @@ -216,7 +216,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Charge. diff --git a/src/zbdpay/resources/lightning_payments.py b/src/zbdpay/resources/lightning_payments.py index f0dc326..e9d5592 100644 --- a/src/zbdpay/resources/lightning_payments.py +++ b/src/zbdpay/resources/lightning_payments.py @@ -5,7 +5,7 @@ import httpx from ..types import lightning_payment_send_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -49,7 +49,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Payment. @@ -77,17 +77,17 @@ def retrieve( def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - invoice: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + internal_id: str | Omit = omit, + invoice: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start sending instant Bitcoin payments through the ZBD API. @@ -161,7 +161,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Payment. @@ -189,17 +189,17 @@ async def retrieve( async def send( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - invoice: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + internal_id: str | Omit = omit, + invoice: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start sending instant Bitcoin payments through the ZBD API. diff --git a/src/zbdpay/resources/lightning_static_charges.py b/src/zbdpay/resources/lightning_static_charges.py index e544fa4..9e7a1df 100644 --- a/src/zbdpay/resources/lightning_static_charges.py +++ b/src/zbdpay/resources/lightning_static_charges.py @@ -5,7 +5,7 @@ import httpx from ..types import lightning_static_charge_create_params, lightning_static_charge_update_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,20 +43,20 @@ def with_streaming_response(self) -> LightningStaticChargesResourceWithStreaming def create( self, *, - allowed_slots: float | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - identifier: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - max_amount: str | NotGiven = NOT_GIVEN, - min_amount: str | NotGiven = NOT_GIVEN, - success_message: str | NotGiven = NOT_GIVEN, + allowed_slots: float | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + identifier: str | Omit = omit, + internal_id: str | Omit = omit, + max_amount: str | Omit = omit, + min_amount: str | Omit = omit, + success_message: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start accepting payments on Lightning with Static QR codes. @@ -117,7 +117,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Static Charge. @@ -146,19 +146,19 @@ def update( self, id: str, *, - allowed_slots: float | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - max_amount: str | NotGiven = NOT_GIVEN, - min_amount: str | NotGiven = NOT_GIVEN, - success_message: str | NotGiven = NOT_GIVEN, + allowed_slots: float | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + internal_id: str | Omit = omit, + max_amount: str | Omit = omit, + min_amount: str | Omit = omit, + success_message: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Change the configuration of a Static Charge QR code. @@ -233,20 +233,20 @@ def with_streaming_response(self) -> AsyncLightningStaticChargesResourceWithStre async def create( self, *, - allowed_slots: float | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - identifier: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - max_amount: str | NotGiven = NOT_GIVEN, - min_amount: str | NotGiven = NOT_GIVEN, - success_message: str | NotGiven = NOT_GIVEN, + allowed_slots: float | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + identifier: str | Omit = omit, + internal_id: str | Omit = omit, + max_amount: str | Omit = omit, + min_amount: str | Omit = omit, + success_message: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start accepting payments on Lightning with Static QR codes. @@ -307,7 +307,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Static Charge. @@ -336,19 +336,19 @@ async def update( self, id: str, *, - allowed_slots: float | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, - max_amount: str | NotGiven = NOT_GIVEN, - min_amount: str | NotGiven = NOT_GIVEN, - success_message: str | NotGiven = NOT_GIVEN, + allowed_slots: float | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + internal_id: str | Omit = omit, + max_amount: str | Omit = omit, + min_amount: str | Omit = omit, + success_message: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Change the configuration of a Static Charge QR code. diff --git a/src/zbdpay/resources/oauth2.py b/src/zbdpay/resources/oauth2.py index 067fcb3..ab09099 100644 --- a/src/zbdpay/resources/oauth2.py +++ b/src/zbdpay/resources/oauth2.py @@ -4,7 +4,7 @@ import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import strip_not_given from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -47,7 +47,7 @@ def create_authorization_url( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Create an authorization URL for ZBD Login.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -67,7 +67,7 @@ def refresh_token( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Generate a new accessToken for a ZBD Login user.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -82,13 +82,13 @@ def refresh_token( def retrieve_user_data( self, *, - usertoken: str | NotGiven = NOT_GIVEN, + usertoken: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Fetch user-related information about a logged-in ZBD User. @@ -115,13 +115,13 @@ def retrieve_user_data( def retrieve_wallet_data( self, *, - usertoken: str | NotGiven = NOT_GIVEN, + usertoken: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Fetch wallet-related information about a logged-in ZBD User. @@ -174,7 +174,7 @@ async def create_authorization_url( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Create an authorization URL for ZBD Login.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -194,7 +194,7 @@ async def refresh_token( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Generate a new accessToken for a ZBD Login user.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -209,13 +209,13 @@ async def refresh_token( async def retrieve_user_data( self, *, - usertoken: str | NotGiven = NOT_GIVEN, + usertoken: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Fetch user-related information about a logged-in ZBD User. @@ -242,13 +242,13 @@ async def retrieve_user_data( async def retrieve_wallet_data( self, *, - usertoken: str | NotGiven = NOT_GIVEN, + usertoken: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Fetch wallet-related information about a logged-in ZBD User. diff --git a/src/zbdpay/resources/utils.py b/src/zbdpay/resources/utils.py index 9819dca..ac15883 100644 --- a/src/zbdpay/resources/utils.py +++ b/src/zbdpay/resources/utils.py @@ -5,7 +5,7 @@ import httpx from ..types import util_decode_lightning_charge_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -49,7 +49,7 @@ def check_ip_support( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Verify if a user is coming from a supported region. @@ -77,13 +77,13 @@ def check_ip_support( def decode_lightning_charge( self, *, - invoice: str | NotGiven = NOT_GIVEN, + invoice: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Understand the inner properties of a Charge QR code. @@ -119,7 +119,7 @@ def list_prod_ips( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Get the official IP addresses of ZBD servers.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -139,7 +139,7 @@ def retrieve_btc_usd( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Get the latest price for Bitcoin in US Dollars.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -181,7 +181,7 @@ async def check_ip_support( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Verify if a user is coming from a supported region. @@ -209,13 +209,13 @@ async def check_ip_support( async def decode_lightning_charge( self, *, - invoice: str | NotGiven = NOT_GIVEN, + invoice: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Understand the inner properties of a Charge QR code. @@ -251,7 +251,7 @@ async def list_prod_ips( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Get the official IP addresses of ZBD servers.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -271,7 +271,7 @@ async def retrieve_btc_usd( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Get the latest price for Bitcoin in US Dollars.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} diff --git a/src/zbdpay/resources/vouchers.py b/src/zbdpay/resources/vouchers.py index e1cb973..f4096dd 100644 --- a/src/zbdpay/resources/vouchers.py +++ b/src/zbdpay/resources/vouchers.py @@ -5,7 +5,7 @@ import httpx from ..types import voucher_create_params, voucher_redeem_params, voucher_revoke_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,14 +43,14 @@ def with_streaming_response(self) -> VouchersResourceWithStreamingResponse: def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Create Voucher @@ -93,7 +93,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Get Voucher @@ -121,13 +121,13 @@ def retrieve( def redeem( self, *, - code: str | NotGiven = NOT_GIVEN, + code: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Redeem Voucher @@ -156,13 +156,13 @@ def redeem( def revoke( self, *, - code: str | NotGiven = NOT_GIVEN, + code: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Revoke Voucher @@ -212,14 +212,14 @@ def with_streaming_response(self) -> AsyncVouchersResourceWithStreamingResponse: async def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + description: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Create Voucher @@ -262,7 +262,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Get Voucher @@ -290,13 +290,13 @@ async def retrieve( async def redeem( self, *, - code: str | NotGiven = NOT_GIVEN, + code: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Redeem Voucher @@ -325,13 +325,13 @@ async def redeem( async def revoke( self, *, - code: str | NotGiven = NOT_GIVEN, + code: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Revoke Voucher diff --git a/src/zbdpay/resources/wallet.py b/src/zbdpay/resources/wallet.py index 83a8f7c..acde7a8 100644 --- a/src/zbdpay/resources/wallet.py +++ b/src/zbdpay/resources/wallet.py @@ -4,7 +4,7 @@ import httpx -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Query, Headers, NoneType, NotGiven, not_given from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource from .._response import ( @@ -46,7 +46,7 @@ def retrieve_balance( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Retrieve all data about a ZBD Project's Wallet.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} @@ -87,7 +87,7 @@ async def retrieve_balance( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """Retrieve all data about a ZBD Project's Wallet.""" extra_headers = {"Accept": "*/*", **(extra_headers or {})} diff --git a/src/zbdpay/resources/withdrawal_requests.py b/src/zbdpay/resources/withdrawal_requests.py index 26e2e0e..51d0338 100644 --- a/src/zbdpay/resources/withdrawal_requests.py +++ b/src/zbdpay/resources/withdrawal_requests.py @@ -5,7 +5,7 @@ import httpx from ..types import withdrawal_request_create_params -from .._types import NOT_GIVEN, Body, Query, Headers, NoneType, NotGiven +from .._types import Body, Omit, Query, Headers, NoneType, NotGiven, omit, not_given from .._utils import maybe_transform, async_maybe_transform from .._compat import cached_property from .._resource import SyncAPIResource, AsyncAPIResource @@ -43,17 +43,17 @@ def with_streaming_response(self) -> WithdrawalRequestsResourceWithStreamingResp def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start creating Bitcoin voucher QR codes. @@ -105,7 +105,7 @@ def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Withdrawal Request. @@ -154,17 +154,17 @@ def with_streaming_response(self) -> AsyncWithdrawalRequestsResourceWithStreamin async def create( self, *, - amount: str | NotGiven = NOT_GIVEN, - callback_url: str | NotGiven = NOT_GIVEN, - description: str | NotGiven = NOT_GIVEN, - expires_in: float | NotGiven = NOT_GIVEN, - internal_id: str | NotGiven = NOT_GIVEN, + amount: str | Omit = omit, + callback_url: str | Omit = omit, + description: str | Omit = omit, + expires_in: float | Omit = omit, + internal_id: str | Omit = omit, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. # The extra values given here take precedence over values defined on the client or passed to this method. extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Start creating Bitcoin voucher QR codes. @@ -216,7 +216,7 @@ async def retrieve( extra_headers: Headers | None = None, extra_query: Query | None = None, extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, + timeout: float | httpx.Timeout | None | NotGiven = not_given, ) -> None: """ Retrieve all data about a single Withdrawal Request. diff --git a/src/zbdpay/types/keysend_payment_send_params.py b/src/zbdpay/types/keysend_payment_send_params.py index 0d891a2..a848e69 100644 --- a/src/zbdpay/types/keysend_payment_send_params.py +++ b/src/zbdpay/types/keysend_payment_send_params.py @@ -2,9 +2,9 @@ from __future__ import annotations -from typing import List from typing_extensions import Annotated, TypedDict +from .._types import SequenceNotStr from .._utils import PropertyInfo __all__ = ["KeysendPaymentSendParams"] @@ -23,7 +23,7 @@ class KeysendPaymentSendParams(TypedDict, total=False): pubkey: str """The Public Key for the destination Lightning node""" - tlv_records: Annotated[List[str], PropertyInfo(alias="tlvRecords")] + tlv_records: Annotated[SequenceNotStr[str], PropertyInfo(alias="tlvRecords")] """ List of TLV records type of the TLV diff --git a/tests/api_resources/test_email_payments.py b/tests/api_resources/test_email_payments.py index 267e005..f728e21 100644 --- a/tests/api_resources/test_email_payments.py +++ b/tests/api_resources/test_email_payments.py @@ -15,13 +15,13 @@ class TestEmailPayments: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send(self, client: ZbdPayments) -> None: email_payment = client.email_payments.send() assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_with_all_params(self, client: ZbdPayments) -> None: email_payment = client.email_payments.send( @@ -31,7 +31,7 @@ def test_method_send_with_all_params(self, client: ZbdPayments) -> None: ) assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_send(self, client: ZbdPayments) -> None: response = client.email_payments.with_raw_response.send() @@ -41,7 +41,7 @@ def test_raw_response_send(self, client: ZbdPayments) -> None: email_payment = response.parse() assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_send(self, client: ZbdPayments) -> None: with client.email_payments.with_streaming_response.send() as response: @@ -59,13 +59,13 @@ class TestAsyncEmailPayments: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send(self, async_client: AsyncZbdPayments) -> None: email_payment = await async_client.email_payments.send() assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) -> None: email_payment = await async_client.email_payments.send( @@ -75,7 +75,7 @@ async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) ) assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: response = await async_client.email_payments.with_raw_response.send() @@ -85,7 +85,7 @@ async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: email_payment = await response.parse() assert email_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_send(self, async_client: AsyncZbdPayments) -> None: async with async_client.email_payments.with_streaming_response.send() as response: diff --git a/tests/api_resources/test_gamertags.py b/tests/api_resources/test_gamertags.py index 6d46dd7..3c40375 100644 --- a/tests/api_resources/test_gamertags.py +++ b/tests/api_resources/test_gamertags.py @@ -15,13 +15,13 @@ class TestGamertags: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_charge(self, client: ZbdPayments) -> None: gamertag = client.gamertags.create_charge() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_charge_with_all_params(self, client: ZbdPayments) -> None: gamertag = client.gamertags.create_charge( @@ -34,7 +34,7 @@ def test_method_create_charge_with_all_params(self, client: ZbdPayments) -> None ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create_charge(self, client: ZbdPayments) -> None: response = client.gamertags.with_raw_response.create_charge() @@ -44,7 +44,7 @@ def test_raw_response_create_charge(self, client: ZbdPayments) -> None: gamertag = response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create_charge(self, client: ZbdPayments) -> None: with client.gamertags.with_streaming_response.create_charge() as response: @@ -56,7 +56,7 @@ def test_streaming_response_create_charge(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_by_gamertag(self, client: ZbdPayments) -> None: gamertag = client.gamertags.retrieve_by_gamertag( @@ -64,7 +64,7 @@ def test_method_retrieve_by_gamertag(self, client: ZbdPayments) -> None: ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_by_gamertag(self, client: ZbdPayments) -> None: response = client.gamertags.with_raw_response.retrieve_by_gamertag( @@ -76,7 +76,7 @@ def test_raw_response_retrieve_by_gamertag(self, client: ZbdPayments) -> None: gamertag = response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_by_gamertag(self, client: ZbdPayments) -> None: with client.gamertags.with_streaming_response.retrieve_by_gamertag( @@ -90,7 +90,7 @@ def test_streaming_response_retrieve_by_gamertag(self, client: ZbdPayments) -> N assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve_by_gamertag(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `gamertag` but received ''"): @@ -98,7 +98,7 @@ def test_path_params_retrieve_by_gamertag(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: gamertag = client.gamertags.retrieve_by_zbd_id( @@ -106,7 +106,7 @@ def test_method_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: response = client.gamertags.with_raw_response.retrieve_by_zbd_id( @@ -118,7 +118,7 @@ def test_raw_response_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: gamertag = response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: with client.gamertags.with_streaming_response.retrieve_by_zbd_id( @@ -132,7 +132,7 @@ def test_streaming_response_retrieve_by_zbd_id(self, client: ZbdPayments) -> Non assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -140,7 +140,7 @@ def test_path_params_retrieve_by_zbd_id(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_payment(self, client: ZbdPayments) -> None: gamertag = client.gamertags.retrieve_payment( @@ -148,7 +148,7 @@ def test_method_retrieve_payment(self, client: ZbdPayments) -> None: ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_payment(self, client: ZbdPayments) -> None: response = client.gamertags.with_raw_response.retrieve_payment( @@ -160,7 +160,7 @@ def test_raw_response_retrieve_payment(self, client: ZbdPayments) -> None: gamertag = response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_payment(self, client: ZbdPayments) -> None: with client.gamertags.with_streaming_response.retrieve_payment( @@ -174,7 +174,7 @@ def test_streaming_response_retrieve_payment(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve_payment(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -182,13 +182,13 @@ def test_path_params_retrieve_payment(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_payment(self, client: ZbdPayments) -> None: gamertag = client.gamertags.send_payment() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_payment_with_all_params(self, client: ZbdPayments) -> None: gamertag = client.gamertags.send_payment( @@ -198,7 +198,7 @@ def test_method_send_payment_with_all_params(self, client: ZbdPayments) -> None: ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_send_payment(self, client: ZbdPayments) -> None: response = client.gamertags.with_raw_response.send_payment() @@ -208,7 +208,7 @@ def test_raw_response_send_payment(self, client: ZbdPayments) -> None: gamertag = response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_send_payment(self, client: ZbdPayments) -> None: with client.gamertags.with_streaming_response.send_payment() as response: @@ -226,13 +226,13 @@ class TestAsyncGamertags: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_charge(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.create_charge() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_charge_with_all_params(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.create_charge( @@ -245,7 +245,7 @@ async def test_method_create_charge_with_all_params(self, async_client: AsyncZbd ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create_charge(self, async_client: AsyncZbdPayments) -> None: response = await async_client.gamertags.with_raw_response.create_charge() @@ -255,7 +255,7 @@ async def test_raw_response_create_charge(self, async_client: AsyncZbdPayments) gamertag = await response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create_charge(self, async_client: AsyncZbdPayments) -> None: async with async_client.gamertags.with_streaming_response.create_charge() as response: @@ -267,7 +267,7 @@ async def test_streaming_response_create_charge(self, async_client: AsyncZbdPaym assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_by_gamertag(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.retrieve_by_gamertag( @@ -275,7 +275,7 @@ async def test_method_retrieve_by_gamertag(self, async_client: AsyncZbdPayments) ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_by_gamertag(self, async_client: AsyncZbdPayments) -> None: response = await async_client.gamertags.with_raw_response.retrieve_by_gamertag( @@ -287,7 +287,7 @@ async def test_raw_response_retrieve_by_gamertag(self, async_client: AsyncZbdPay gamertag = await response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_by_gamertag(self, async_client: AsyncZbdPayments) -> None: async with async_client.gamertags.with_streaming_response.retrieve_by_gamertag( @@ -301,7 +301,7 @@ async def test_streaming_response_retrieve_by_gamertag(self, async_client: Async assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve_by_gamertag(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `gamertag` but received ''"): @@ -309,7 +309,7 @@ async def test_path_params_retrieve_by_gamertag(self, async_client: AsyncZbdPaym "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_by_zbd_id(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.retrieve_by_zbd_id( @@ -317,7 +317,7 @@ async def test_method_retrieve_by_zbd_id(self, async_client: AsyncZbdPayments) - ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_by_zbd_id(self, async_client: AsyncZbdPayments) -> None: response = await async_client.gamertags.with_raw_response.retrieve_by_zbd_id( @@ -329,7 +329,7 @@ async def test_raw_response_retrieve_by_zbd_id(self, async_client: AsyncZbdPayme gamertag = await response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_by_zbd_id(self, async_client: AsyncZbdPayments) -> None: async with async_client.gamertags.with_streaming_response.retrieve_by_zbd_id( @@ -343,7 +343,7 @@ async def test_streaming_response_retrieve_by_zbd_id(self, async_client: AsyncZb assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve_by_zbd_id(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -351,7 +351,7 @@ async def test_path_params_retrieve_by_zbd_id(self, async_client: AsyncZbdPaymen "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_payment(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.retrieve_payment( @@ -359,7 +359,7 @@ async def test_method_retrieve_payment(self, async_client: AsyncZbdPayments) -> ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_payment(self, async_client: AsyncZbdPayments) -> None: response = await async_client.gamertags.with_raw_response.retrieve_payment( @@ -371,7 +371,7 @@ async def test_raw_response_retrieve_payment(self, async_client: AsyncZbdPayment gamertag = await response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_payment(self, async_client: AsyncZbdPayments) -> None: async with async_client.gamertags.with_streaming_response.retrieve_payment( @@ -385,7 +385,7 @@ async def test_streaming_response_retrieve_payment(self, async_client: AsyncZbdP assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve_payment(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -393,13 +393,13 @@ async def test_path_params_retrieve_payment(self, async_client: AsyncZbdPayments "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_payment(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.send_payment() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_payment_with_all_params(self, async_client: AsyncZbdPayments) -> None: gamertag = await async_client.gamertags.send_payment( @@ -409,7 +409,7 @@ async def test_method_send_payment_with_all_params(self, async_client: AsyncZbdP ) assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_send_payment(self, async_client: AsyncZbdPayments) -> None: response = await async_client.gamertags.with_raw_response.send_payment() @@ -419,7 +419,7 @@ async def test_raw_response_send_payment(self, async_client: AsyncZbdPayments) - gamertag = await response.parse() assert gamertag is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_send_payment(self, async_client: AsyncZbdPayments) -> None: async with async_client.gamertags.with_streaming_response.send_payment() as response: diff --git a/tests/api_resources/test_internal_transfer.py b/tests/api_resources/test_internal_transfer.py index 13a0eff..695e06a 100644 --- a/tests/api_resources/test_internal_transfer.py +++ b/tests/api_resources/test_internal_transfer.py @@ -15,13 +15,13 @@ class TestInternalTransfer: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_initiate(self, client: ZbdPayments) -> None: internal_transfer = client.internal_transfer.initiate() assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_initiate_with_all_params(self, client: ZbdPayments) -> None: internal_transfer = client.internal_transfer.initiate( @@ -30,7 +30,7 @@ def test_method_initiate_with_all_params(self, client: ZbdPayments) -> None: ) assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_initiate(self, client: ZbdPayments) -> None: response = client.internal_transfer.with_raw_response.initiate() @@ -40,7 +40,7 @@ def test_raw_response_initiate(self, client: ZbdPayments) -> None: internal_transfer = response.parse() assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_initiate(self, client: ZbdPayments) -> None: with client.internal_transfer.with_streaming_response.initiate() as response: @@ -58,13 +58,13 @@ class TestAsyncInternalTransfer: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_initiate(self, async_client: AsyncZbdPayments) -> None: internal_transfer = await async_client.internal_transfer.initiate() assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_initiate_with_all_params(self, async_client: AsyncZbdPayments) -> None: internal_transfer = await async_client.internal_transfer.initiate( @@ -73,7 +73,7 @@ async def test_method_initiate_with_all_params(self, async_client: AsyncZbdPayme ) assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_initiate(self, async_client: AsyncZbdPayments) -> None: response = await async_client.internal_transfer.with_raw_response.initiate() @@ -83,7 +83,7 @@ async def test_raw_response_initiate(self, async_client: AsyncZbdPayments) -> No internal_transfer = await response.parse() assert internal_transfer is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_initiate(self, async_client: AsyncZbdPayments) -> None: async with async_client.internal_transfer.with_streaming_response.initiate() as response: diff --git a/tests/api_resources/test_keysend_payments.py b/tests/api_resources/test_keysend_payments.py index 5906705..35f5c08 100644 --- a/tests/api_resources/test_keysend_payments.py +++ b/tests/api_resources/test_keysend_payments.py @@ -15,13 +15,13 @@ class TestKeysendPayments: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send(self, client: ZbdPayments) -> None: keysend_payment = client.keysend_payments.send() assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_with_all_params(self, client: ZbdPayments) -> None: keysend_payment = client.keysend_payments.send( @@ -34,7 +34,7 @@ def test_method_send_with_all_params(self, client: ZbdPayments) -> None: ) assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_send(self, client: ZbdPayments) -> None: response = client.keysend_payments.with_raw_response.send() @@ -44,7 +44,7 @@ def test_raw_response_send(self, client: ZbdPayments) -> None: keysend_payment = response.parse() assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_send(self, client: ZbdPayments) -> None: with client.keysend_payments.with_streaming_response.send() as response: @@ -62,13 +62,13 @@ class TestAsyncKeysendPayments: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send(self, async_client: AsyncZbdPayments) -> None: keysend_payment = await async_client.keysend_payments.send() assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) -> None: keysend_payment = await async_client.keysend_payments.send( @@ -81,7 +81,7 @@ async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) ) assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: response = await async_client.keysend_payments.with_raw_response.send() @@ -91,7 +91,7 @@ async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: keysend_payment = await response.parse() assert keysend_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_send(self, async_client: AsyncZbdPayments) -> None: async with async_client.keysend_payments.with_streaming_response.send() as response: diff --git a/tests/api_resources/test_lightning_address.py b/tests/api_resources/test_lightning_address.py index e72a2c9..ea09a19 100644 --- a/tests/api_resources/test_lightning_address.py +++ b/tests/api_resources/test_lightning_address.py @@ -15,13 +15,13 @@ class TestLightningAddress: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_charge(self, client: ZbdPayments) -> None: lightning_address = client.lightning_address.create_charge() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_charge_with_all_params(self, client: ZbdPayments) -> None: lightning_address = client.lightning_address.create_charge( @@ -31,7 +31,7 @@ def test_method_create_charge_with_all_params(self, client: ZbdPayments) -> None ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create_charge(self, client: ZbdPayments) -> None: response = client.lightning_address.with_raw_response.create_charge() @@ -41,7 +41,7 @@ def test_raw_response_create_charge(self, client: ZbdPayments) -> None: lightning_address = response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create_charge(self, client: ZbdPayments) -> None: with client.lightning_address.with_streaming_response.create_charge() as response: @@ -53,13 +53,13 @@ def test_streaming_response_create_charge(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_payment(self, client: ZbdPayments) -> None: lightning_address = client.lightning_address.send_payment() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_payment_with_all_params(self, client: ZbdPayments) -> None: lightning_address = client.lightning_address.send_payment( @@ -71,7 +71,7 @@ def test_method_send_payment_with_all_params(self, client: ZbdPayments) -> None: ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_send_payment(self, client: ZbdPayments) -> None: response = client.lightning_address.with_raw_response.send_payment() @@ -81,7 +81,7 @@ def test_raw_response_send_payment(self, client: ZbdPayments) -> None: lightning_address = response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_send_payment(self, client: ZbdPayments) -> None: with client.lightning_address.with_streaming_response.send_payment() as response: @@ -93,7 +93,7 @@ def test_streaming_response_send_payment(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_validate(self, client: ZbdPayments) -> None: lightning_address = client.lightning_address.validate( @@ -101,7 +101,7 @@ def test_method_validate(self, client: ZbdPayments) -> None: ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_validate(self, client: ZbdPayments) -> None: response = client.lightning_address.with_raw_response.validate( @@ -113,7 +113,7 @@ def test_raw_response_validate(self, client: ZbdPayments) -> None: lightning_address = response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_validate(self, client: ZbdPayments) -> None: with client.lightning_address.with_streaming_response.validate( @@ -127,7 +127,7 @@ def test_streaming_response_validate(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_validate(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `address` but received ''"): @@ -141,13 +141,13 @@ class TestAsyncLightningAddress: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_charge(self, async_client: AsyncZbdPayments) -> None: lightning_address = await async_client.lightning_address.create_charge() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_charge_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_address = await async_client.lightning_address.create_charge( @@ -157,7 +157,7 @@ async def test_method_create_charge_with_all_params(self, async_client: AsyncZbd ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create_charge(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_address.with_raw_response.create_charge() @@ -167,7 +167,7 @@ async def test_raw_response_create_charge(self, async_client: AsyncZbdPayments) lightning_address = await response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create_charge(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_address.with_streaming_response.create_charge() as response: @@ -179,13 +179,13 @@ async def test_streaming_response_create_charge(self, async_client: AsyncZbdPaym assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_payment(self, async_client: AsyncZbdPayments) -> None: lightning_address = await async_client.lightning_address.send_payment() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_payment_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_address = await async_client.lightning_address.send_payment( @@ -197,7 +197,7 @@ async def test_method_send_payment_with_all_params(self, async_client: AsyncZbdP ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_send_payment(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_address.with_raw_response.send_payment() @@ -207,7 +207,7 @@ async def test_raw_response_send_payment(self, async_client: AsyncZbdPayments) - lightning_address = await response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_send_payment(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_address.with_streaming_response.send_payment() as response: @@ -219,7 +219,7 @@ async def test_streaming_response_send_payment(self, async_client: AsyncZbdPayme assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_validate(self, async_client: AsyncZbdPayments) -> None: lightning_address = await async_client.lightning_address.validate( @@ -227,7 +227,7 @@ async def test_method_validate(self, async_client: AsyncZbdPayments) -> None: ) assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_validate(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_address.with_raw_response.validate( @@ -239,7 +239,7 @@ async def test_raw_response_validate(self, async_client: AsyncZbdPayments) -> No lightning_address = await response.parse() assert lightning_address is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_validate(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_address.with_streaming_response.validate( @@ -253,7 +253,7 @@ async def test_streaming_response_validate(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_validate(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `address` but received ''"): diff --git a/tests/api_resources/test_lightning_charges.py b/tests/api_resources/test_lightning_charges.py index 15dacc1..45a7bc3 100644 --- a/tests/api_resources/test_lightning_charges.py +++ b/tests/api_resources/test_lightning_charges.py @@ -15,13 +15,13 @@ class TestLightningCharges: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create(self, client: ZbdPayments) -> None: lightning_charge = client.lightning_charges.create() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_with_all_params(self, client: ZbdPayments) -> None: lightning_charge = client.lightning_charges.create( @@ -33,7 +33,7 @@ def test_method_create_with_all_params(self, client: ZbdPayments) -> None: ) assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create(self, client: ZbdPayments) -> None: response = client.lightning_charges.with_raw_response.create() @@ -43,7 +43,7 @@ def test_raw_response_create(self, client: ZbdPayments) -> None: lightning_charge = response.parse() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create(self, client: ZbdPayments) -> None: with client.lightning_charges.with_streaming_response.create() as response: @@ -55,7 +55,7 @@ def test_streaming_response_create(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve(self, client: ZbdPayments) -> None: lightning_charge = client.lightning_charges.retrieve( @@ -63,7 +63,7 @@ def test_method_retrieve(self, client: ZbdPayments) -> None: ) assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve(self, client: ZbdPayments) -> None: response = client.lightning_charges.with_raw_response.retrieve( @@ -75,7 +75,7 @@ def test_raw_response_retrieve(self, client: ZbdPayments) -> None: lightning_charge = response.parse() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: with client.lightning_charges.with_streaming_response.retrieve( @@ -89,7 +89,7 @@ def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -103,13 +103,13 @@ class TestAsyncLightningCharges: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create(self, async_client: AsyncZbdPayments) -> None: lightning_charge = await async_client.lightning_charges.create() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_charge = await async_client.lightning_charges.create( @@ -121,7 +121,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncZbdPayment ) assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_charges.with_raw_response.create() @@ -131,7 +131,7 @@ async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None lightning_charge = await response.parse() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_charges.with_streaming_response.create() as response: @@ -143,7 +143,7 @@ async def test_streaming_response_create(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: lightning_charge = await async_client.lightning_charges.retrieve( @@ -151,7 +151,7 @@ async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: ) assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_charges.with_raw_response.retrieve( @@ -163,7 +163,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> No lightning_charge = await response.parse() assert lightning_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_charges.with_streaming_response.retrieve( @@ -177,7 +177,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): diff --git a/tests/api_resources/test_lightning_payments.py b/tests/api_resources/test_lightning_payments.py index 753bb28..936adc5 100644 --- a/tests/api_resources/test_lightning_payments.py +++ b/tests/api_resources/test_lightning_payments.py @@ -15,7 +15,7 @@ class TestLightningPayments: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve(self, client: ZbdPayments) -> None: lightning_payment = client.lightning_payments.retrieve( @@ -23,7 +23,7 @@ def test_method_retrieve(self, client: ZbdPayments) -> None: ) assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve(self, client: ZbdPayments) -> None: response = client.lightning_payments.with_raw_response.retrieve( @@ -35,7 +35,7 @@ def test_raw_response_retrieve(self, client: ZbdPayments) -> None: lightning_payment = response.parse() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: with client.lightning_payments.with_streaming_response.retrieve( @@ -49,7 +49,7 @@ def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -57,13 +57,13 @@ def test_path_params_retrieve(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send(self, client: ZbdPayments) -> None: lightning_payment = client.lightning_payments.send() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_send_with_all_params(self, client: ZbdPayments) -> None: lightning_payment = client.lightning_payments.send( @@ -75,7 +75,7 @@ def test_method_send_with_all_params(self, client: ZbdPayments) -> None: ) assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_send(self, client: ZbdPayments) -> None: response = client.lightning_payments.with_raw_response.send() @@ -85,7 +85,7 @@ def test_raw_response_send(self, client: ZbdPayments) -> None: lightning_payment = response.parse() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_send(self, client: ZbdPayments) -> None: with client.lightning_payments.with_streaming_response.send() as response: @@ -103,7 +103,7 @@ class TestAsyncLightningPayments: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: lightning_payment = await async_client.lightning_payments.retrieve( @@ -111,7 +111,7 @@ async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: ) assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_payments.with_raw_response.retrieve( @@ -123,7 +123,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> No lightning_payment = await response.parse() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_payments.with_streaming_response.retrieve( @@ -137,7 +137,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -145,13 +145,13 @@ async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> Non "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send(self, async_client: AsyncZbdPayments) -> None: lightning_payment = await async_client.lightning_payments.send() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_payment = await async_client.lightning_payments.send( @@ -163,7 +163,7 @@ async def test_method_send_with_all_params(self, async_client: AsyncZbdPayments) ) assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_payments.with_raw_response.send() @@ -173,7 +173,7 @@ async def test_raw_response_send(self, async_client: AsyncZbdPayments) -> None: lightning_payment = await response.parse() assert lightning_payment is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_send(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_payments.with_streaming_response.send() as response: diff --git a/tests/api_resources/test_lightning_static_charges.py b/tests/api_resources/test_lightning_static_charges.py index 1317b1a..d6fcac3 100644 --- a/tests/api_resources/test_lightning_static_charges.py +++ b/tests/api_resources/test_lightning_static_charges.py @@ -15,13 +15,13 @@ class TestLightningStaticCharges: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create(self, client: ZbdPayments) -> None: lightning_static_charge = client.lightning_static_charges.create() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_with_all_params(self, client: ZbdPayments) -> None: lightning_static_charge = client.lightning_static_charges.create( @@ -36,7 +36,7 @@ def test_method_create_with_all_params(self, client: ZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create(self, client: ZbdPayments) -> None: response = client.lightning_static_charges.with_raw_response.create() @@ -46,7 +46,7 @@ def test_raw_response_create(self, client: ZbdPayments) -> None: lightning_static_charge = response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create(self, client: ZbdPayments) -> None: with client.lightning_static_charges.with_streaming_response.create() as response: @@ -58,7 +58,7 @@ def test_streaming_response_create(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve(self, client: ZbdPayments) -> None: lightning_static_charge = client.lightning_static_charges.retrieve( @@ -66,7 +66,7 @@ def test_method_retrieve(self, client: ZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve(self, client: ZbdPayments) -> None: response = client.lightning_static_charges.with_raw_response.retrieve( @@ -78,7 +78,7 @@ def test_raw_response_retrieve(self, client: ZbdPayments) -> None: lightning_static_charge = response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: with client.lightning_static_charges.with_streaming_response.retrieve( @@ -92,7 +92,7 @@ def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -100,7 +100,7 @@ def test_path_params_retrieve(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_update(self, client: ZbdPayments) -> None: lightning_static_charge = client.lightning_static_charges.update( @@ -108,7 +108,7 @@ def test_method_update(self, client: ZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_update_with_all_params(self, client: ZbdPayments) -> None: lightning_static_charge = client.lightning_static_charges.update( @@ -123,7 +123,7 @@ def test_method_update_with_all_params(self, client: ZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_update(self, client: ZbdPayments) -> None: response = client.lightning_static_charges.with_raw_response.update( @@ -135,7 +135,7 @@ def test_raw_response_update(self, client: ZbdPayments) -> None: lightning_static_charge = response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_update(self, client: ZbdPayments) -> None: with client.lightning_static_charges.with_streaming_response.update( @@ -149,7 +149,7 @@ def test_streaming_response_update(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_update(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -163,13 +163,13 @@ class TestAsyncLightningStaticCharges: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create(self, async_client: AsyncZbdPayments) -> None: lightning_static_charge = await async_client.lightning_static_charges.create() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_static_charge = await async_client.lightning_static_charges.create( @@ -184,7 +184,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncZbdPayment ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_static_charges.with_raw_response.create() @@ -194,7 +194,7 @@ async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None lightning_static_charge = await response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_static_charges.with_streaming_response.create() as response: @@ -206,7 +206,7 @@ async def test_streaming_response_create(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: lightning_static_charge = await async_client.lightning_static_charges.retrieve( @@ -214,7 +214,7 @@ async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_static_charges.with_raw_response.retrieve( @@ -226,7 +226,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> No lightning_static_charge = await response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_static_charges.with_streaming_response.retrieve( @@ -240,7 +240,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -248,7 +248,7 @@ async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> Non "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_update(self, async_client: AsyncZbdPayments) -> None: lightning_static_charge = await async_client.lightning_static_charges.update( @@ -256,7 +256,7 @@ async def test_method_update(self, async_client: AsyncZbdPayments) -> None: ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_update_with_all_params(self, async_client: AsyncZbdPayments) -> None: lightning_static_charge = await async_client.lightning_static_charges.update( @@ -271,7 +271,7 @@ async def test_method_update_with_all_params(self, async_client: AsyncZbdPayment ) assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_update(self, async_client: AsyncZbdPayments) -> None: response = await async_client.lightning_static_charges.with_raw_response.update( @@ -283,7 +283,7 @@ async def test_raw_response_update(self, async_client: AsyncZbdPayments) -> None lightning_static_charge = await response.parse() assert lightning_static_charge is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_update(self, async_client: AsyncZbdPayments) -> None: async with async_client.lightning_static_charges.with_streaming_response.update( @@ -297,7 +297,7 @@ async def test_streaming_response_update(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_update(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): diff --git a/tests/api_resources/test_oauth2.py b/tests/api_resources/test_oauth2.py index 5928c78..4a7e365 100644 --- a/tests/api_resources/test_oauth2.py +++ b/tests/api_resources/test_oauth2.py @@ -15,13 +15,13 @@ class TestOauth2: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_authorization_url(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.create_authorization_url() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create_authorization_url(self, client: ZbdPayments) -> None: response = client.oauth2.with_raw_response.create_authorization_url() @@ -31,7 +31,7 @@ def test_raw_response_create_authorization_url(self, client: ZbdPayments) -> Non oauth2 = response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create_authorization_url(self, client: ZbdPayments) -> None: with client.oauth2.with_streaming_response.create_authorization_url() as response: @@ -43,13 +43,13 @@ def test_streaming_response_create_authorization_url(self, client: ZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_refresh_token(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.refresh_token() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_refresh_token(self, client: ZbdPayments) -> None: response = client.oauth2.with_raw_response.refresh_token() @@ -59,7 +59,7 @@ def test_raw_response_refresh_token(self, client: ZbdPayments) -> None: oauth2 = response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_refresh_token(self, client: ZbdPayments) -> None: with client.oauth2.with_streaming_response.refresh_token() as response: @@ -71,13 +71,13 @@ def test_streaming_response_refresh_token(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_user_data(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.retrieve_user_data() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_user_data_with_all_params(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.retrieve_user_data( @@ -85,7 +85,7 @@ def test_method_retrieve_user_data_with_all_params(self, client: ZbdPayments) -> ) assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_user_data(self, client: ZbdPayments) -> None: response = client.oauth2.with_raw_response.retrieve_user_data() @@ -95,7 +95,7 @@ def test_raw_response_retrieve_user_data(self, client: ZbdPayments) -> None: oauth2 = response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_user_data(self, client: ZbdPayments) -> None: with client.oauth2.with_streaming_response.retrieve_user_data() as response: @@ -107,13 +107,13 @@ def test_streaming_response_retrieve_user_data(self, client: ZbdPayments) -> Non assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_wallet_data(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.retrieve_wallet_data() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_wallet_data_with_all_params(self, client: ZbdPayments) -> None: oauth2 = client.oauth2.retrieve_wallet_data( @@ -121,7 +121,7 @@ def test_method_retrieve_wallet_data_with_all_params(self, client: ZbdPayments) ) assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_wallet_data(self, client: ZbdPayments) -> None: response = client.oauth2.with_raw_response.retrieve_wallet_data() @@ -131,7 +131,7 @@ def test_raw_response_retrieve_wallet_data(self, client: ZbdPayments) -> None: oauth2 = response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_wallet_data(self, client: ZbdPayments) -> None: with client.oauth2.with_streaming_response.retrieve_wallet_data() as response: @@ -149,13 +149,13 @@ class TestAsyncOauth2: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_authorization_url(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.create_authorization_url() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create_authorization_url(self, async_client: AsyncZbdPayments) -> None: response = await async_client.oauth2.with_raw_response.create_authorization_url() @@ -165,7 +165,7 @@ async def test_raw_response_create_authorization_url(self, async_client: AsyncZb oauth2 = await response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create_authorization_url(self, async_client: AsyncZbdPayments) -> None: async with async_client.oauth2.with_streaming_response.create_authorization_url() as response: @@ -177,13 +177,13 @@ async def test_streaming_response_create_authorization_url(self, async_client: A assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_refresh_token(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.refresh_token() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_refresh_token(self, async_client: AsyncZbdPayments) -> None: response = await async_client.oauth2.with_raw_response.refresh_token() @@ -193,7 +193,7 @@ async def test_raw_response_refresh_token(self, async_client: AsyncZbdPayments) oauth2 = await response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_refresh_token(self, async_client: AsyncZbdPayments) -> None: async with async_client.oauth2.with_streaming_response.refresh_token() as response: @@ -205,13 +205,13 @@ async def test_streaming_response_refresh_token(self, async_client: AsyncZbdPaym assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_user_data(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.retrieve_user_data() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_user_data_with_all_params(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.retrieve_user_data( @@ -219,7 +219,7 @@ async def test_method_retrieve_user_data_with_all_params(self, async_client: Asy ) assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_user_data(self, async_client: AsyncZbdPayments) -> None: response = await async_client.oauth2.with_raw_response.retrieve_user_data() @@ -229,7 +229,7 @@ async def test_raw_response_retrieve_user_data(self, async_client: AsyncZbdPayme oauth2 = await response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_user_data(self, async_client: AsyncZbdPayments) -> None: async with async_client.oauth2.with_streaming_response.retrieve_user_data() as response: @@ -241,13 +241,13 @@ async def test_streaming_response_retrieve_user_data(self, async_client: AsyncZb assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_wallet_data(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.retrieve_wallet_data() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_wallet_data_with_all_params(self, async_client: AsyncZbdPayments) -> None: oauth2 = await async_client.oauth2.retrieve_wallet_data( @@ -255,7 +255,7 @@ async def test_method_retrieve_wallet_data_with_all_params(self, async_client: A ) assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_wallet_data(self, async_client: AsyncZbdPayments) -> None: response = await async_client.oauth2.with_raw_response.retrieve_wallet_data() @@ -265,7 +265,7 @@ async def test_raw_response_retrieve_wallet_data(self, async_client: AsyncZbdPay oauth2 = await response.parse() assert oauth2 is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_wallet_data(self, async_client: AsyncZbdPayments) -> None: async with async_client.oauth2.with_streaming_response.retrieve_wallet_data() as response: diff --git a/tests/api_resources/test_utils.py b/tests/api_resources/test_utils.py index 241c815..a1b0f89 100644 --- a/tests/api_resources/test_utils.py +++ b/tests/api_resources/test_utils.py @@ -15,7 +15,7 @@ class TestUtils: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_check_ip_support(self, client: ZbdPayments) -> None: util = client.utils.check_ip_support( @@ -23,7 +23,7 @@ def test_method_check_ip_support(self, client: ZbdPayments) -> None: ) assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_check_ip_support(self, client: ZbdPayments) -> None: response = client.utils.with_raw_response.check_ip_support( @@ -35,7 +35,7 @@ def test_raw_response_check_ip_support(self, client: ZbdPayments) -> None: util = response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_check_ip_support(self, client: ZbdPayments) -> None: with client.utils.with_streaming_response.check_ip_support( @@ -49,7 +49,7 @@ def test_streaming_response_check_ip_support(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_check_ip_support(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ip` but received ''"): @@ -57,13 +57,13 @@ def test_path_params_check_ip_support(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_decode_lightning_charge(self, client: ZbdPayments) -> None: util = client.utils.decode_lightning_charge() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_decode_lightning_charge_with_all_params(self, client: ZbdPayments) -> None: util = client.utils.decode_lightning_charge( @@ -71,7 +71,7 @@ def test_method_decode_lightning_charge_with_all_params(self, client: ZbdPayment ) assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_decode_lightning_charge(self, client: ZbdPayments) -> None: response = client.utils.with_raw_response.decode_lightning_charge() @@ -81,7 +81,7 @@ def test_raw_response_decode_lightning_charge(self, client: ZbdPayments) -> None util = response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_decode_lightning_charge(self, client: ZbdPayments) -> None: with client.utils.with_streaming_response.decode_lightning_charge() as response: @@ -93,13 +93,13 @@ def test_streaming_response_decode_lightning_charge(self, client: ZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_list_prod_ips(self, client: ZbdPayments) -> None: util = client.utils.list_prod_ips() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_list_prod_ips(self, client: ZbdPayments) -> None: response = client.utils.with_raw_response.list_prod_ips() @@ -109,7 +109,7 @@ def test_raw_response_list_prod_ips(self, client: ZbdPayments) -> None: util = response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_list_prod_ips(self, client: ZbdPayments) -> None: with client.utils.with_streaming_response.list_prod_ips() as response: @@ -121,13 +121,13 @@ def test_streaming_response_list_prod_ips(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_btc_usd(self, client: ZbdPayments) -> None: util = client.utils.retrieve_btc_usd() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_btc_usd(self, client: ZbdPayments) -> None: response = client.utils.with_raw_response.retrieve_btc_usd() @@ -137,7 +137,7 @@ def test_raw_response_retrieve_btc_usd(self, client: ZbdPayments) -> None: util = response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_btc_usd(self, client: ZbdPayments) -> None: with client.utils.with_streaming_response.retrieve_btc_usd() as response: @@ -155,7 +155,7 @@ class TestAsyncUtils: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_check_ip_support(self, async_client: AsyncZbdPayments) -> None: util = await async_client.utils.check_ip_support( @@ -163,7 +163,7 @@ async def test_method_check_ip_support(self, async_client: AsyncZbdPayments) -> ) assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_check_ip_support(self, async_client: AsyncZbdPayments) -> None: response = await async_client.utils.with_raw_response.check_ip_support( @@ -175,7 +175,7 @@ async def test_raw_response_check_ip_support(self, async_client: AsyncZbdPayment util = await response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_check_ip_support(self, async_client: AsyncZbdPayments) -> None: async with async_client.utils.with_streaming_response.check_ip_support( @@ -189,7 +189,7 @@ async def test_streaming_response_check_ip_support(self, async_client: AsyncZbdP assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_check_ip_support(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `ip` but received ''"): @@ -197,13 +197,13 @@ async def test_path_params_check_ip_support(self, async_client: AsyncZbdPayments "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_decode_lightning_charge(self, async_client: AsyncZbdPayments) -> None: util = await async_client.utils.decode_lightning_charge() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_decode_lightning_charge_with_all_params(self, async_client: AsyncZbdPayments) -> None: util = await async_client.utils.decode_lightning_charge( @@ -211,7 +211,7 @@ async def test_method_decode_lightning_charge_with_all_params(self, async_client ) assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_decode_lightning_charge(self, async_client: AsyncZbdPayments) -> None: response = await async_client.utils.with_raw_response.decode_lightning_charge() @@ -221,7 +221,7 @@ async def test_raw_response_decode_lightning_charge(self, async_client: AsyncZbd util = await response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_decode_lightning_charge(self, async_client: AsyncZbdPayments) -> None: async with async_client.utils.with_streaming_response.decode_lightning_charge() as response: @@ -233,13 +233,13 @@ async def test_streaming_response_decode_lightning_charge(self, async_client: As assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_list_prod_ips(self, async_client: AsyncZbdPayments) -> None: util = await async_client.utils.list_prod_ips() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_list_prod_ips(self, async_client: AsyncZbdPayments) -> None: response = await async_client.utils.with_raw_response.list_prod_ips() @@ -249,7 +249,7 @@ async def test_raw_response_list_prod_ips(self, async_client: AsyncZbdPayments) util = await response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_list_prod_ips(self, async_client: AsyncZbdPayments) -> None: async with async_client.utils.with_streaming_response.list_prod_ips() as response: @@ -261,13 +261,13 @@ async def test_streaming_response_list_prod_ips(self, async_client: AsyncZbdPaym assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_btc_usd(self, async_client: AsyncZbdPayments) -> None: util = await async_client.utils.retrieve_btc_usd() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_btc_usd(self, async_client: AsyncZbdPayments) -> None: response = await async_client.utils.with_raw_response.retrieve_btc_usd() @@ -277,7 +277,7 @@ async def test_raw_response_retrieve_btc_usd(self, async_client: AsyncZbdPayment util = await response.parse() assert util is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_btc_usd(self, async_client: AsyncZbdPayments) -> None: async with async_client.utils.with_streaming_response.retrieve_btc_usd() as response: diff --git a/tests/api_resources/test_vouchers.py b/tests/api_resources/test_vouchers.py index 59b023a..2e18227 100644 --- a/tests/api_resources/test_vouchers.py +++ b/tests/api_resources/test_vouchers.py @@ -15,13 +15,13 @@ class TestVouchers: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create(self, client: ZbdPayments) -> None: voucher = client.vouchers.create() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_with_all_params(self, client: ZbdPayments) -> None: voucher = client.vouchers.create( @@ -30,7 +30,7 @@ def test_method_create_with_all_params(self, client: ZbdPayments) -> None: ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create(self, client: ZbdPayments) -> None: response = client.vouchers.with_raw_response.create() @@ -40,7 +40,7 @@ def test_raw_response_create(self, client: ZbdPayments) -> None: voucher = response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create(self, client: ZbdPayments) -> None: with client.vouchers.with_streaming_response.create() as response: @@ -52,7 +52,7 @@ def test_streaming_response_create(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve(self, client: ZbdPayments) -> None: voucher = client.vouchers.retrieve( @@ -60,7 +60,7 @@ def test_method_retrieve(self, client: ZbdPayments) -> None: ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve(self, client: ZbdPayments) -> None: response = client.vouchers.with_raw_response.retrieve( @@ -72,7 +72,7 @@ def test_raw_response_retrieve(self, client: ZbdPayments) -> None: voucher = response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: with client.vouchers.with_streaming_response.retrieve( @@ -86,7 +86,7 @@ def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -94,13 +94,13 @@ def test_path_params_retrieve(self, client: ZbdPayments) -> None: "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_redeem(self, client: ZbdPayments) -> None: voucher = client.vouchers.redeem() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_redeem_with_all_params(self, client: ZbdPayments) -> None: voucher = client.vouchers.redeem( @@ -108,7 +108,7 @@ def test_method_redeem_with_all_params(self, client: ZbdPayments) -> None: ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_redeem(self, client: ZbdPayments) -> None: response = client.vouchers.with_raw_response.redeem() @@ -118,7 +118,7 @@ def test_raw_response_redeem(self, client: ZbdPayments) -> None: voucher = response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_redeem(self, client: ZbdPayments) -> None: with client.vouchers.with_streaming_response.redeem() as response: @@ -130,13 +130,13 @@ def test_streaming_response_redeem(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_revoke(self, client: ZbdPayments) -> None: voucher = client.vouchers.revoke() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_revoke_with_all_params(self, client: ZbdPayments) -> None: voucher = client.vouchers.revoke( @@ -144,7 +144,7 @@ def test_method_revoke_with_all_params(self, client: ZbdPayments) -> None: ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_revoke(self, client: ZbdPayments) -> None: response = client.vouchers.with_raw_response.revoke() @@ -154,7 +154,7 @@ def test_raw_response_revoke(self, client: ZbdPayments) -> None: voucher = response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_revoke(self, client: ZbdPayments) -> None: with client.vouchers.with_streaming_response.revoke() as response: @@ -172,13 +172,13 @@ class TestAsyncVouchers: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.create() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.create( @@ -187,7 +187,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncZbdPayment ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None: response = await async_client.vouchers.with_raw_response.create() @@ -197,7 +197,7 @@ async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None voucher = await response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create(self, async_client: AsyncZbdPayments) -> None: async with async_client.vouchers.with_streaming_response.create() as response: @@ -209,7 +209,7 @@ async def test_streaming_response_create(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.retrieve( @@ -217,7 +217,7 @@ async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> None: response = await async_client.vouchers.with_raw_response.retrieve( @@ -229,7 +229,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> No voucher = await response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) -> None: async with async_client.vouchers.with_streaming_response.retrieve( @@ -243,7 +243,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -251,13 +251,13 @@ async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> Non "", ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_redeem(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.redeem() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_redeem_with_all_params(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.redeem( @@ -265,7 +265,7 @@ async def test_method_redeem_with_all_params(self, async_client: AsyncZbdPayment ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_redeem(self, async_client: AsyncZbdPayments) -> None: response = await async_client.vouchers.with_raw_response.redeem() @@ -275,7 +275,7 @@ async def test_raw_response_redeem(self, async_client: AsyncZbdPayments) -> None voucher = await response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_redeem(self, async_client: AsyncZbdPayments) -> None: async with async_client.vouchers.with_streaming_response.redeem() as response: @@ -287,13 +287,13 @@ async def test_streaming_response_redeem(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_revoke(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.revoke() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_revoke_with_all_params(self, async_client: AsyncZbdPayments) -> None: voucher = await async_client.vouchers.revoke( @@ -301,7 +301,7 @@ async def test_method_revoke_with_all_params(self, async_client: AsyncZbdPayment ) assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_revoke(self, async_client: AsyncZbdPayments) -> None: response = await async_client.vouchers.with_raw_response.revoke() @@ -311,7 +311,7 @@ async def test_raw_response_revoke(self, async_client: AsyncZbdPayments) -> None voucher = await response.parse() assert voucher is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_revoke(self, async_client: AsyncZbdPayments) -> None: async with async_client.vouchers.with_streaming_response.revoke() as response: diff --git a/tests/api_resources/test_wallet.py b/tests/api_resources/test_wallet.py index 3ad4f1b..bff2528 100644 --- a/tests/api_resources/test_wallet.py +++ b/tests/api_resources/test_wallet.py @@ -15,13 +15,13 @@ class TestWallet: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve_balance(self, client: ZbdPayments) -> None: wallet = client.wallet.retrieve_balance() assert wallet is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve_balance(self, client: ZbdPayments) -> None: response = client.wallet.with_raw_response.retrieve_balance() @@ -31,7 +31,7 @@ def test_raw_response_retrieve_balance(self, client: ZbdPayments) -> None: wallet = response.parse() assert wallet is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve_balance(self, client: ZbdPayments) -> None: with client.wallet.with_streaming_response.retrieve_balance() as response: @@ -49,13 +49,13 @@ class TestAsyncWallet: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve_balance(self, async_client: AsyncZbdPayments) -> None: wallet = await async_client.wallet.retrieve_balance() assert wallet is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve_balance(self, async_client: AsyncZbdPayments) -> None: response = await async_client.wallet.with_raw_response.retrieve_balance() @@ -65,7 +65,7 @@ async def test_raw_response_retrieve_balance(self, async_client: AsyncZbdPayment wallet = await response.parse() assert wallet is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve_balance(self, async_client: AsyncZbdPayments) -> None: async with async_client.wallet.with_streaming_response.retrieve_balance() as response: diff --git a/tests/api_resources/test_withdrawal_requests.py b/tests/api_resources/test_withdrawal_requests.py index 68d79a7..835d9e4 100644 --- a/tests/api_resources/test_withdrawal_requests.py +++ b/tests/api_resources/test_withdrawal_requests.py @@ -15,13 +15,13 @@ class TestWithdrawalRequests: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create(self, client: ZbdPayments) -> None: withdrawal_request = client.withdrawal_requests.create() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_create_with_all_params(self, client: ZbdPayments) -> None: withdrawal_request = client.withdrawal_requests.create( @@ -33,7 +33,7 @@ def test_method_create_with_all_params(self, client: ZbdPayments) -> None: ) assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_create(self, client: ZbdPayments) -> None: response = client.withdrawal_requests.with_raw_response.create() @@ -43,7 +43,7 @@ def test_raw_response_create(self, client: ZbdPayments) -> None: withdrawal_request = response.parse() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_create(self, client: ZbdPayments) -> None: with client.withdrawal_requests.with_streaming_response.create() as response: @@ -55,7 +55,7 @@ def test_streaming_response_create(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_method_retrieve(self, client: ZbdPayments) -> None: withdrawal_request = client.withdrawal_requests.retrieve( @@ -63,7 +63,7 @@ def test_method_retrieve(self, client: ZbdPayments) -> None: ) assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_raw_response_retrieve(self, client: ZbdPayments) -> None: response = client.withdrawal_requests.with_raw_response.retrieve( @@ -75,7 +75,7 @@ def test_raw_response_retrieve(self, client: ZbdPayments) -> None: withdrawal_request = response.parse() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: with client.withdrawal_requests.with_streaming_response.retrieve( @@ -89,7 +89,7 @@ def test_streaming_response_retrieve(self, client: ZbdPayments) -> None: assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize def test_path_params_retrieve(self, client: ZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): @@ -103,13 +103,13 @@ class TestAsyncWithdrawalRequests: "async_client", [False, True, {"http_client": "aiohttp"}], indirect=True, ids=["loose", "strict", "aiohttp"] ) - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create(self, async_client: AsyncZbdPayments) -> None: withdrawal_request = await async_client.withdrawal_requests.create() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_create_with_all_params(self, async_client: AsyncZbdPayments) -> None: withdrawal_request = await async_client.withdrawal_requests.create( @@ -121,7 +121,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncZbdPayment ) assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None: response = await async_client.withdrawal_requests.with_raw_response.create() @@ -131,7 +131,7 @@ async def test_raw_response_create(self, async_client: AsyncZbdPayments) -> None withdrawal_request = await response.parse() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_create(self, async_client: AsyncZbdPayments) -> None: async with async_client.withdrawal_requests.with_streaming_response.create() as response: @@ -143,7 +143,7 @@ async def test_streaming_response_create(self, async_client: AsyncZbdPayments) - assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: withdrawal_request = await async_client.withdrawal_requests.retrieve( @@ -151,7 +151,7 @@ async def test_method_retrieve(self, async_client: AsyncZbdPayments) -> None: ) assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> None: response = await async_client.withdrawal_requests.with_raw_response.retrieve( @@ -163,7 +163,7 @@ async def test_raw_response_retrieve(self, async_client: AsyncZbdPayments) -> No withdrawal_request = await response.parse() assert withdrawal_request is None - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) -> None: async with async_client.withdrawal_requests.with_streaming_response.retrieve( @@ -177,7 +177,7 @@ async def test_streaming_response_retrieve(self, async_client: AsyncZbdPayments) assert cast(Any, response.is_closed) is True - @pytest.mark.skip() + @pytest.mark.skip(reason="Prism tests are disabled") @parametrize async def test_path_params_retrieve(self, async_client: AsyncZbdPayments) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `id` but received ''"): diff --git a/tests/test_client.py b/tests/test_client.py index 050393c..f93fb10 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -6,13 +6,10 @@ import os import sys import json -import time import asyncio import inspect -import subprocess import tracemalloc from typing import Any, Union, cast -from textwrap import dedent from unittest import mock from typing_extensions import Literal @@ -23,14 +20,17 @@ from zbdpay import ZbdPayments, AsyncZbdPayments, APIResponseValidationError from zbdpay._types import Omit +from zbdpay._utils import asyncify from zbdpay._models import BaseModel, FinalRequestOptions from zbdpay._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError from zbdpay._base_client import ( DEFAULT_TIMEOUT, HTTPX_DEFAULT_TIMEOUT, BaseClient, + OtherPlatform, DefaultHttpxClient, DefaultAsyncHttpxClient, + get_platform, make_request_options, ) @@ -59,51 +59,49 @@ def _get_open_connections(client: ZbdPayments | AsyncZbdPayments) -> int: class TestZbdPayments: - client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - @pytest.mark.respx(base_url=base_url) - def test_raw_response(self, respx_mock: MockRouter) -> None: + def test_raw_response(self, respx_mock: MockRouter, client: ZbdPayments) -> None: respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = self.client.post("/foo", cast_to=httpx.Response) + response = client.post("/foo", cast_to=httpx.Response) assert response.status_code == 200 assert isinstance(response, httpx.Response) assert response.json() == {"foo": "bar"} @pytest.mark.respx(base_url=base_url) - def test_raw_response_for_binary(self, respx_mock: MockRouter) -> None: + def test_raw_response_for_binary(self, respx_mock: MockRouter, client: ZbdPayments) -> None: respx_mock.post("/foo").mock( return_value=httpx.Response(200, headers={"Content-Type": "application/binary"}, content='{"foo": "bar"}') ) - response = self.client.post("/foo", cast_to=httpx.Response) + response = client.post("/foo", cast_to=httpx.Response) assert response.status_code == 200 assert isinstance(response, httpx.Response) assert response.json() == {"foo": "bar"} - def test_copy(self) -> None: - copied = self.client.copy() - assert id(copied) != id(self.client) + def test_copy(self, client: ZbdPayments) -> None: + copied = client.copy() + assert id(copied) != id(client) - copied = self.client.copy(apikey="another My Apikey") + copied = client.copy(apikey="another My Apikey") assert copied.apikey == "another My Apikey" - assert self.client.apikey == "My Apikey" + assert client.apikey == "My Apikey" - def test_copy_default_options(self) -> None: + def test_copy_default_options(self, client: ZbdPayments) -> None: # options that have a default are overridden correctly - copied = self.client.copy(max_retries=7) + copied = client.copy(max_retries=7) assert copied.max_retries == 7 - assert self.client.max_retries == 2 + assert client.max_retries == 2 copied2 = copied.copy(max_retries=6) assert copied2.max_retries == 6 assert copied.max_retries == 7 # timeout - assert isinstance(self.client.timeout, httpx.Timeout) - copied = self.client.copy(timeout=None) + assert isinstance(client.timeout, httpx.Timeout) + copied = client.copy(timeout=None) assert copied.timeout is None - assert isinstance(self.client.timeout, httpx.Timeout) + assert isinstance(client.timeout, httpx.Timeout) def test_copy_default_headers(self) -> None: client = ZbdPayments( @@ -138,6 +136,7 @@ def test_copy_default_headers(self) -> None: match="`default_headers` and `set_default_headers` arguments are mutually exclusive", ): client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"}) + client.close() def test_copy_default_query(self) -> None: client = ZbdPayments( @@ -175,13 +174,15 @@ def test_copy_default_query(self) -> None: ): client.copy(set_default_query={}, default_query={"foo": "Bar"}) - def test_copy_signature(self) -> None: + client.close() + + def test_copy_signature(self, client: ZbdPayments) -> None: # ensure the same parameters that can be passed to the client are defined in the `.copy()` method init_signature = inspect.signature( # mypy doesn't like that we access the `__init__` property. - self.client.__init__, # type: ignore[misc] + client.__init__, # type: ignore[misc] ) - copy_signature = inspect.signature(self.client.copy) + copy_signature = inspect.signature(client.copy) exclude_params = {"transport", "proxies", "_strict_response_validation"} for name in init_signature.parameters.keys(): @@ -192,12 +193,12 @@ def test_copy_signature(self) -> None: assert copy_param is not None, f"copy() signature is missing the {name} param" @pytest.mark.skipif(sys.version_info >= (3, 10), reason="fails because of a memory leak that started from 3.12") - def test_copy_build_request(self) -> None: + def test_copy_build_request(self, client: ZbdPayments) -> None: options = FinalRequestOptions(method="get", url="/foo") def build_request(options: FinalRequestOptions) -> None: - client = self.client.copy() - client._build_request(options) + client_copy = client.copy() + client_copy._build_request(options) # ensure that the machinery is warmed up before tracing starts. build_request(options) @@ -254,14 +255,12 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic print(frame) raise AssertionError() - def test_request_timeout(self) -> None: - request = self.client._build_request(FinalRequestOptions(method="get", url="/foo")) + def test_request_timeout(self, client: ZbdPayments) -> None: + request = client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT - request = self.client._build_request( - FinalRequestOptions(method="get", url="/foo", timeout=httpx.Timeout(100.0)) - ) + request = client._build_request(FinalRequestOptions(method="get", url="/foo", timeout=httpx.Timeout(100.0))) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == httpx.Timeout(100.0) @@ -274,6 +273,8 @@ def test_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == httpx.Timeout(0) + client.close() + def test_http_client_timeout_option(self) -> None: # custom timeout given to the httpx client should be used with httpx.Client(timeout=None) as http_client: @@ -285,6 +286,8 @@ def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == httpx.Timeout(None) + client.close() + # no timeout given to the httpx client should not use the httpx default with httpx.Client() as http_client: client = ZbdPayments( @@ -295,6 +298,8 @@ def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT + client.close() + # explicitly passing the default timeout currently results in it being ignored with httpx.Client(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client: client = ZbdPayments( @@ -305,6 +310,8 @@ def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT # our default + client.close() + async def test_invalid_http_client(self) -> None: with pytest.raises(TypeError, match="Invalid `http_client` arg"): async with httpx.AsyncClient() as http_client: @@ -316,14 +323,14 @@ async def test_invalid_http_client(self) -> None: ) def test_default_headers_option(self) -> None: - client = ZbdPayments( + test_client = ZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, default_headers={"X-Foo": "bar"} ) - request = client._build_request(FinalRequestOptions(method="get", url="/foo")) + request = test_client._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "bar" assert request.headers.get("x-stainless-lang") == "python" - client2 = ZbdPayments( + test_client2 = ZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, @@ -332,10 +339,13 @@ def test_default_headers_option(self) -> None: "X-Stainless-Lang": "my-overriding-header", }, ) - request = client2._build_request(FinalRequestOptions(method="get", url="/foo")) + request = test_client2._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "stainless" assert request.headers.get("x-stainless-lang") == "my-overriding-header" + test_client.close() + test_client2.close() + def test_validate_headers(self) -> None: client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) @@ -371,8 +381,10 @@ def test_default_query_option(self) -> None: url = httpx.URL(request.url) assert dict(url.params) == {"foo": "baz", "query_param": "overridden"} - def test_request_extra_json(self) -> None: - request = self.client._build_request( + client.close() + + def test_request_extra_json(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -383,7 +395,7 @@ def test_request_extra_json(self) -> None: data = json.loads(request.content.decode("utf-8")) assert data == {"foo": "bar", "baz": False} - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -394,7 +406,7 @@ def test_request_extra_json(self) -> None: assert data == {"baz": False} # `extra_json` takes priority over `json_data` when keys clash - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -405,8 +417,8 @@ def test_request_extra_json(self) -> None: data = json.loads(request.content.decode("utf-8")) assert data == {"foo": "bar", "baz": None} - def test_request_extra_headers(self) -> None: - request = self.client._build_request( + def test_request_extra_headers(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -416,7 +428,7 @@ def test_request_extra_headers(self) -> None: assert request.headers.get("X-Foo") == "Foo" # `extra_headers` takes priority over `default_headers` when keys clash - request = self.client.with_options(default_headers={"X-Bar": "true"})._build_request( + request = client.with_options(default_headers={"X-Bar": "true"})._build_request( FinalRequestOptions( method="post", url="/foo", @@ -427,8 +439,8 @@ def test_request_extra_headers(self) -> None: ) assert request.headers.get("X-Bar") == "false" - def test_request_extra_query(self) -> None: - request = self.client._build_request( + def test_request_extra_query(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -441,7 +453,7 @@ def test_request_extra_query(self) -> None: assert params == {"my_query_param": "Foo"} # if both `query` and `extra_query` are given, they are merged - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -455,7 +467,7 @@ def test_request_extra_query(self) -> None: assert params == {"bar": "1", "foo": "2"} # `extra_query` takes priority over `query` when keys clash - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -471,7 +483,7 @@ def test_request_extra_query(self) -> None: def test_multipart_repeating_array(self, client: ZbdPayments) -> None: request = client._build_request( FinalRequestOptions.construct( - method="get", + method="post", url="/foo", headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"}, json_data={"array": ["foo", "bar"]}, @@ -498,7 +510,7 @@ def test_multipart_repeating_array(self, client: ZbdPayments) -> None: ] @pytest.mark.respx(base_url=base_url) - def test_basic_union_response(self, respx_mock: MockRouter) -> None: + def test_basic_union_response(self, respx_mock: MockRouter, client: ZbdPayments) -> None: class Model1(BaseModel): name: str @@ -507,12 +519,12 @@ class Model2(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model2) assert response.foo == "bar" @pytest.mark.respx(base_url=base_url) - def test_union_response_different_types(self, respx_mock: MockRouter) -> None: + def test_union_response_different_types(self, respx_mock: MockRouter, client: ZbdPayments) -> None: """Union of objects with the same field name using a different type""" class Model1(BaseModel): @@ -523,18 +535,18 @@ class Model2(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model2) assert response.foo == "bar" respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": 1})) - response = self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model1) assert response.foo == 1 @pytest.mark.respx(base_url=base_url) - def test_non_application_json_content_type_for_json_data(self, respx_mock: MockRouter) -> None: + def test_non_application_json_content_type_for_json_data(self, respx_mock: MockRouter, client: ZbdPayments) -> None: """ Response that sets Content-Type to something other than application/json but returns json data """ @@ -550,7 +562,7 @@ class Model(BaseModel): ) ) - response = self.client.get("/foo", cast_to=Model) + response = client.get("/foo", cast_to=Model) assert isinstance(response, Model) assert response.foo == 2 @@ -562,6 +574,8 @@ def test_base_url_setter(self) -> None: assert client.base_url == "https://example.com/from_setter/" + client.close() + def test_base_url_env(self) -> None: with update_env(ZBD_PAYMENTS_BASE_URL="http://localhost:5000/from/env"): client = ZbdPayments(apikey=apikey, _strict_response_validation=True) @@ -589,6 +603,7 @@ def test_base_url_trailing_slash(self, client: ZbdPayments) -> None: ), ) assert request.url == "http://localhost:5000/custom/path/foo" + client.close() @pytest.mark.parametrize( "client", @@ -612,6 +627,7 @@ def test_base_url_no_trailing_slash(self, client: ZbdPayments) -> None: ), ) assert request.url == "http://localhost:5000/custom/path/foo" + client.close() @pytest.mark.parametrize( "client", @@ -635,35 +651,36 @@ def test_absolute_request_url(self, client: ZbdPayments) -> None: ), ) assert request.url == "https://myapi.com/foo" + client.close() def test_copied_client_does_not_close_http(self) -> None: - client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - assert not client.is_closed() + test_client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) + assert not test_client.is_closed() - copied = client.copy() - assert copied is not client + copied = test_client.copy() + assert copied is not test_client del copied - assert not client.is_closed() + assert not test_client.is_closed() def test_client_context_manager(self) -> None: - client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - with client as c2: - assert c2 is client + test_client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) + with test_client as c2: + assert c2 is test_client assert not c2.is_closed() - assert not client.is_closed() - assert client.is_closed() + assert not test_client.is_closed() + assert test_client.is_closed() @pytest.mark.respx(base_url=base_url) - def test_client_response_validation_error(self, respx_mock: MockRouter) -> None: + def test_client_response_validation_error(self, respx_mock: MockRouter, client: ZbdPayments) -> None: class Model(BaseModel): foo: str respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": {"invalid": True}})) with pytest.raises(APIResponseValidationError) as exc: - self.client.get("/foo", cast_to=Model) + client.get("/foo", cast_to=Model) assert isinstance(exc.value.__cause__, ValidationError) @@ -683,11 +700,14 @@ class Model(BaseModel): with pytest.raises(APIResponseValidationError): strict_client.get("/foo", cast_to=Model) - client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=False) + non_strict_client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=False) - response = client.get("/foo", cast_to=Model) + response = non_strict_client.get("/foo", cast_to=Model) assert isinstance(response, str) # type: ignore[unreachable] + strict_client.close() + non_strict_client.close() + @pytest.mark.parametrize( "remaining_retries,retry_after,timeout", [ @@ -710,9 +730,9 @@ class Model(BaseModel): ], ) @mock.patch("time.time", mock.MagicMock(return_value=1696004797)) - def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None: - client = ZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - + def test_parse_retry_after_header( + self, remaining_retries: int, retry_after: str, timeout: float, client: ZbdPayments + ) -> None: headers = httpx.Headers({"retry-after": retry_after}) options = FinalRequestOptions(method="get", url="/foo", max_retries=3) calculated = client._calculate_retry_timeout(remaining_retries, options, headers) @@ -726,7 +746,7 @@ def test_retrying_timeout_errors_doesnt_leak(self, respx_mock: MockRouter, clien with pytest.raises(APITimeoutError): client.lightning_address.with_streaming_response.send_payment().__enter__() - assert _get_open_connections(self.client) == 0 + assert _get_open_connections(client) == 0 @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @@ -735,7 +755,7 @@ def test_retrying_status_errors_doesnt_leak(self, respx_mock: MockRouter, client with pytest.raises(APIStatusError): client.lightning_address.with_streaming_response.send_payment().__enter__() - assert _get_open_connections(self.client) == 0 + assert _get_open_connections(client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @@ -841,83 +861,77 @@ def test_default_client_creation(self) -> None: ) @pytest.mark.respx(base_url=base_url) - def test_follow_redirects(self, respx_mock: MockRouter) -> None: + def test_follow_redirects(self, respx_mock: MockRouter, client: ZbdPayments) -> None: # Test that the default follow_redirects=True allows following redirects respx_mock.post("/redirect").mock( return_value=httpx.Response(302, headers={"Location": f"{base_url}/redirected"}) ) respx_mock.get("/redirected").mock(return_value=httpx.Response(200, json={"status": "ok"})) - response = self.client.post("/redirect", body={"key": "value"}, cast_to=httpx.Response) + response = client.post("/redirect", body={"key": "value"}, cast_to=httpx.Response) assert response.status_code == 200 assert response.json() == {"status": "ok"} @pytest.mark.respx(base_url=base_url) - def test_follow_redirects_disabled(self, respx_mock: MockRouter) -> None: + def test_follow_redirects_disabled(self, respx_mock: MockRouter, client: ZbdPayments) -> None: # Test that follow_redirects=False prevents following redirects respx_mock.post("/redirect").mock( return_value=httpx.Response(302, headers={"Location": f"{base_url}/redirected"}) ) with pytest.raises(APIStatusError) as exc_info: - self.client.post( - "/redirect", body={"key": "value"}, options={"follow_redirects": False}, cast_to=httpx.Response - ) + client.post("/redirect", body={"key": "value"}, options={"follow_redirects": False}, cast_to=httpx.Response) assert exc_info.value.response.status_code == 302 assert exc_info.value.response.headers["Location"] == f"{base_url}/redirected" class TestAsyncZbdPayments: - client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio - async def test_raw_response(self, respx_mock: MockRouter) -> None: + async def test_raw_response(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: respx_mock.post("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = await self.client.post("/foo", cast_to=httpx.Response) + response = await async_client.post("/foo", cast_to=httpx.Response) assert response.status_code == 200 assert isinstance(response, httpx.Response) assert response.json() == {"foo": "bar"} @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio - async def test_raw_response_for_binary(self, respx_mock: MockRouter) -> None: + async def test_raw_response_for_binary(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: respx_mock.post("/foo").mock( return_value=httpx.Response(200, headers={"Content-Type": "application/binary"}, content='{"foo": "bar"}') ) - response = await self.client.post("/foo", cast_to=httpx.Response) + response = await async_client.post("/foo", cast_to=httpx.Response) assert response.status_code == 200 assert isinstance(response, httpx.Response) assert response.json() == {"foo": "bar"} - def test_copy(self) -> None: - copied = self.client.copy() - assert id(copied) != id(self.client) + def test_copy(self, async_client: AsyncZbdPayments) -> None: + copied = async_client.copy() + assert id(copied) != id(async_client) - copied = self.client.copy(apikey="another My Apikey") + copied = async_client.copy(apikey="another My Apikey") assert copied.apikey == "another My Apikey" - assert self.client.apikey == "My Apikey" + assert async_client.apikey == "My Apikey" - def test_copy_default_options(self) -> None: + def test_copy_default_options(self, async_client: AsyncZbdPayments) -> None: # options that have a default are overridden correctly - copied = self.client.copy(max_retries=7) + copied = async_client.copy(max_retries=7) assert copied.max_retries == 7 - assert self.client.max_retries == 2 + assert async_client.max_retries == 2 copied2 = copied.copy(max_retries=6) assert copied2.max_retries == 6 assert copied.max_retries == 7 # timeout - assert isinstance(self.client.timeout, httpx.Timeout) - copied = self.client.copy(timeout=None) + assert isinstance(async_client.timeout, httpx.Timeout) + copied = async_client.copy(timeout=None) assert copied.timeout is None - assert isinstance(self.client.timeout, httpx.Timeout) + assert isinstance(async_client.timeout, httpx.Timeout) - def test_copy_default_headers(self) -> None: + async def test_copy_default_headers(self) -> None: client = AsyncZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, default_headers={"X-Foo": "bar"} ) @@ -950,8 +964,9 @@ def test_copy_default_headers(self) -> None: match="`default_headers` and `set_default_headers` arguments are mutually exclusive", ): client.copy(set_default_headers={}, default_headers={"X-Foo": "Bar"}) + await client.close() - def test_copy_default_query(self) -> None: + async def test_copy_default_query(self) -> None: client = AsyncZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, default_query={"foo": "bar"} ) @@ -987,13 +1002,15 @@ def test_copy_default_query(self) -> None: ): client.copy(set_default_query={}, default_query={"foo": "Bar"}) - def test_copy_signature(self) -> None: + await client.close() + + def test_copy_signature(self, async_client: AsyncZbdPayments) -> None: # ensure the same parameters that can be passed to the client are defined in the `.copy()` method init_signature = inspect.signature( # mypy doesn't like that we access the `__init__` property. - self.client.__init__, # type: ignore[misc] + async_client.__init__, # type: ignore[misc] ) - copy_signature = inspect.signature(self.client.copy) + copy_signature = inspect.signature(async_client.copy) exclude_params = {"transport", "proxies", "_strict_response_validation"} for name in init_signature.parameters.keys(): @@ -1004,12 +1021,12 @@ def test_copy_signature(self) -> None: assert copy_param is not None, f"copy() signature is missing the {name} param" @pytest.mark.skipif(sys.version_info >= (3, 10), reason="fails because of a memory leak that started from 3.12") - def test_copy_build_request(self) -> None: + def test_copy_build_request(self, async_client: AsyncZbdPayments) -> None: options = FinalRequestOptions(method="get", url="/foo") def build_request(options: FinalRequestOptions) -> None: - client = self.client.copy() - client._build_request(options) + client_copy = async_client.copy() + client_copy._build_request(options) # ensure that the machinery is warmed up before tracing starts. build_request(options) @@ -1066,12 +1083,12 @@ def add_leak(leaks: list[tracemalloc.StatisticDiff], diff: tracemalloc.Statistic print(frame) raise AssertionError() - async def test_request_timeout(self) -> None: - request = self.client._build_request(FinalRequestOptions(method="get", url="/foo")) + async def test_request_timeout(self, async_client: AsyncZbdPayments) -> None: + request = async_client._build_request(FinalRequestOptions(method="get", url="/foo")) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT - request = self.client._build_request( + request = async_client._build_request( FinalRequestOptions(method="get", url="/foo", timeout=httpx.Timeout(100.0)) ) timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore @@ -1086,6 +1103,8 @@ async def test_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == httpx.Timeout(0) + await client.close() + async def test_http_client_timeout_option(self) -> None: # custom timeout given to the httpx client should be used async with httpx.AsyncClient(timeout=None) as http_client: @@ -1097,6 +1116,8 @@ async def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == httpx.Timeout(None) + await client.close() + # no timeout given to the httpx client should not use the httpx default async with httpx.AsyncClient() as http_client: client = AsyncZbdPayments( @@ -1107,6 +1128,8 @@ async def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT + await client.close() + # explicitly passing the default timeout currently results in it being ignored async with httpx.AsyncClient(timeout=HTTPX_DEFAULT_TIMEOUT) as http_client: client = AsyncZbdPayments( @@ -1117,6 +1140,8 @@ async def test_http_client_timeout_option(self) -> None: timeout = httpx.Timeout(**request.extensions["timeout"]) # type: ignore assert timeout == DEFAULT_TIMEOUT # our default + await client.close() + def test_invalid_http_client(self) -> None: with pytest.raises(TypeError, match="Invalid `http_client` arg"): with httpx.Client() as http_client: @@ -1127,15 +1152,15 @@ def test_invalid_http_client(self) -> None: http_client=cast(Any, http_client), ) - def test_default_headers_option(self) -> None: - client = AsyncZbdPayments( + async def test_default_headers_option(self) -> None: + test_client = AsyncZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, default_headers={"X-Foo": "bar"} ) - request = client._build_request(FinalRequestOptions(method="get", url="/foo")) + request = test_client._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "bar" assert request.headers.get("x-stainless-lang") == "python" - client2 = AsyncZbdPayments( + test_client2 = AsyncZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, @@ -1144,10 +1169,13 @@ def test_default_headers_option(self) -> None: "X-Stainless-Lang": "my-overriding-header", }, ) - request = client2._build_request(FinalRequestOptions(method="get", url="/foo")) + request = test_client2._build_request(FinalRequestOptions(method="get", url="/foo")) assert request.headers.get("x-foo") == "stainless" assert request.headers.get("x-stainless-lang") == "my-overriding-header" + await test_client.close() + await test_client2.close() + def test_validate_headers(self) -> None: client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) request = client._build_request(FinalRequestOptions(method="get", url="/foo")) @@ -1165,7 +1193,7 @@ def test_validate_headers(self) -> None: request2 = client2._build_request(FinalRequestOptions(method="get", url="/foo", headers={"apikey": Omit()})) assert request2.headers.get("apikey") is None - def test_default_query_option(self) -> None: + async def test_default_query_option(self) -> None: client = AsyncZbdPayments( base_url=base_url, apikey=apikey, _strict_response_validation=True, default_query={"query_param": "bar"} ) @@ -1183,8 +1211,10 @@ def test_default_query_option(self) -> None: url = httpx.URL(request.url) assert dict(url.params) == {"foo": "baz", "query_param": "overridden"} - def test_request_extra_json(self) -> None: - request = self.client._build_request( + await client.close() + + def test_request_extra_json(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1195,7 +1225,7 @@ def test_request_extra_json(self) -> None: data = json.loads(request.content.decode("utf-8")) assert data == {"foo": "bar", "baz": False} - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1206,7 +1236,7 @@ def test_request_extra_json(self) -> None: assert data == {"baz": False} # `extra_json` takes priority over `json_data` when keys clash - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1217,8 +1247,8 @@ def test_request_extra_json(self) -> None: data = json.loads(request.content.decode("utf-8")) assert data == {"foo": "bar", "baz": None} - def test_request_extra_headers(self) -> None: - request = self.client._build_request( + def test_request_extra_headers(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1228,7 +1258,7 @@ def test_request_extra_headers(self) -> None: assert request.headers.get("X-Foo") == "Foo" # `extra_headers` takes priority over `default_headers` when keys clash - request = self.client.with_options(default_headers={"X-Bar": "true"})._build_request( + request = client.with_options(default_headers={"X-Bar": "true"})._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1239,8 +1269,8 @@ def test_request_extra_headers(self) -> None: ) assert request.headers.get("X-Bar") == "false" - def test_request_extra_query(self) -> None: - request = self.client._build_request( + def test_request_extra_query(self, client: ZbdPayments) -> None: + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1253,7 +1283,7 @@ def test_request_extra_query(self) -> None: assert params == {"my_query_param": "Foo"} # if both `query` and `extra_query` are given, they are merged - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1267,7 +1297,7 @@ def test_request_extra_query(self) -> None: assert params == {"bar": "1", "foo": "2"} # `extra_query` takes priority over `query` when keys clash - request = self.client._build_request( + request = client._build_request( FinalRequestOptions( method="post", url="/foo", @@ -1283,7 +1313,7 @@ def test_request_extra_query(self) -> None: def test_multipart_repeating_array(self, async_client: AsyncZbdPayments) -> None: request = async_client._build_request( FinalRequestOptions.construct( - method="get", + method="post", url="/foo", headers={"Content-Type": "multipart/form-data; boundary=6b7ba517decee4a450543ea6ae821c82"}, json_data={"array": ["foo", "bar"]}, @@ -1310,7 +1340,7 @@ def test_multipart_repeating_array(self, async_client: AsyncZbdPayments) -> None ] @pytest.mark.respx(base_url=base_url) - async def test_basic_union_response(self, respx_mock: MockRouter) -> None: + async def test_basic_union_response(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: class Model1(BaseModel): name: str @@ -1319,12 +1349,12 @@ class Model2(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = await async_client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model2) assert response.foo == "bar" @pytest.mark.respx(base_url=base_url) - async def test_union_response_different_types(self, respx_mock: MockRouter) -> None: + async def test_union_response_different_types(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: """Union of objects with the same field name using a different type""" class Model1(BaseModel): @@ -1335,18 +1365,20 @@ class Model2(BaseModel): respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": "bar"})) - response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = await async_client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model2) assert response.foo == "bar" respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": 1})) - response = await self.client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) + response = await async_client.get("/foo", cast_to=cast(Any, Union[Model1, Model2])) assert isinstance(response, Model1) assert response.foo == 1 @pytest.mark.respx(base_url=base_url) - async def test_non_application_json_content_type_for_json_data(self, respx_mock: MockRouter) -> None: + async def test_non_application_json_content_type_for_json_data( + self, respx_mock: MockRouter, async_client: AsyncZbdPayments + ) -> None: """ Response that sets Content-Type to something other than application/json but returns json data """ @@ -1362,11 +1394,11 @@ class Model(BaseModel): ) ) - response = await self.client.get("/foo", cast_to=Model) + response = await async_client.get("/foo", cast_to=Model) assert isinstance(response, Model) assert response.foo == 2 - def test_base_url_setter(self) -> None: + async def test_base_url_setter(self) -> None: client = AsyncZbdPayments( base_url="https://example.com/from_init", apikey=apikey, _strict_response_validation=True ) @@ -1376,7 +1408,9 @@ def test_base_url_setter(self) -> None: assert client.base_url == "https://example.com/from_setter/" - def test_base_url_env(self) -> None: + await client.close() + + async def test_base_url_env(self) -> None: with update_env(ZBD_PAYMENTS_BASE_URL="http://localhost:5000/from/env"): client = AsyncZbdPayments(apikey=apikey, _strict_response_validation=True) assert client.base_url == "http://localhost:5000/from/env/" @@ -1396,7 +1430,7 @@ def test_base_url_env(self) -> None: ], ids=["standard", "custom http client"], ) - def test_base_url_trailing_slash(self, client: AsyncZbdPayments) -> None: + async def test_base_url_trailing_slash(self, client: AsyncZbdPayments) -> None: request = client._build_request( FinalRequestOptions( method="post", @@ -1405,6 +1439,7 @@ def test_base_url_trailing_slash(self, client: AsyncZbdPayments) -> None: ), ) assert request.url == "http://localhost:5000/custom/path/foo" + await client.close() @pytest.mark.parametrize( "client", @@ -1421,7 +1456,7 @@ def test_base_url_trailing_slash(self, client: AsyncZbdPayments) -> None: ], ids=["standard", "custom http client"], ) - def test_base_url_no_trailing_slash(self, client: AsyncZbdPayments) -> None: + async def test_base_url_no_trailing_slash(self, client: AsyncZbdPayments) -> None: request = client._build_request( FinalRequestOptions( method="post", @@ -1430,6 +1465,7 @@ def test_base_url_no_trailing_slash(self, client: AsyncZbdPayments) -> None: ), ) assert request.url == "http://localhost:5000/custom/path/foo" + await client.close() @pytest.mark.parametrize( "client", @@ -1446,7 +1482,7 @@ def test_base_url_no_trailing_slash(self, client: AsyncZbdPayments) -> None: ], ids=["standard", "custom http client"], ) - def test_absolute_request_url(self, client: AsyncZbdPayments) -> None: + async def test_absolute_request_url(self, client: AsyncZbdPayments) -> None: request = client._build_request( FinalRequestOptions( method="post", @@ -1455,37 +1491,39 @@ def test_absolute_request_url(self, client: AsyncZbdPayments) -> None: ), ) assert request.url == "https://myapi.com/foo" + await client.close() async def test_copied_client_does_not_close_http(self) -> None: - client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - assert not client.is_closed() + test_client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) + assert not test_client.is_closed() - copied = client.copy() - assert copied is not client + copied = test_client.copy() + assert copied is not test_client del copied await asyncio.sleep(0.2) - assert not client.is_closed() + assert not test_client.is_closed() async def test_client_context_manager(self) -> None: - client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - async with client as c2: - assert c2 is client + test_client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) + async with test_client as c2: + assert c2 is test_client assert not c2.is_closed() - assert not client.is_closed() - assert client.is_closed() + assert not test_client.is_closed() + assert test_client.is_closed() @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio - async def test_client_response_validation_error(self, respx_mock: MockRouter) -> None: + async def test_client_response_validation_error( + self, respx_mock: MockRouter, async_client: AsyncZbdPayments + ) -> None: class Model(BaseModel): foo: str respx_mock.get("/foo").mock(return_value=httpx.Response(200, json={"foo": {"invalid": True}})) with pytest.raises(APIResponseValidationError) as exc: - await self.client.get("/foo", cast_to=Model) + await async_client.get("/foo", cast_to=Model) assert isinstance(exc.value.__cause__, ValidationError) @@ -1496,7 +1534,6 @@ async def test_client_max_retries_validation(self) -> None: ) @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio async def test_received_text_for_expected_json(self, respx_mock: MockRouter) -> None: class Model(BaseModel): name: str @@ -1508,11 +1545,14 @@ class Model(BaseModel): with pytest.raises(APIResponseValidationError): await strict_client.get("/foo", cast_to=Model) - client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=False) + non_strict_client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=False) - response = await client.get("/foo", cast_to=Model) + response = await non_strict_client.get("/foo", cast_to=Model) assert isinstance(response, str) # type: ignore[unreachable] + await strict_client.close() + await non_strict_client.close() + @pytest.mark.parametrize( "remaining_retries,retry_after,timeout", [ @@ -1535,13 +1575,12 @@ class Model(BaseModel): ], ) @mock.patch("time.time", mock.MagicMock(return_value=1696004797)) - @pytest.mark.asyncio - async def test_parse_retry_after_header(self, remaining_retries: int, retry_after: str, timeout: float) -> None: - client = AsyncZbdPayments(base_url=base_url, apikey=apikey, _strict_response_validation=True) - + async def test_parse_retry_after_header( + self, remaining_retries: int, retry_after: str, timeout: float, async_client: AsyncZbdPayments + ) -> None: headers = httpx.Headers({"retry-after": retry_after}) options = FinalRequestOptions(method="get", url="/foo", max_retries=3) - calculated = client._calculate_retry_timeout(remaining_retries, options, headers) + calculated = async_client._calculate_retry_timeout(remaining_retries, options, headers) assert calculated == pytest.approx(timeout, 0.5 * 0.875) # pyright: ignore[reportUnknownMemberType] @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @@ -1554,7 +1593,7 @@ async def test_retrying_timeout_errors_doesnt_leak( with pytest.raises(APITimeoutError): await async_client.lightning_address.with_streaming_response.send_payment().__aenter__() - assert _get_open_connections(self.client) == 0 + assert _get_open_connections(async_client) == 0 @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) @@ -1565,12 +1604,11 @@ async def test_retrying_status_errors_doesnt_leak( with pytest.raises(APIStatusError): await async_client.lightning_address.with_streaming_response.send_payment().__aenter__() - assert _get_open_connections(self.client) == 0 + assert _get_open_connections(async_client) == 0 @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio @pytest.mark.parametrize("failure_mode", ["status", "exception"]) async def test_retries_taken( self, @@ -1602,7 +1640,6 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio async def test_omit_retry_count_header( self, async_client: AsyncZbdPayments, failures_before_success: int, respx_mock: MockRouter ) -> None: @@ -1628,7 +1665,6 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: @pytest.mark.parametrize("failures_before_success", [0, 2, 4]) @mock.patch("zbdpay._base_client.BaseClient._calculate_retry_timeout", _low_retry_timeout) @pytest.mark.respx(base_url=base_url) - @pytest.mark.asyncio async def test_overwrite_retry_count_header( self, async_client: AsyncZbdPayments, failures_before_success: int, respx_mock: MockRouter ) -> None: @@ -1651,50 +1687,9 @@ def retry_handler(_request: httpx.Request) -> httpx.Response: assert response.http_request.headers.get("x-stainless-retry-count") == "42" - def test_get_platform(self) -> None: - # A previous implementation of asyncify could leave threads unterminated when - # used with nest_asyncio. - # - # Since nest_asyncio.apply() is global and cannot be un-applied, this - # test is run in a separate process to avoid affecting other tests. - test_code = dedent(""" - import asyncio - import nest_asyncio - import threading - - from zbdpay._utils import asyncify - from zbdpay._base_client import get_platform - - async def test_main() -> None: - result = await asyncify(get_platform)() - print(result) - for thread in threading.enumerate(): - print(thread.name) - - nest_asyncio.apply() - asyncio.run(test_main()) - """) - with subprocess.Popen( - [sys.executable, "-c", test_code], - text=True, - ) as process: - timeout = 10 # seconds - - start_time = time.monotonic() - while True: - return_code = process.poll() - if return_code is not None: - if return_code != 0: - raise AssertionError("calling get_platform using asyncify resulted in a non-zero exit code") - - # success - break - - if time.monotonic() - start_time > timeout: - process.kill() - raise AssertionError("calling get_platform using asyncify resulted in a hung process") - - time.sleep(0.1) + async def test_get_platform(self) -> None: + platform = await asyncify(get_platform)() + assert isinstance(platform, (str, OtherPlatform)) async def test_proxy_environment_variables(self, monkeypatch: pytest.MonkeyPatch) -> None: # Test that the proxy environment variables are set correctly @@ -1719,26 +1714,26 @@ async def test_default_client_creation(self) -> None: ) @pytest.mark.respx(base_url=base_url) - async def test_follow_redirects(self, respx_mock: MockRouter) -> None: + async def test_follow_redirects(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: # Test that the default follow_redirects=True allows following redirects respx_mock.post("/redirect").mock( return_value=httpx.Response(302, headers={"Location": f"{base_url}/redirected"}) ) respx_mock.get("/redirected").mock(return_value=httpx.Response(200, json={"status": "ok"})) - response = await self.client.post("/redirect", body={"key": "value"}, cast_to=httpx.Response) + response = await async_client.post("/redirect", body={"key": "value"}, cast_to=httpx.Response) assert response.status_code == 200 assert response.json() == {"status": "ok"} @pytest.mark.respx(base_url=base_url) - async def test_follow_redirects_disabled(self, respx_mock: MockRouter) -> None: + async def test_follow_redirects_disabled(self, respx_mock: MockRouter, async_client: AsyncZbdPayments) -> None: # Test that follow_redirects=False prevents following redirects respx_mock.post("/redirect").mock( return_value=httpx.Response(302, headers={"Location": f"{base_url}/redirected"}) ) with pytest.raises(APIStatusError) as exc_info: - await self.client.post( + await async_client.post( "/redirect", body={"key": "value"}, options={"follow_redirects": False}, cast_to=httpx.Response ) diff --git a/tests/test_models.py b/tests/test_models.py index 19ce47f..a295efd 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,5 +1,5 @@ import json -from typing import Any, Dict, List, Union, Optional, cast +from typing import TYPE_CHECKING, Any, Dict, List, Union, Optional, cast from datetime import datetime, timezone from typing_extensions import Literal, Annotated, TypeAliasType @@ -8,7 +8,7 @@ from pydantic import Field from zbdpay._utils import PropertyInfo -from zbdpay._compat import PYDANTIC_V2, parse_obj, model_dump, model_json +from zbdpay._compat import PYDANTIC_V1, parse_obj, model_dump, model_json from zbdpay._models import BaseModel, construct_type @@ -294,12 +294,12 @@ class Model(BaseModel): assert cast(bool, m.foo) is True m = Model.construct(foo={"name": 3}) - if PYDANTIC_V2: - assert isinstance(m.foo, Submodel1) - assert m.foo.name == 3 # type: ignore - else: + if PYDANTIC_V1: assert isinstance(m.foo, Submodel2) assert m.foo.name == "3" + else: + assert isinstance(m.foo, Submodel1) + assert m.foo.name == 3 # type: ignore def test_list_of_unions() -> None: @@ -426,10 +426,10 @@ class Model(BaseModel): expected = datetime(2019, 12, 27, 18, 11, 19, 117000, tzinfo=timezone.utc) - if PYDANTIC_V2: - expected_json = '{"created_at":"2019-12-27T18:11:19.117000Z"}' - else: + if PYDANTIC_V1: expected_json = '{"created_at": "2019-12-27T18:11:19.117000+00:00"}' + else: + expected_json = '{"created_at":"2019-12-27T18:11:19.117000Z"}' model = Model.construct(created_at="2019-12-27T18:11:19.117Z") assert model.created_at == expected @@ -531,7 +531,7 @@ class Model2(BaseModel): assert m4.to_dict(mode="python") == {"created_at": datetime.fromisoformat(time_str)} assert m4.to_dict(mode="json") == {"created_at": time_str} - if not PYDANTIC_V2: + if PYDANTIC_V1: with pytest.raises(ValueError, match="warnings is only supported in Pydantic v2"): m.to_dict(warnings=False) @@ -556,7 +556,7 @@ class Model(BaseModel): assert m3.model_dump() == {"foo": None} assert m3.model_dump(exclude_none=True) == {} - if not PYDANTIC_V2: + if PYDANTIC_V1: with pytest.raises(ValueError, match="round_trip is only supported in Pydantic v2"): m.model_dump(round_trip=True) @@ -580,10 +580,10 @@ class Model(BaseModel): assert json.loads(m.to_json()) == {"FOO": "hello"} assert json.loads(m.to_json(use_api_names=False)) == {"foo": "hello"} - if PYDANTIC_V2: - assert m.to_json(indent=None) == '{"FOO":"hello"}' - else: + if PYDANTIC_V1: assert m.to_json(indent=None) == '{"FOO": "hello"}' + else: + assert m.to_json(indent=None) == '{"FOO":"hello"}' m2 = Model() assert json.loads(m2.to_json()) == {} @@ -595,7 +595,7 @@ class Model(BaseModel): assert json.loads(m3.to_json()) == {"FOO": None} assert json.loads(m3.to_json(exclude_none=True)) == {} - if not PYDANTIC_V2: + if PYDANTIC_V1: with pytest.raises(ValueError, match="warnings is only supported in Pydantic v2"): m.to_json(warnings=False) @@ -622,7 +622,7 @@ class Model(BaseModel): assert json.loads(m3.model_dump_json()) == {"foo": None} assert json.loads(m3.model_dump_json(exclude_none=True)) == {} - if not PYDANTIC_V2: + if PYDANTIC_V1: with pytest.raises(ValueError, match="round_trip is only supported in Pydantic v2"): m.model_dump_json(round_trip=True) @@ -679,12 +679,12 @@ class B(BaseModel): ) assert isinstance(m, A) assert m.type == "a" - if PYDANTIC_V2: - assert m.data == 100 # type: ignore[comparison-overlap] - else: + if PYDANTIC_V1: # pydantic v1 automatically converts inputs to strings # if the expected type is a str assert m.data == "100" + else: + assert m.data == 100 # type: ignore[comparison-overlap] def test_discriminated_unions_unknown_variant() -> None: @@ -768,12 +768,12 @@ class B(BaseModel): ) assert isinstance(m, A) assert m.foo_type == "a" - if PYDANTIC_V2: - assert m.data == 100 # type: ignore[comparison-overlap] - else: + if PYDANTIC_V1: # pydantic v1 automatically converts inputs to strings # if the expected type is a str assert m.data == "100" + else: + assert m.data == 100 # type: ignore[comparison-overlap] def test_discriminated_unions_overlapping_discriminators_invalid_data() -> None: @@ -833,7 +833,7 @@ class B(BaseModel): assert UnionType.__discriminator__ is discriminator -@pytest.mark.skipif(not PYDANTIC_V2, reason="TypeAliasType is not supported in Pydantic v1") +@pytest.mark.skipif(PYDANTIC_V1, reason="TypeAliasType is not supported in Pydantic v1") def test_type_alias_type() -> None: Alias = TypeAliasType("Alias", str) # pyright: ignore @@ -849,7 +849,7 @@ class Model(BaseModel): assert m.union == "bar" -@pytest.mark.skipif(not PYDANTIC_V2, reason="TypeAliasType is not supported in Pydantic v1") +@pytest.mark.skipif(PYDANTIC_V1, reason="TypeAliasType is not supported in Pydantic v1") def test_field_named_cls() -> None: class Model(BaseModel): cls: str @@ -889,3 +889,75 @@ class ModelB(BaseModel): ) assert isinstance(m, ModelB) + + +def test_nested_discriminated_union() -> None: + class InnerType1(BaseModel): + type: Literal["type_1"] + + class InnerModel(BaseModel): + inner_value: str + + class InnerType2(BaseModel): + type: Literal["type_2"] + some_inner_model: InnerModel + + class Type1(BaseModel): + base_type: Literal["base_type_1"] + value: Annotated[ + Union[ + InnerType1, + InnerType2, + ], + PropertyInfo(discriminator="type"), + ] + + class Type2(BaseModel): + base_type: Literal["base_type_2"] + + T = Annotated[ + Union[ + Type1, + Type2, + ], + PropertyInfo(discriminator="base_type"), + ] + + model = construct_type( + type_=T, + value={ + "base_type": "base_type_1", + "value": { + "type": "type_2", + }, + }, + ) + assert isinstance(model, Type1) + assert isinstance(model.value, InnerType2) + + +@pytest.mark.skipif(PYDANTIC_V1, reason="this is only supported in pydantic v2 for now") +def test_extra_properties() -> None: + class Item(BaseModel): + prop: int + + class Model(BaseModel): + __pydantic_extra__: Dict[str, Item] = Field(init=False) # pyright: ignore[reportIncompatibleVariableOverride] + + other: str + + if TYPE_CHECKING: + + def __getattr__(self, attr: str) -> Item: ... + + model = construct_type( + type_=Model, + value={ + "a": {"prop": 1}, + "other": "foo", + }, + ) + assert isinstance(model, Model) + assert model.a.prop == 1 + assert isinstance(model.a, Item) + assert model.other == "foo" diff --git a/tests/test_transform.py b/tests/test_transform.py index 982d90f..fa44c68 100644 --- a/tests/test_transform.py +++ b/tests/test_transform.py @@ -8,14 +8,14 @@ import pytest -from zbdpay._types import NOT_GIVEN, Base64FileInput +from zbdpay._types import Base64FileInput, omit, not_given from zbdpay._utils import ( PropertyInfo, transform as _transform, parse_datetime, async_transform as _async_transform, ) -from zbdpay._compat import PYDANTIC_V2 +from zbdpay._compat import PYDANTIC_V1 from zbdpay._models import BaseModel _T = TypeVar("_T") @@ -189,7 +189,7 @@ class DateModel(BaseModel): @pytest.mark.asyncio async def test_iso8601_format(use_async: bool) -> None: dt = datetime.fromisoformat("2023-02-23T14:16:36.337692+00:00") - tz = "Z" if PYDANTIC_V2 else "+00:00" + tz = "+00:00" if PYDANTIC_V1 else "Z" assert await transform({"foo": dt}, DatetimeDict, use_async) == {"foo": "2023-02-23T14:16:36.337692+00:00"} # type: ignore[comparison-overlap] assert await transform(DatetimeModel(foo=dt), Any, use_async) == {"foo": "2023-02-23T14:16:36.337692" + tz} # type: ignore[comparison-overlap] @@ -297,11 +297,11 @@ async def test_pydantic_unknown_field(use_async: bool) -> None: @pytest.mark.asyncio async def test_pydantic_mismatched_types(use_async: bool) -> None: model = MyModel.construct(foo=True) - if PYDANTIC_V2: + if PYDANTIC_V1: + params = await transform(model, Any, use_async) + else: with pytest.warns(UserWarning): params = await transform(model, Any, use_async) - else: - params = await transform(model, Any, use_async) assert cast(Any, params) == {"foo": True} @@ -309,11 +309,11 @@ async def test_pydantic_mismatched_types(use_async: bool) -> None: @pytest.mark.asyncio async def test_pydantic_mismatched_object_type(use_async: bool) -> None: model = MyModel.construct(foo=MyModel.construct(hello="world")) - if PYDANTIC_V2: + if PYDANTIC_V1: + params = await transform(model, Any, use_async) + else: with pytest.warns(UserWarning): params = await transform(model, Any, use_async) - else: - params = await transform(model, Any, use_async) assert cast(Any, params) == {"foo": {"hello": "world"}} @@ -450,4 +450,11 @@ async def test_transform_skipping(use_async: bool) -> None: @pytest.mark.asyncio async def test_strips_notgiven(use_async: bool) -> None: assert await transform({"foo_bar": "bar"}, Foo1, use_async) == {"fooBar": "bar"} - assert await transform({"foo_bar": NOT_GIVEN}, Foo1, use_async) == {} + assert await transform({"foo_bar": not_given}, Foo1, use_async) == {} + + +@parametrize +@pytest.mark.asyncio +async def test_strips_omit(use_async: bool) -> None: + assert await transform({"foo_bar": "bar"}, Foo1, use_async) == {"fooBar": "bar"} + assert await transform({"foo_bar": omit}, Foo1, use_async) == {} diff --git a/tests/test_utils/test_datetime_parse.py b/tests/test_utils/test_datetime_parse.py new file mode 100644 index 0000000..e569bea --- /dev/null +++ b/tests/test_utils/test_datetime_parse.py @@ -0,0 +1,110 @@ +""" +Copied from https://github.com/pydantic/pydantic/blob/v1.10.22/tests/test_datetime_parse.py +with modifications so it works without pydantic v1 imports. +""" + +from typing import Type, Union +from datetime import date, datetime, timezone, timedelta + +import pytest + +from zbdpay._utils import parse_date, parse_datetime + + +def create_tz(minutes: int) -> timezone: + return timezone(timedelta(minutes=minutes)) + + +@pytest.mark.parametrize( + "value,result", + [ + # Valid inputs + ("1494012444.883309", date(2017, 5, 5)), + (b"1494012444.883309", date(2017, 5, 5)), + (1_494_012_444.883_309, date(2017, 5, 5)), + ("1494012444", date(2017, 5, 5)), + (1_494_012_444, date(2017, 5, 5)), + (0, date(1970, 1, 1)), + ("2012-04-23", date(2012, 4, 23)), + (b"2012-04-23", date(2012, 4, 23)), + ("2012-4-9", date(2012, 4, 9)), + (date(2012, 4, 9), date(2012, 4, 9)), + (datetime(2012, 4, 9, 12, 15), date(2012, 4, 9)), + # Invalid inputs + ("x20120423", ValueError), + ("2012-04-56", ValueError), + (19_999_999_999, date(2603, 10, 11)), # just before watershed + (20_000_000_001, date(1970, 8, 20)), # just after watershed + (1_549_316_052, date(2019, 2, 4)), # nowish in s + (1_549_316_052_104, date(2019, 2, 4)), # nowish in ms + (1_549_316_052_104_324, date(2019, 2, 4)), # nowish in μs + (1_549_316_052_104_324_096, date(2019, 2, 4)), # nowish in ns + ("infinity", date(9999, 12, 31)), + ("inf", date(9999, 12, 31)), + (float("inf"), date(9999, 12, 31)), + ("infinity ", date(9999, 12, 31)), + (int("1" + "0" * 100), date(9999, 12, 31)), + (1e1000, date(9999, 12, 31)), + ("-infinity", date(1, 1, 1)), + ("-inf", date(1, 1, 1)), + ("nan", ValueError), + ], +) +def test_date_parsing(value: Union[str, bytes, int, float], result: Union[date, Type[Exception]]) -> None: + if type(result) == type and issubclass(result, Exception): # pyright: ignore[reportUnnecessaryIsInstance] + with pytest.raises(result): + parse_date(value) + else: + assert parse_date(value) == result + + +@pytest.mark.parametrize( + "value,result", + [ + # Valid inputs + # values in seconds + ("1494012444.883309", datetime(2017, 5, 5, 19, 27, 24, 883_309, tzinfo=timezone.utc)), + (1_494_012_444.883_309, datetime(2017, 5, 5, 19, 27, 24, 883_309, tzinfo=timezone.utc)), + ("1494012444", datetime(2017, 5, 5, 19, 27, 24, tzinfo=timezone.utc)), + (b"1494012444", datetime(2017, 5, 5, 19, 27, 24, tzinfo=timezone.utc)), + (1_494_012_444, datetime(2017, 5, 5, 19, 27, 24, tzinfo=timezone.utc)), + # values in ms + ("1494012444000.883309", datetime(2017, 5, 5, 19, 27, 24, 883, tzinfo=timezone.utc)), + ("-1494012444000.883309", datetime(1922, 8, 29, 4, 32, 35, 999117, tzinfo=timezone.utc)), + (1_494_012_444_000, datetime(2017, 5, 5, 19, 27, 24, tzinfo=timezone.utc)), + ("2012-04-23T09:15:00", datetime(2012, 4, 23, 9, 15)), + ("2012-4-9 4:8:16", datetime(2012, 4, 9, 4, 8, 16)), + ("2012-04-23T09:15:00Z", datetime(2012, 4, 23, 9, 15, 0, 0, timezone.utc)), + ("2012-4-9 4:8:16-0320", datetime(2012, 4, 9, 4, 8, 16, 0, create_tz(-200))), + ("2012-04-23T10:20:30.400+02:30", datetime(2012, 4, 23, 10, 20, 30, 400_000, create_tz(150))), + ("2012-04-23T10:20:30.400+02", datetime(2012, 4, 23, 10, 20, 30, 400_000, create_tz(120))), + ("2012-04-23T10:20:30.400-02", datetime(2012, 4, 23, 10, 20, 30, 400_000, create_tz(-120))), + (b"2012-04-23T10:20:30.400-02", datetime(2012, 4, 23, 10, 20, 30, 400_000, create_tz(-120))), + (datetime(2017, 5, 5), datetime(2017, 5, 5)), + (0, datetime(1970, 1, 1, 0, 0, 0, tzinfo=timezone.utc)), + # Invalid inputs + ("x20120423091500", ValueError), + ("2012-04-56T09:15:90", ValueError), + ("2012-04-23T11:05:00-25:00", ValueError), + (19_999_999_999, datetime(2603, 10, 11, 11, 33, 19, tzinfo=timezone.utc)), # just before watershed + (20_000_000_001, datetime(1970, 8, 20, 11, 33, 20, 1000, tzinfo=timezone.utc)), # just after watershed + (1_549_316_052, datetime(2019, 2, 4, 21, 34, 12, 0, tzinfo=timezone.utc)), # nowish in s + (1_549_316_052_104, datetime(2019, 2, 4, 21, 34, 12, 104_000, tzinfo=timezone.utc)), # nowish in ms + (1_549_316_052_104_324, datetime(2019, 2, 4, 21, 34, 12, 104_324, tzinfo=timezone.utc)), # nowish in μs + (1_549_316_052_104_324_096, datetime(2019, 2, 4, 21, 34, 12, 104_324, tzinfo=timezone.utc)), # nowish in ns + ("infinity", datetime(9999, 12, 31, 23, 59, 59, 999999)), + ("inf", datetime(9999, 12, 31, 23, 59, 59, 999999)), + ("inf ", datetime(9999, 12, 31, 23, 59, 59, 999999)), + (1e50, datetime(9999, 12, 31, 23, 59, 59, 999999)), + (float("inf"), datetime(9999, 12, 31, 23, 59, 59, 999999)), + ("-infinity", datetime(1, 1, 1, 0, 0)), + ("-inf", datetime(1, 1, 1, 0, 0)), + ("nan", ValueError), + ], +) +def test_datetime_parsing(value: Union[str, bytes, int, float], result: Union[datetime, Type[Exception]]) -> None: + if type(result) == type and issubclass(result, Exception): # pyright: ignore[reportUnnecessaryIsInstance] + with pytest.raises(result): + parse_datetime(value) + else: + assert parse_datetime(value) == result diff --git a/tests/utils.py b/tests/utils.py index 72d57bb..7cd307e 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -4,7 +4,7 @@ import inspect import traceback import contextlib -from typing import Any, TypeVar, Iterator, cast +from typing import Any, TypeVar, Iterator, Sequence, cast from datetime import date, datetime from typing_extensions import Literal, get_args, get_origin, assert_type @@ -15,10 +15,11 @@ is_list_type, is_union_type, extract_type_arg, + is_sequence_type, is_annotated_type, is_type_alias_type, ) -from zbdpay._compat import PYDANTIC_V2, field_outer_type, get_model_fields +from zbdpay._compat import PYDANTIC_V1, field_outer_type, get_model_fields from zbdpay._models import BaseModel BaseModelT = TypeVar("BaseModelT", bound=BaseModel) @@ -27,12 +28,12 @@ def assert_matches_model(model: type[BaseModelT], value: BaseModelT, *, path: list[str]) -> bool: for name, field in get_model_fields(model).items(): field_value = getattr(value, name) - if PYDANTIC_V2: - allow_none = False - else: + if PYDANTIC_V1: # in v1 nullability was structured differently # https://docs.pydantic.dev/2.0/migration/#required-optional-and-nullable-fields allow_none = getattr(field, "allow_none", False) + else: + allow_none = False assert_matches_type( field_outer_type(field), @@ -71,6 +72,13 @@ def assert_matches_type( if is_list_type(type_): return _assert_list_type(type_, value) + if is_sequence_type(type_): + assert isinstance(value, Sequence) + inner_type = get_args(type_)[0] + for entry in value: # type: ignore + assert_type(inner_type, entry) # type: ignore + return + if origin == str: assert isinstance(value, str) elif origin == int: