be-patient


Namebe-patient JSON
Version 0.1.0 PyPI version JSON
download
home_page
SummaryA library facilitating work with asynchronous APIs
upload_time2023-08-13 11:25:46
maintainer
docs_urlNone
author
requires_python>=3.10
licenseMIT License Copyright (c) 2023 Dawid Szaniawski Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords api async api_testing automation json testing web
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Tests](https://github.com/dawid-szaniawski/be_patient/actions/workflows/tox.yml/badge.svg)](https://github.com/dawid-szaniawski/be_patient/actions/workflows/tox.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/dawid-szaniawski/be_patient/blob/master/LICENSE)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![codecov](https://codecov.io/github/dawid-szaniawski/be_patient/branch/master/graph/badge.svg?token=hY7Nb5jGgi)](https://codecov.io/github/dawid-szaniawski/be_patient)
[![CodeFactor](https://www.codefactor.io/repository/github/dawid-szaniawski/be_patient/badge)](https://www.codefactor.io/repository/github/dawid-szaniawski/be_patient)

# Be Patient

_be_patient_ is a library aimed at facilitating work with asynchronous applications. It 
allows for the repeated execution of specific actions until the desired effect is achieved.

## Features

- Set up and monitor requests for expected values.
- Flexible comparison using various checkers and comparers.
- Retry mechanism with customizable retries and delay.

## Installation

To install _be_patient_, you can use pip:

```bash
pip install be_patient
```

_be_patient_ supports Python 3.10+.

## Basic Usage

Using RequestsWaiter object:

```python
from requests import get

from be_patient import RequestsWaiter


waiter = RequestsWaiter(request=get("https://example.com/api"))
waiter.add_checker(comparer="contain", expected_value="string")
waiter.run()

response = waiter.get_result()

assert response.status_code == 200
```

Simple way:

```python
from requests import get

from be_patient import wait_for_value_in_request


response = wait_for_value_in_request(
    request=get("https://example.com/api"),
    comparer="contain",
    expected_value="string"
)
assert response.status_code == 200
```

If we need add more than one checker:

```python
from requests import get

from be_patient import wait_for_values_in_request


list_of_checkers = [
    {
        "checker": "json_checker",
        "comparer": "contain",
        "expected_value": "string"
    },
    {
        "checker": "headers_checker",
        "comparer": "is_equal",
        "expected_value": "cloudflare",
        "dict_path": "Server",
    },
]
response = wait_for_values_in_request(
    request=get("https://example.com/api"),
    checkers=list_of_checkers,
    retries=5,
)
assert response.status_code == 200
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "be-patient",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": "",
    "keywords": "api,async,api_testing,automation,json,testing,web",
    "author": "",
    "author_email": "Dawid Szaniawski <webluduspl@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/f0/f8/349e5ee055b138ac48f76afb8eb963cdfcc9c868452d3ccf56ed3925fb71/be_patient-0.1.0.tar.gz",
    "platform": null,
    "description": "[![Tests](https://github.com/dawid-szaniawski/be_patient/actions/workflows/tox.yml/badge.svg)](https://github.com/dawid-szaniawski/be_patient/actions/workflows/tox.yml)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/dawid-szaniawski/be_patient/blob/master/LICENSE)\r\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\r\n[![codecov](https://codecov.io/github/dawid-szaniawski/be_patient/branch/master/graph/badge.svg?token=hY7Nb5jGgi)](https://codecov.io/github/dawid-szaniawski/be_patient)\r\n[![CodeFactor](https://www.codefactor.io/repository/github/dawid-szaniawski/be_patient/badge)](https://www.codefactor.io/repository/github/dawid-szaniawski/be_patient)\r\n\r\n# Be Patient\r\n\r\n_be_patient_ is a library aimed at facilitating work with asynchronous applications. It \r\nallows for the repeated execution of specific actions until the desired effect is achieved.\r\n\r\n## Features\r\n\r\n- Set up and monitor requests for expected values.\r\n- Flexible comparison using various checkers and comparers.\r\n- Retry mechanism with customizable retries and delay.\r\n\r\n## Installation\r\n\r\nTo install _be_patient_, you can use pip:\r\n\r\n```bash\r\npip install be_patient\r\n```\r\n\r\n_be_patient_ supports Python 3.10+.\r\n\r\n## Basic Usage\r\n\r\nUsing RequestsWaiter object:\r\n\r\n```python\r\nfrom requests import get\r\n\r\nfrom be_patient import RequestsWaiter\r\n\r\n\r\nwaiter = RequestsWaiter(request=get(\"https://example.com/api\"))\r\nwaiter.add_checker(comparer=\"contain\", expected_value=\"string\")\r\nwaiter.run()\r\n\r\nresponse = waiter.get_result()\r\n\r\nassert response.status_code == 200\r\n```\r\n\r\nSimple way:\r\n\r\n```python\r\nfrom requests import get\r\n\r\nfrom be_patient import wait_for_value_in_request\r\n\r\n\r\nresponse = wait_for_value_in_request(\r\n    request=get(\"https://example.com/api\"),\r\n    comparer=\"contain\",\r\n    expected_value=\"string\"\r\n)\r\nassert response.status_code == 200\r\n```\r\n\r\nIf we need add more than one checker:\r\n\r\n```python\r\nfrom requests import get\r\n\r\nfrom be_patient import wait_for_values_in_request\r\n\r\n\r\nlist_of_checkers = [\r\n    {\r\n        \"checker\": \"json_checker\",\r\n        \"comparer\": \"contain\",\r\n        \"expected_value\": \"string\"\r\n    },\r\n    {\r\n        \"checker\": \"headers_checker\",\r\n        \"comparer\": \"is_equal\",\r\n        \"expected_value\": \"cloudflare\",\r\n        \"dict_path\": \"Server\",\r\n    },\r\n]\r\nresponse = wait_for_values_in_request(\r\n    request=get(\"https://example.com/api\"),\r\n    checkers=list_of_checkers,\r\n    retries=5,\r\n)\r\nassert response.status_code == 200\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2023 Dawid Szaniawski  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "A library facilitating work with asynchronous APIs",
    "version": "0.1.0",
    "project_urls": {
        "documentation": "https://webludus.pl",
        "repository": "https://github.com/dawid-szaniawski/be_patient"
    },
    "split_keywords": [
        "api",
        "async",
        "api_testing",
        "automation",
        "json",
        "testing",
        "web"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6e23f3da7e3714a56666e1ecf73a282aad000e1b6d149887d06a32a671796ad9",
                "md5": "5dc8df6fe5df20184ca3af9025cccb0d",
                "sha256": "e638f419fab601eed42018a51e88a517c703da61f1ba8026dd9acc9bf828c84e"
            },
            "downloads": -1,
            "filename": "be_patient-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5dc8df6fe5df20184ca3af9025cccb0d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 14557,
            "upload_time": "2023-08-13T11:25:44",
            "upload_time_iso_8601": "2023-08-13T11:25:44.565954Z",
            "url": "https://files.pythonhosted.org/packages/6e/23/f3da7e3714a56666e1ecf73a282aad000e1b6d149887d06a32a671796ad9/be_patient-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f0f8349e5ee055b138ac48f76afb8eb963cdfcc9c868452d3ccf56ed3925fb71",
                "md5": "bc4be7371d181155590726bb2adc1197",
                "sha256": "1907ee35f7e2d6985ef6d606e5c3164ac72f4cbef7e69d3404af1ad339991918"
            },
            "downloads": -1,
            "filename": "be_patient-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "bc4be7371d181155590726bb2adc1197",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 14302,
            "upload_time": "2023-08-13T11:25:46",
            "upload_time_iso_8601": "2023-08-13T11:25:46.471325Z",
            "url": "https://files.pythonhosted.org/packages/f0/f8/349e5ee055b138ac48f76afb8eb963cdfcc9c868452d3ccf56ed3925fb71/be_patient-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-13 11:25:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dawid-szaniawski",
    "github_project": "be_patient",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "be-patient"
}
        
Elapsed time: 0.10542s