diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..1f6abf0 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,39 @@ +name: Test + +on: + push: + pull_request: + branches: [main] + +jobs: + test-python: + strategy: + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup Poetry + uses: pronovic/setup-poetry@v1 + with: + version: "1.4.1" + cache-venv: "true" + cache-poetry: "true" + + - name: Install dependencies + run: | + poetry install --with dev + + - name: Run tests + run: | + source ./.venv/bin/activate + pytest diff --git a/README.md b/README.md index 717af69..929ec3d 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,6 @@ pip install bitbucket-python ## Usage -### Sync client - ```python from bitbucket.client import Client from bitbucket import AsyncClient @@ -24,6 +22,8 @@ async with AsyncClient('EMAIL', 'PASSWORD') as client: ``` +### Methods + Get user information ``` response = client.get_user() @@ -132,6 +132,21 @@ Delete webhook response = client.delete_webhook('REPOSITORY_SLUG', 'WEBHOOK_ID') ``` +### Helper methods + +### all_pages + +The `all_pages` method is a helper function that makes it easy to retrieve all items from an API methods that uses pagination (see https://developer.atlassian.com/cloud/bitbucket/rest/intro/#pagination). + +```python +client = Client() + +items = list(client.all_pages(client.get_repositories)) +``` + +Note that the `all_pages` method uses a generator to return the results. + + ## Requirements - requests diff --git a/bitbucket/aclient.py b/bitbucket/aclient.py index b57541c..835a90d 100644 --- a/bitbucket/aclient.py +++ b/bitbucket/aclient.py @@ -1,3 +1,4 @@ +import typing import httpx from .base import BaseClient @@ -21,11 +22,6 @@ class Client(BaseClient): ``` """ - def __init__(self, user, password, owner=None): - self.user = user - self.password = password - self.username = owner - async def __aenter__(self): self._session = httpx.AsyncClient( auth=( @@ -50,6 +46,52 @@ async def __aexit__( ) -> None: await self._session.aclose() + async def all_pages( + self, + method: typing.Callable[ + ..., + typing.Awaitable[typing.Union[typing.Dict[str, typing.Any], None]], + ], + *args, + **kwargs + ) -> typing.AsyncGenerator[typing.Dict[str, typing.Any], None]: + """ + Retrieves all pages from a BitBucket API list endpoint and yields a generator for the items in the + response. + + Example: + + ```python + async for item in client.all_pages( + client.get_issues, + "{726f1aab-826f-4c08-a127-1224347b3d09}" + ): + print(item["id"]) + ``` + + Args: + method: A client class method to retrieve all pages from. + *args: Variable length argument list to be passed to the `method` callable. + **kwargs: Arbitrary keyword arguments to be passed to the `method` callable. + + Returns: + An asynchronous generator that yields a dictionary of item data for each item in the response. + + Raises: + Any exceptions raised by the `method` callable. + """ + resp = await method(*args, **kwargs) + while True: + if resp is None: + break + + for v in resp["values"]: + yield v + + if "next" not in resp: + break + resp = await self._get(resp["next"]) + async def get_user(self, params=None): """ Retrieves information about the current user. @@ -100,7 +142,7 @@ async def create_repository(self, params=None, data=None, name=None, team=None): Creates a new repository. Example data: - ``` + ```json { "scm": "git", "project": { @@ -408,7 +450,10 @@ async def _get(self, endpoint, params=None): Returns: A dictionary containing the parsed response from the GET request. """ - response = await self._session.get(self.BASE_URL + endpoint, params=params) + response = await self._session.get( + endpoint if endpoint.startswith("http") else self.BASE_URL + endpoint, + params=params, + ) return self.parse(response) async def _post(self, endpoint, params=None, data=None): diff --git a/bitbucket/base.py b/bitbucket/base.py index 5df61ec..6b5b782 100644 --- a/bitbucket/base.py +++ b/bitbucket/base.py @@ -1,26 +1,59 @@ -from .exceptions import UnknownError, InvalidIDError, NotFoundIDError, NotAuthenticatedError, PermissionError +import typing + +from .exceptions import ( + InvalidIDError, + NotAuthenticatedError, + NotFoundIDError, + PermissionError, + UnknownError, +) + class BaseClient(object): - BASE_URL = 'https://api.bitbucket.org/' + BASE_URL = "https://api.bitbucket.org/" + + def __init__(self, user: str, password: str, owner: typing.Union[str, None] = None): + self.user = user + self.password = password + self.username = owner + + def parse(self, response) -> typing.Union[typing.Dict[str, typing.Any], None]: + """ + Parses the response from the BitBucket API and returns the response data or raises an exception if the response + indicates an error. + + Args: + response: The response object returned by the BitBucket API. + + Returns: + If the response status code is 200, 201, or 202, returns the JSON data in the response body as a dictionary. + If the response status code is 204, returns None. + Otherwise, raises an exception indicating the error message returned by the API. - def parse(self, response): + Raises: + InvalidIDError: If the response status code is 400. + NotAuthenticatedError: If the response status code is 401. + PermissionError: If the response status code is 403. + NotFoundIDError: If the response status code is 404. + UnknownError: If the response status code is not one of the above. + """ status_code = response.status_code - if 'application/json' in response.headers['Content-Type']: + if "application/json" in response.headers["Content-Type"]: r = response.json() else: r = response.text - if status_code in (200, 201): + if status_code in (200, 201, 202): return r if status_code == 204: return None message = None try: - if type(r) == str: + if type(r) == dict: + message = r["error"]["message"] + else: message = r - elif 'errorMessages' in r: - message = r['errorMessages'] except Exception: - message = 'No error message.' + message = response.text if status_code == 400: raise InvalidIDError(message) if status_code == 401: @@ -29,4 +62,4 @@ def parse(self, response): raise PermissionError(message) if status_code == 404: raise NotFoundIDError(message) - raise UnknownError(message) \ No newline at end of file + raise UnknownError(message) diff --git a/bitbucket/client.py b/bitbucket/client.py index 197a11b..de1c430 100644 --- a/bitbucket/client.py +++ b/bitbucket/client.py @@ -1,11 +1,10 @@ +import typing import requests from .base import BaseClient class Client(BaseClient): - - def __init__(self, user, password, owner=None): """Initial session with user/password, and setup repository owner @@ -15,16 +14,55 @@ def __init__(self, user, password, owner=None): Returns: """ + super().__init__(user, password, owner) + + # for shared repo, set baseURL to owner + if owner is None: + user_data = self.get_user() + owner = user_data.get("username") + self.workspace = owner + + def all_pages( + self, + method: typing.Callable[..., typing.Union[typing.Dict, None]], + *args, + **kwargs + ) -> typing.Generator[typing.Dict[str, typing.Any], None, None]: + """ + Retrieves all pages in the response from a BitBucket API list endpoint and yields a generator for the items in the + response. - self.user = user - self.password = password + Example: - user_data = self.get_user() + ```python + for item in client.all_pages( + client.get_issues, + "{726f1aab-826f-4c08-a127-1224347b3d09}" + ): + print(item["id"]) + ``` - # for shared repo, set baseURL to owner - if owner is None and user_data is not None: - owner = user_data.get('username') - self.username = owner + Args: + method: A client class method to retrieve all pages from. + *args: Variable length argument list to be passed to the `method` callable. + **kwargs: Arbitrary keyword arguments to be passed to the `method` callable. + + Returns: + A generator that yields a dictionary of item data for each item in the response. + + Raises: + Any exceptions raised by the `method` callable. + """ + resp = method(*args, **kwargs) + while True: + if resp is None: + break + + yield from resp["values"] + + if "next" not in resp: + break + resp = self._get(resp["next"]) def get_user(self, params=None): """Returns the currently logged in user. @@ -35,7 +73,7 @@ def get_user(self, params=None): Returns: """ - return self._get('2.0/user', params=params) + return self._get("2.0/user", params=params) def get_privileges(self, params=None): """Gets a list of all the privilege across all an account's repositories. @@ -50,7 +88,7 @@ def get_privileges(self, params=None): Returns: """ - return self._get('1.0/privileges/{}'.format(self.username), params=params) + return self._get("1.0/privileges/{}".format(self.workspace), params=params) def get_repositories(self, params=None): """Returns a paginated list of all repositories owned by the specified account or UUID. @@ -68,7 +106,7 @@ def get_repositories(self, params=None): Returns: """ - return self._get('2.0/repositories/{}'.format(self.username), params=params) + return self._get("2.0/repositories/{}".format(self.workspace), params=params) def get_repository(self, repository_slug, params=None): """Returns the object describing this repository. @@ -80,7 +118,10 @@ def get_repository(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}".format(self.workspace, repository_slug), + params=params, + ) def create_repository(self, params=None, data=None, name=None, team=None): """Creates a new repository. @@ -98,18 +139,27 @@ def create_repository(self, params=None, data=None, name=None, team=None): Args: data: params: - Name: + Name: team: Returns: Repository """ - return self._post('2.0/repositories/{}/{}'.format(team, name), params, data) + return self._post( + "2.0/repositories/{}/{}".format(team or self.workspace, name), params, data + ) - def get_repository_branches(self, repository_slug, params=None): - return self._get('2.0/repositories/{}/{}/refs/branches'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/refs/branches".format( + self.workspace, repository_slug + ), + params=params, + ) def get_repository_tags(self, repository_slug, params=None): - return self._get('2.0/repositories/{}/{}/refs/tags'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/refs/tags".format(self.workspace, repository_slug), + params=params, + ) def get_repository_commits(self, repository_slug, params=None): """Returns the commits from the repository. @@ -125,7 +175,10 @@ def get_repository_commits(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/commits'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/commits".format(self.workspace, repository_slug), + params=params, + ) def get_repository_components(self, repository_slug, params=None): """Returns the components that have been defined in the issue tracker. @@ -139,7 +192,10 @@ def get_repository_components(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/components'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/components".format(self.workspace, repository_slug), + params=params, + ) def get_repository_milestones(self, repository_slug, params=None): """Returns the milestones that have been defined in the issue tracker. @@ -153,7 +209,10 @@ def get_repository_milestones(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/milestones'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/milestones".format(self.workspace, repository_slug), + params=params, + ) def get_repository_versions(self, repository_slug, params=None): """Returns the versions that have been defined in the issue tracker. @@ -167,7 +226,10 @@ def get_repository_versions(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/versions'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/versions".format(self.workspace, repository_slug), + params=params, + ) def get_repository_source_code(self, repository_slug, params=None): """Returns data about the source code of given repository. @@ -179,9 +241,14 @@ def get_repository_source_code(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/src'.format(self.username, repository_slug), params=params) - - def get_repository_commit_path_source_code(self, repository_slug, commit_hash, path, params=None): + return self._get( + "2.0/repositories/{}/{}/src".format(self.workspace, repository_slug), + params=params, + ) + + def get_repository_commit_path_source_code( + self, repository_slug, commit_hash, path, params=None + ): """Returns source code of given path at specified commit_hash of given repository. Args: @@ -193,12 +260,12 @@ def get_repository_commit_path_source_code(self, repository_slug, commit_hash, p Returns: """ - return self._get('2.0/repositories/{}/{}/src/{}/{}'.format( - self.username, - repository_slug, - commit_hash, - path - ), params=params) + return self._get( + "2.0/repositories/{}/{}/src/{}/{}".format( + self.workspace, repository_slug, commit_hash, path + ), + params=params, + ) def create_issue(self, repository_slug, data, params=None): """Creates a new issue. @@ -216,8 +283,11 @@ def create_issue(self, repository_slug, data, params=None): Returns: """ - return self._post('2.0/repositories/{}/{}/issues'.format(self.username, repository_slug), data=data, - params=params) + return self._post( + "2.0/repositories/{}/{}/issues".format(self.workspace, repository_slug), + data=data, + params=params, + ) def get_issue(self, repository_slug, issue_id, params=None): """Returns the specified issue. @@ -230,8 +300,12 @@ def get_issue(self, repository_slug, issue_id, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/issues/{}'.format(self.username, repository_slug, issue_id), - params=params) + return self._get( + "2.0/repositories/{}/{}/issues/{}".format( + self.workspace, repository_slug, issue_id + ), + params=params, + ) def get_issues(self, repository_slug, params=None): """Returns the issues in the issue tracker. @@ -243,7 +317,10 @@ def get_issues(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/issues'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/issues".format(self.workspace, repository_slug), + params=params, + ) def delete_issue(self, repository_slug, issue_id, params=None): """Deletes the specified issue. This requires write access to the repository. @@ -256,8 +333,12 @@ def delete_issue(self, repository_slug, issue_id, params=None): Returns: """ - return self._delete('2.0/repositories/{}/{}/issues/{}'.format(self.username, repository_slug, issue_id), - params=params) + return self._delete( + "2.0/repositories/{}/{}/issues/{}".format( + self.workspace, repository_slug, issue_id + ), + params=params, + ) def create_webhook(self, repository_slug, data, params=None): """Creates a new webhook on the specified repository. @@ -286,8 +367,11 @@ def create_webhook(self, repository_slug, data, params=None): Returns: """ - return self._post('2.0/repositories/{}/{}/hooks'.format(self.username, repository_slug), data=data, - params=params) + return self._post( + "2.0/repositories/{}/{}/hooks".format(self.workspace, repository_slug), + data=data, + params=params, + ) def get_webhook(self, repository_slug, webhook_uid, params=None): """Returns the webhook with the specified id installed on the specified repository. @@ -300,8 +384,12 @@ def get_webhook(self, repository_slug, webhook_uid, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/hooks/{}'.format(self.username, repository_slug, webhook_uid), - params=params) + return self._get( + "2.0/repositories/{}/{}/hooks/{}".format( + self.workspace, repository_slug, webhook_uid + ), + params=params, + ) def get_webhooks(self, repository_slug, params=None): """Returns a paginated list of webhooks installed on this repository. @@ -313,7 +401,10 @@ def get_webhooks(self, repository_slug, params=None): Returns: """ - return self._get('2.0/repositories/{}/{}/hooks'.format(self.username, repository_slug), params=params) + return self._get( + "2.0/repositories/{}/{}/hooks".format(self.workspace, repository_slug), + params=params, + ) def delete_webhook(self, repository_slug, webhook_uid, params=None): """Deletes the specified webhook subscription from the given repository. @@ -326,22 +417,41 @@ def delete_webhook(self, repository_slug, webhook_uid, params=None): Returns: """ - return self._delete('2.0/repositories/{}/{}/hooks/{}'.format(self.username, repository_slug, webhook_uid), - params=params) - - def _get(self, endpoint, params=None): - response = requests.get(self.BASE_URL + endpoint, params=params, auth=(self.user, self.password)) + return self._delete( + "2.0/repositories/{}/{}/hooks/{}".format( + self.workspace, repository_slug, webhook_uid + ), + params=params, + ) + + def _get(self, endpoint: str, params=None): + response = requests.get( + endpoint if endpoint.startswith("http") else self.BASE_URL + endpoint, + params=params, + auth=(self.user, self.password), + ) return self.parse(response) def _post(self, endpoint, params=None, data=None): - response = requests.post(self.BASE_URL + endpoint, params=params, json=data, auth=(self.user, self.password)) + response = requests.post( + self.BASE_URL + endpoint, + params=params, + json=data, + auth=(self.user, self.password), + ) return self.parse(response) def _put(self, endpoint, params=None, data=None): - response = requests.put(self.BASE_URL + endpoint, params=params, json=data, auth=(self.user, self.password)) + response = requests.put( + self.BASE_URL + endpoint, + params=params, + json=data, + auth=(self.user, self.password), + ) return self.parse(response) def _delete(self, endpoint, params=None): - response = requests.delete(self.BASE_URL + endpoint, params=params, auth=(self.user, self.password)) + response = requests.delete( + self.BASE_URL + endpoint, params=params, auth=(self.user, self.password) + ) return self.parse(response) - diff --git a/poetry.lock b/poetry.lock new file mode 100644 index 0000000..720968d --- /dev/null +++ b/poetry.lock @@ -0,0 +1,462 @@ +# This file is automatically @generated by Poetry 1.4.1 and should not be changed by hand. + +[[package]] +name = "anyio" +version = "3.6.2" +description = "High level compatibility layer for multiple asynchronous event loop implementations" +category = "main" +optional = false +python-versions = ">=3.6.2" +files = [ + {file = "anyio-3.6.2-py3-none-any.whl", hash = "sha256:fbbe32bd270d2a2ef3ed1c5d45041250284e31fc0a4df4a5a6071842051a51e3"}, + {file = "anyio-3.6.2.tar.gz", hash = "sha256:25ea0d673ae30af41a0c442f81cf3b38c7e79fdc7b60335a4c14e05eb0947421"}, +] + +[package.dependencies] +idna = ">=2.8" +sniffio = ">=1.1" +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} + +[package.extras] +doc = ["packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphinx-rtd-theme"] +test = ["contextlib2", "coverage[toml] (>=4.5)", "hypothesis (>=4.0)", "mock (>=4)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (<0.15)", "uvloop (>=0.15)"] +trio = ["trio (>=0.16,<0.22)"] + +[[package]] +name = "attrs" +version = "22.2.0" +description = "Classes Without Boilerplate" +category = "dev" +optional = false +python-versions = ">=3.6" +files = [ + {file = "attrs-22.2.0-py3-none-any.whl", hash = "sha256:29e95c7f6778868dbd49170f98f8818f78f3dc5e0e37c0b1f474e3561b240836"}, + {file = "attrs-22.2.0.tar.gz", hash = "sha256:c9227bfc2f01993c03f68db37d1d15c9690188323c067c641f1a35ca58185f99"}, +] + +[package.extras] +cov = ["attrs[tests]", "coverage-enable-subprocess", "coverage[toml] (>=5.3)"] +dev = ["attrs[docs,tests]"] +docs = ["furo", "myst-parser", "sphinx", "sphinx-notfound-page", "sphinxcontrib-towncrier", "towncrier", "zope.interface"] +tests = ["attrs[tests-no-zope]", "zope.interface"] +tests-no-zope = ["cloudpickle", "cloudpickle", "hypothesis", "hypothesis", "mypy (>=0.971,<0.990)", "mypy (>=0.971,<0.990)", "pympler", "pympler", "pytest (>=4.3.0)", "pytest (>=4.3.0)", "pytest-mypy-plugins", "pytest-mypy-plugins", "pytest-xdist[psutil]", "pytest-xdist[psutil]"] + +[[package]] +name = "certifi" +version = "2022.12.7" +description = "Python package for providing Mozilla's CA Bundle." +category = "main" +optional = false +python-versions = ">=3.6" +files = [ + {file = "certifi-2022.12.7-py3-none-any.whl", hash = "sha256:4ad3232f5e926d6718ec31cfc1fcadfde020920e278684144551c91769c7bc18"}, + {file = "certifi-2022.12.7.tar.gz", hash = "sha256:35824b4c3a97115964b408844d64aa14db1cc518f6562e8d7261699d1350a9e3"}, +] + +[[package]] +name = "charset-normalizer" +version = "3.1.0" +description = "The Real First Universal Charset Detector. Open, modern and actively maintained alternative to Chardet." +category = "main" +optional = false +python-versions = ">=3.7.0" +files = [ + {file = "charset-normalizer-3.1.0.tar.gz", hash = "sha256:34e0a2f9c370eb95597aae63bf85eb5e96826d81e3dcf88b8886012906f509b5"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:e0ac8959c929593fee38da1c2b64ee9778733cdf03c482c9ff1d508b6b593b2b"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:d7fc3fca01da18fbabe4625d64bb612b533533ed10045a2ac3dd194bfa656b60"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:04eefcee095f58eaabe6dc3cc2262f3bcd776d2c67005880894f447b3f2cb9c1"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:20064ead0717cf9a73a6d1e779b23d149b53daf971169289ed2ed43a71e8d3b0"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:1435ae15108b1cb6fffbcea2af3d468683b7afed0169ad718451f8db5d1aff6f"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c84132a54c750fda57729d1e2599bb598f5fa0344085dbde5003ba429a4798c0"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:75f2568b4189dda1c567339b48cba4ac7384accb9c2a7ed655cd86b04055c795"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:11d3bcb7be35e7b1bba2c23beedac81ee893ac9871d0ba79effc7fc01167db6c"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:891cf9b48776b5c61c700b55a598621fdb7b1e301a550365571e9624f270c203"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_i686.whl", hash = "sha256:5f008525e02908b20e04707a4f704cd286d94718f48bb33edddc7d7b584dddc1"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_ppc64le.whl", hash = "sha256:b06f0d3bf045158d2fb8837c5785fe9ff9b8c93358be64461a1089f5da983137"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_s390x.whl", hash = "sha256:49919f8400b5e49e961f320c735388ee686a62327e773fa5b3ce6721f7e785ce"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:22908891a380d50738e1f978667536f6c6b526a2064156203d418f4856d6e86a"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-win32.whl", hash = "sha256:12d1a39aa6b8c6f6248bb54550efcc1c38ce0d8096a146638fd4738e42284448"}, + {file = "charset_normalizer-3.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:65ed923f84a6844de5fd29726b888e58c62820e0769b76565480e1fdc3d062f8"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_universal2.whl", hash = "sha256:9a3267620866c9d17b959a84dd0bd2d45719b817245e49371ead79ed4f710d19"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:6734e606355834f13445b6adc38b53c0fd45f1a56a9ba06c2058f86893ae8017"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:f8303414c7b03f794347ad062c0516cee0e15f7a612abd0ce1e25caf6ceb47df"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:aaf53a6cebad0eae578f062c7d462155eada9c172bd8c4d250b8c1d8eb7f916a"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3dc5b6a8ecfdc5748a7e429782598e4f17ef378e3e272eeb1340ea57c9109f41"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e1b25e3ad6c909f398df8921780d6a3d120d8c09466720226fc621605b6f92b1"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:0ca564606d2caafb0abe6d1b5311c2649e8071eb241b2d64e75a0d0065107e62"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b82fab78e0b1329e183a65260581de4375f619167478dddab510c6c6fb04d9b6"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:bd7163182133c0c7701b25e604cf1611c0d87712e56e88e7ee5d72deab3e76b5"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_i686.whl", hash = "sha256:11d117e6c63e8f495412d37e7dc2e2fff09c34b2d09dbe2bee3c6229577818be"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_ppc64le.whl", hash = "sha256:cf6511efa4801b9b38dc5546d7547d5b5c6ef4b081c60b23e4d941d0eba9cbeb"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_s390x.whl", hash = "sha256:abc1185d79f47c0a7aaf7e2412a0eb2c03b724581139193d2d82b3ad8cbb00ac"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:cb7b2ab0188829593b9de646545175547a70d9a6e2b63bf2cd87a0a391599324"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-win32.whl", hash = "sha256:c36bcbc0d5174a80d6cccf43a0ecaca44e81d25be4b7f90f0ed7bcfbb5a00909"}, + {file = "charset_normalizer-3.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:cca4def576f47a09a943666b8f829606bcb17e2bc2d5911a46c8f8da45f56755"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:0c95f12b74681e9ae127728f7e5409cbbef9cd914d5896ef238cc779b8152373"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:fca62a8301b605b954ad2e9c3666f9d97f63872aa4efcae5492baca2056b74ab"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:ac0aa6cd53ab9a31d397f8303f92c42f534693528fafbdb997c82bae6e477ad9"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:c3af8e0f07399d3176b179f2e2634c3ce9c1301379a6b8c9c9aeecd481da494f"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:3a5fc78f9e3f501a1614a98f7c54d3969f3ad9bba8ba3d9b438c3bc5d047dd28"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:628c985afb2c7d27a4800bfb609e03985aaecb42f955049957814e0491d4006d"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_aarch64.whl", hash = "sha256:74db0052d985cf37fa111828d0dd230776ac99c740e1a758ad99094be4f1803d"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_i686.whl", hash = "sha256:1e8fcdd8f672a1c4fc8d0bd3a2b576b152d2a349782d1eb0f6b8e52e9954731d"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_ppc64le.whl", hash = "sha256:04afa6387e2b282cf78ff3dbce20f0cc071c12dc8f685bd40960cc68644cfea6"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_s390x.whl", hash = "sha256:dd5653e67b149503c68c4018bf07e42eeed6b4e956b24c00ccdf93ac79cdff84"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-musllinux_1_1_x86_64.whl", hash = "sha256:d2686f91611f9e17f4548dbf050e75b079bbc2a82be565832bc8ea9047b61c8c"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-win32.whl", hash = "sha256:4155b51ae05ed47199dc5b2a4e62abccb274cee6b01da5b895099b61b1982974"}, + {file = "charset_normalizer-3.1.0-cp37-cp37m-win_amd64.whl", hash = "sha256:322102cdf1ab682ecc7d9b1c5eed4ec59657a65e1c146a0da342b78f4112db23"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_universal2.whl", hash = "sha256:e633940f28c1e913615fd624fcdd72fdba807bf53ea6925d6a588e84e1151531"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:3a06f32c9634a8705f4ca9946d667609f52cf130d5548881401f1eb2c39b1e2c"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7381c66e0561c5757ffe616af869b916c8b4e42b367ab29fedc98481d1e74e14"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3573d376454d956553c356df45bb824262c397c6e26ce43e8203c4c540ee0acb"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:e89df2958e5159b811af9ff0f92614dabf4ff617c03a4c1c6ff53bf1c399e0e1"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:78cacd03e79d009d95635e7d6ff12c21eb89b894c354bd2b2ed0b4763373693b"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:de5695a6f1d8340b12a5d6d4484290ee74d61e467c39ff03b39e30df62cf83a0"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:1c60b9c202d00052183c9be85e5eaf18a4ada0a47d188a83c8f5c5b23252f649"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:f645caaf0008bacf349875a974220f1f1da349c5dbe7c4ec93048cdc785a3326"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_i686.whl", hash = "sha256:ea9f9c6034ea2d93d9147818f17c2a0860d41b71c38b9ce4d55f21b6f9165a11"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_ppc64le.whl", hash = "sha256:80d1543d58bd3d6c271b66abf454d437a438dff01c3e62fdbcd68f2a11310d4b"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_s390x.whl", hash = "sha256:73dc03a6a7e30b7edc5b01b601e53e7fc924b04e1835e8e407c12c037e81adbd"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:6f5c2e7bc8a4bf7c426599765b1bd33217ec84023033672c1e9a8b35eaeaaaf8"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-win32.whl", hash = "sha256:12a2b561af122e3d94cdb97fe6fb2bb2b82cef0cdca131646fdb940a1eda04f0"}, + {file = "charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:3160a0fd9754aab7d47f95a6b63ab355388d890163eb03b2d2b87ab0a30cfa59"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_universal2.whl", hash = "sha256:38e812a197bf8e71a59fe55b757a84c1f946d0ac114acafaafaf21667a7e169e"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:6baf0baf0d5d265fa7944feb9f7451cc316bfe30e8df1a61b1bb08577c554f31"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8f25e17ab3039b05f762b0a55ae0b3632b2e073d9c8fc88e89aca31a6198e88f"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3747443b6a904001473370d7810aa19c3a180ccd52a7157aacc264a5ac79265e"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:b116502087ce8a6b7a5f1814568ccbd0e9f6cfd99948aa59b0e241dc57cf739f"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:d16fd5252f883eb074ca55cb622bc0bee49b979ae4e8639fff6ca3ff44f9f854"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21fa558996782fc226b529fdd2ed7866c2c6ec91cee82735c98a197fae39f706"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:6f6c7a8a57e9405cad7485f4c9d3172ae486cfef1344b5ddd8e5239582d7355e"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:ac3775e3311661d4adace3697a52ac0bab17edd166087d493b52d4f4f553f9f0"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_i686.whl", hash = "sha256:10c93628d7497c81686e8e5e557aafa78f230cd9e77dd0c40032ef90c18f2230"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_ppc64le.whl", hash = "sha256:6f4f4668e1831850ebcc2fd0b1cd11721947b6dc7c00bf1c6bd3c929ae14f2c7"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_s390x.whl", hash = "sha256:0be65ccf618c1e7ac9b849c315cc2e8a8751d9cfdaa43027d4f6624bd587ab7e"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:53d0a3fa5f8af98a1e261de6a3943ca631c526635eb5817a87a59d9a57ebf48f"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-win32.whl", hash = "sha256:a04f86f41a8916fe45ac5024ec477f41f886b3c435da2d4e3d2709b22ab02af1"}, + {file = "charset_normalizer-3.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:830d2948a5ec37c386d3170c483063798d7879037492540f10a475e3fd6f244b"}, + {file = "charset_normalizer-3.1.0-py3-none-any.whl", hash = "sha256:3d9098b479e78c85080c98e1e35ff40b4a31d8953102bb0fd7d1b6f8a2111a3d"}, +] + +[[package]] +name = "colorama" +version = "0.4.6" +description = "Cross-platform colored terminal text." +category = "dev" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" +files = [ + {file = "colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6"}, + {file = "colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"}, +] + +[[package]] +name = "exceptiongroup" +version = "1.1.1" +description = "Backport of PEP 654 (exception groups)" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "exceptiongroup-1.1.1-py3-none-any.whl", hash = "sha256:232c37c63e4f682982c8b6459f33a8981039e5fb8756b2074364e5055c498c9e"}, + {file = "exceptiongroup-1.1.1.tar.gz", hash = "sha256:d484c3090ba2889ae2928419117447a14daf3c1231d5e30d0aae34f354f01785"}, +] + +[package.extras] +test = ["pytest (>=6)"] + +[[package]] +name = "h11" +version = "0.14.0" +description = "A pure-Python, bring-your-own-I/O implementation of HTTP/1.1" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "h11-0.14.0-py3-none-any.whl", hash = "sha256:e3fe4ac4b851c468cc8363d500db52c2ead036020723024a109d37346efaa761"}, + {file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"}, +] + +[package.dependencies] +typing-extensions = {version = "*", markers = "python_version < \"3.8\""} + +[[package]] +name = "httpcore" +version = "0.16.3" +description = "A minimal low-level HTTP client." +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "httpcore-0.16.3-py3-none-any.whl", hash = "sha256:da1fb708784a938aa084bde4feb8317056c55037247c787bd7e19eb2c2949dc0"}, + {file = "httpcore-0.16.3.tar.gz", hash = "sha256:c5d6f04e2fc530f39e0c077e6a30caa53f1451096120f1f38b954afd0b17c0cb"}, +] + +[package.dependencies] +anyio = ">=3.0,<5.0" +certifi = "*" +h11 = ">=0.13,<0.15" +sniffio = ">=1.0.0,<2.0.0" + +[package.extras] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (>=1.0.0,<2.0.0)"] + +[[package]] +name = "httpx" +version = "0.23.3" +description = "The next generation HTTP client." +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "httpx-0.23.3-py3-none-any.whl", hash = "sha256:a211fcce9b1254ea24f0cd6af9869b3d29aba40154e947d2a07bb499b3e310d6"}, + {file = "httpx-0.23.3.tar.gz", hash = "sha256:9818458eb565bb54898ccb9b8b251a28785dd4a55afbc23d0eb410754fe7d0f9"}, +] + +[package.dependencies] +certifi = "*" +httpcore = ">=0.15.0,<0.17.0" +rfc3986 = {version = ">=1.3,<2", extras = ["idna2008"]} +sniffio = "*" + +[package.extras] +brotli = ["brotli", "brotlicffi"] +cli = ["click (>=8.0.0,<9.0.0)", "pygments (>=2.0.0,<3.0.0)", "rich (>=10,<13)"] +http2 = ["h2 (>=3,<5)"] +socks = ["socksio (>=1.0.0,<2.0.0)"] + +[[package]] +name = "idna" +version = "3.4" +description = "Internationalized Domain Names in Applications (IDNA)" +category = "main" +optional = false +python-versions = ">=3.5" +files = [ + {file = "idna-3.4-py3-none-any.whl", hash = "sha256:90b77e79eaa3eba6de819a0c442c0b4ceefc341a7a2ab77d7562bf49f425c5c2"}, + {file = "idna-3.4.tar.gz", hash = "sha256:814f528e8dead7d329833b91c5faa87d60bf71824cd12a7530b5526063d02cb4"}, +] + +[[package]] +name = "importlib-metadata" +version = "6.1.0" +description = "Read metadata from Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "importlib_metadata-6.1.0-py3-none-any.whl", hash = "sha256:ff80f3b5394912eb1b108fcfd444dc78b7f1f3e16b16188054bd01cb9cb86f09"}, + {file = "importlib_metadata-6.1.0.tar.gz", hash = "sha256:43ce9281e097583d758c2c708c4376371261a02c34682491a8e98352365aad20"}, +] + +[package.dependencies] +typing-extensions = {version = ">=3.6.4", markers = "python_version < \"3.8\""} +zipp = ">=0.5" + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +perf = ["ipython"] +testing = ["flake8 (<5)", "flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf (>=0.9.2)"] + +[[package]] +name = "iniconfig" +version = "2.0.0" +description = "brain-dead simple config-ini parsing" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "iniconfig-2.0.0-py3-none-any.whl", hash = "sha256:b6a85871a79d2e3b22d2d1b94ac2824226a63c6b741c88f7ae975f18b6778374"}, + {file = "iniconfig-2.0.0.tar.gz", hash = "sha256:2d91e135bf72d31a410b17c16da610a82cb55f6b0477d1a902134b24a455b8b3"}, +] + +[[package]] +name = "packaging" +version = "23.0" +description = "Core utilities for Python packages" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "packaging-23.0-py3-none-any.whl", hash = "sha256:714ac14496c3e68c99c29b00845f7a2b85f3bb6f1078fd9f72fd20f0570002b2"}, + {file = "packaging-23.0.tar.gz", hash = "sha256:b6ad297f8907de0fa2fe1ccbd26fdaf387f5f47c7275fedf8cce89f99446cf97"}, +] + +[[package]] +name = "pluggy" +version = "1.0.0" +description = "plugin and hook calling mechanisms for python" +category = "dev" +optional = false +python-versions = ">=3.6" +files = [ + {file = "pluggy-1.0.0-py2.py3-none-any.whl", hash = "sha256:74134bbf457f031a36d68416e1509f34bd5ccc019f0bcc952c7b909d06b37bd3"}, + {file = "pluggy-1.0.0.tar.gz", hash = "sha256:4224373bacce55f955a878bf9cfa763c1e360858e330072059e10bad68531159"}, +] + +[package.dependencies] +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} + +[package.extras] +dev = ["pre-commit", "tox"] +testing = ["pytest", "pytest-benchmark"] + +[[package]] +name = "pytest" +version = "7.2.2" +description = "pytest: simple powerful testing with Python" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-7.2.2-py3-none-any.whl", hash = "sha256:130328f552dcfac0b1cec75c12e3f005619dc5f874f0a06e8ff7263f0ee6225e"}, + {file = "pytest-7.2.2.tar.gz", hash = "sha256:c99ab0c73aceb050f68929bc93af19ab6db0558791c6a0715723abe9d0ade9d4"}, +] + +[package.dependencies] +attrs = ">=19.2.0" +colorama = {version = "*", markers = "sys_platform == \"win32\""} +exceptiongroup = {version = ">=1.0.0rc8", markers = "python_version < \"3.11\""} +importlib-metadata = {version = ">=0.12", markers = "python_version < \"3.8\""} +iniconfig = "*" +packaging = "*" +pluggy = ">=0.12,<2.0" +tomli = {version = ">=1.0.0", markers = "python_version < \"3.11\""} + +[package.extras] +testing = ["argcomplete", "hypothesis (>=3.56)", "mock", "nose", "pygments (>=2.7.2)", "requests", "xmlschema"] + +[[package]] +name = "pytest-asyncio" +version = "0.21.0" +description = "Pytest support for asyncio" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "pytest-asyncio-0.21.0.tar.gz", hash = "sha256:2b38a496aef56f56b0e87557ec313e11e1ab9276fc3863f6a7be0f1d0e415e1b"}, + {file = "pytest_asyncio-0.21.0-py3-none-any.whl", hash = "sha256:f2b3366b7cd501a4056858bd39349d5af19742aed2d81660b7998b6341c7eb9c"}, +] + +[package.dependencies] +pytest = ">=7.0.0" +typing-extensions = {version = ">=3.7.2", markers = "python_version < \"3.8\""} + +[package.extras] +docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"] +testing = ["coverage (>=6.2)", "flaky (>=3.5.0)", "hypothesis (>=5.7.1)", "mypy (>=0.931)", "pytest-trio (>=0.7.0)"] + +[[package]] +name = "requests" +version = "2.28.2" +description = "Python HTTP for Humans." +category = "main" +optional = false +python-versions = ">=3.7, <4" +files = [ + {file = "requests-2.28.2-py3-none-any.whl", hash = "sha256:64299f4909223da747622c030b781c0d7811e359c37124b4bd368fb8c6518baa"}, + {file = "requests-2.28.2.tar.gz", hash = "sha256:98b1b2782e3c6c4904938b84c0eb932721069dfdb9134313beff7c83c2df24bf"}, +] + +[package.dependencies] +certifi = ">=2017.4.17" +charset-normalizer = ">=2,<4" +idna = ">=2.5,<4" +urllib3 = ">=1.21.1,<1.27" + +[package.extras] +socks = ["PySocks (>=1.5.6,!=1.5.7)"] +use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] + +[[package]] +name = "rfc3986" +version = "1.5.0" +description = "Validating URI References per RFC 3986" +category = "main" +optional = false +python-versions = "*" +files = [ + {file = "rfc3986-1.5.0-py2.py3-none-any.whl", hash = "sha256:a86d6e1f5b1dc238b218b012df0aa79409667bb209e58da56d0b94704e712a97"}, + {file = "rfc3986-1.5.0.tar.gz", hash = "sha256:270aaf10d87d0d4e095063c65bf3ddbc6ee3d0b226328ce21e036f946e421835"}, +] + +[package.dependencies] +idna = {version = "*", optional = true, markers = "extra == \"idna2008\""} + +[package.extras] +idna2008 = ["idna"] + +[[package]] +name = "sniffio" +version = "1.3.0" +description = "Sniff out which async library your code is running under" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "sniffio-1.3.0-py3-none-any.whl", hash = "sha256:eecefdce1e5bbfb7ad2eeaabf7c1eeb404d7757c379bd1f7e5cce9d8bf425384"}, + {file = "sniffio-1.3.0.tar.gz", hash = "sha256:e60305c5e5d314f5389259b7f22aaa33d8f7dee49763119234af3755c55b9101"}, +] + +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + +[[package]] +name = "typing-extensions" +version = "4.5.0" +description = "Backported and Experimental Type Hints for Python 3.7+" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "typing_extensions-4.5.0-py3-none-any.whl", hash = "sha256:fb33085c39dd998ac16d1431ebc293a8b3eedd00fd4a32de0ff79002c19511b4"}, + {file = "typing_extensions-4.5.0.tar.gz", hash = "sha256:5cb5f4a79139d699607b3ef622a1dedafa84e115ab0024e0d9c044a9479ca7cb"}, +] + +[[package]] +name = "urllib3" +version = "1.26.15" +description = "HTTP library with thread-safe connection pooling, file post, and more." +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" +files = [ + {file = "urllib3-1.26.15-py2.py3-none-any.whl", hash = "sha256:aa751d169e23c7479ce47a0cb0da579e3ede798f994f5816a74e4f4500dcea42"}, + {file = "urllib3-1.26.15.tar.gz", hash = "sha256:8a388717b9476f934a21484e8c8e61875ab60644d29b9b39e11e4b9dc1c6b305"}, +] + +[package.extras] +brotli = ["brotli (>=1.0.9)", "brotlicffi (>=0.8.0)", "brotlipy (>=0.6.0)"] +secure = ["certifi", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "ipaddress", "pyOpenSSL (>=0.14)", "urllib3-secure-extra"] +socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] + +[[package]] +name = "zipp" +version = "3.15.0" +description = "Backport of pathlib-compatible object wrapper for zip files" +category = "dev" +optional = false +python-versions = ">=3.7" +files = [ + {file = "zipp-3.15.0-py3-none-any.whl", hash = "sha256:48904fc76a60e542af151aded95726c1a5c34ed43ab4134b597665c86d7ad556"}, + {file = "zipp-3.15.0.tar.gz", hash = "sha256:112929ad649da941c23de50f356a2b5570c954b65150642bccdd66bf194d224b"}, +] + +[package.extras] +docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] +testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more-itertools", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)"] + +[metadata] +lock-version = "2.0" +python-versions = "^3.7" +content-hash = "134a8a74d7806b6d52ef0553220996a2f96b0511bb9f0c4990c351ab438f7117" diff --git a/pyproject.toml b/pyproject.toml index 65c2c69..d3d6ee2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bitbucket-python" -version = "0.3.0" +version = "0.3.1" description = "API wrapper for Bitbucket written in Python" authors = ["Miguel Ferrer "] license = "MIT" @@ -13,6 +13,10 @@ requests = "^2.26.0" httpx = "^0.23.0" +[tool.poetry.group.dev.dependencies] +pytest = "^7.2.2" +pytest-asyncio = "^0.21.0" + [build-system] requires = ["poetry-core"] build-backend = "poetry.core.masonry.api" diff --git a/tests/test_aclient.py b/tests/test_aclient.py new file mode 100644 index 0000000..0e1f968 --- /dev/null +++ b/tests/test_aclient.py @@ -0,0 +1,54 @@ +from unittest.mock import MagicMock, call +import pytest + +from bitbucket import AsyncClient + + +class AsyncMock(MagicMock): + async def __call__(self, *args, **kwargs): + return super(AsyncMock, self).__call__(*args, **kwargs) + + +class TestAsyncClient: + @pytest.fixture + def client(self): + return AsyncClient("", "", "") + + @pytest.mark.asyncio + async def test_no_pages(self, client): + async def method(params): + return None + + result = [x async for x in client.all_pages(method, {})] + assert result == [] + + @pytest.mark.asyncio + async def test_single_page(self, client): + async def method(params): + return {"values": [{"id": 1}, {"id": 2}, {"id": 3}]} + + result = [x async for x in client.all_pages(method, {})] + assert result == [{"id": 1}, {"id": 2}, {"id": 3}] + + @pytest.mark.asyncio + async def test_multiple_pages(self, client): + async def method(params): + return {"values": [{"id": 1}, {"id": 2}], "next": "/api?page=2"} + + get_mock = AsyncMock( + side_effect=[ + {"values": [{"id": 3}, {"id": 4}], "next": "/api?page=3"}, + {"values": [{"id": 5}, {"id": 6}]}, + ] + ) + client._get = get_mock + result = [x async for x in client.all_pages(method, {})] + expected = [{"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}, {"id": 6}] + assert result == expected + assert get_mock.call_count == 2 + assert get_mock.call_args_list[0] == call( + "/api?page=2", + ) + assert get_mock.call_args_list[1] == call( + "/api?page=3", + ) diff --git a/tests/test_base.py b/tests/test_base.py new file mode 100644 index 0000000..254122c --- /dev/null +++ b/tests/test_base.py @@ -0,0 +1,99 @@ +from unittest.mock import Mock + +import pytest + +from bitbucket.base import BaseClient +from bitbucket.exceptions import ( + InvalidIDError, + NotAuthenticatedError, + NotFoundIDError, + PermissionError, + UnknownError, +) + + +class TestBaseClient: + @pytest.fixture + def client(self): + return BaseClient("", "") + + def test_parse_returns_dict_when_status_code_200(self, client): + # Arrange + response = Mock(status_code=200, headers={"Content-Type": "application/json"}) + response.json.return_value = {"key": "value"} + + # Act + result = client.parse(response) + + # Assert + assert result == {"key": "value"} + + def test_parse_returns_none_when_status_code_204(self, client): + # Arrange + response = Mock(status_code=204, headers={"Content-Type": "application/json"}) + + # Act + result = client.parse(response) + + # Assert + assert result is None + + def test_parse_raises_InvalidIDError_when_status_code_400(self, client): + # Arrange + response = Mock(status_code=400, headers={"Content-Type": "application/json"}) + response.json.return_value = {"error": {"message": "Invalid ID"}} + + # Act/Assert + with pytest.raises(InvalidIDError, match="Invalid ID"): + client.parse(response) + + def test_parse_raises_NotAuthenticatedError_when_status_code_401(self, client): + # Arrange + response = Mock( + status_code=401, + headers={"Content-Type": "application/json"}, + ) + response.json.return_value = {"error": {"message": "Not authenticated"}} + + # Act/Assert + with pytest.raises(NotAuthenticatedError, match="Not authenticated"): + client.parse(response) + + def test_parse_raises_NotFoundIDError_when_status_code_404(self, client): + # Arrange + response = Mock( + status_code=404, + headers={"Content-Type": "application/json"}, + ) + response.json.return_value = {"error": {"message": "ID not found"}} + + # Act/Assert + with pytest.raises(NotFoundIDError, match="ID not found"): + client.parse(response) + + def test_parse_raises_PermissionError_when_status_code_403(self, client): + # Arrange + response = Mock( + status_code=403, + headers={"Content-Type": "application/json"}, + ) + response.json.return_value = {"error": {"message": "Permission denied"}} + + # Act/Assert + with pytest.raises(PermissionError, match="Permission denied"): + client.parse(response) + + def test_parse_raises_UnknownError_when_status_code_is_not_handled(self, client): + # Arrange + response = Mock( + status_code=500, + headers={"Content-Type": "application/json"}, + ) + response.json.return_value = {"error": {"message": "Unknown error"}} + + # Act/Assert + with pytest.raises(UnknownError, match="Unknown error"): + client.parse(response) + + +# Add more test cases for other status codes and scenarios diff --git a/tests/test_client.py b/tests/test_client.py new file mode 100644 index 0000000..6b8d7ad --- /dev/null +++ b/tests/test_client.py @@ -0,0 +1,42 @@ +from unittest.mock import MagicMock, Mock, call, patch +import pytest + +from bitbucket.client import Client + + +class TestClient: + @pytest.fixture + def client(self): + return Client("", "", "") + + def test_no_pages(self, client): + method = lambda: None + result = list(client.all_pages(method)) + assert result == [] + + def test_single_page(self, client): + method = lambda: {"values": [{"id": 1}, {"id": 2}, {"id": 3}]} + result = list(client.all_pages(method)) + assert result == [{"id": 1}, {"id": 2}, {"id": 3}] + + def test_multiple_pages(self, client): + method = lambda: {"values": [{"id": 1}, {"id": 2}], "next": "/api?page=2"} + + get_mock = MagicMock( + side_effect=[ + {"values": [{"id": 3}, {"id": 4}], "next": "/api?page=3"}, + {"values": [{"id": 5}, {"id": 6}]}, + ] + ) + client._get = get_mock + result = list(client.all_pages(method)) + expected = [{"id": 1}, {"id": 2}, {"id": 3}, {"id": 4}, {"id": 5}, {"id": 6}] + + assert result == expected + assert get_mock.call_count == 2 + assert get_mock.call_args_list[0] == call( + "/api?page=2", + ) + assert get_mock.call_args_list[1] == call( + "/api?page=3", + )