Wait for some http response
Project description
Wait for some HTTP response
===========================
Written in order to make functional tests less complicated.
Retries a HTTP request until it responds as expected or reaches
the max attempt number.
------------------------------------------------------------------
Lets say we have an endpoint `http://localhost:8080/health` that give
us a json, e.g., `{ "status": "UP" }`. This script keep checking that endpoint
until it receives the `UP` status or it reaches the max number of attempts.
# Install
`pip install wait_response`
# Module
You can use a function from the module to wait for status responses.
```python
import wait_response
from wait_response import wait_response_status
# Make 2 attempts to get status=UP, trying every 1 seconds.
respCode = wait_response_status('http://localhost:8080/health', 2, 1, 'UP')
print(respCode) # 0 if success or else, 1
```
# Script
`wait_response url [OPTIONS]`
`url` is the required endpoint, e.g., `http://localhost:8080/health`.
## Options
* `--max-attempts default=20` The max number of attempts.
* `--sleep defaul=1` Sleep time, in seconds, between checks.
* `--status default=UP` The status to wait for. E.g., `GREEN` or `YELLOW`.
# Developing
## Tests
Use `unittest`
`python -m unittest test.test_wait_response`
## Run script
===========================
Written in order to make functional tests less complicated.
Retries a HTTP request until it responds as expected or reaches
the max attempt number.
------------------------------------------------------------------
Lets say we have an endpoint `http://localhost:8080/health` that give
us a json, e.g., `{ "status": "UP" }`. This script keep checking that endpoint
until it receives the `UP` status or it reaches the max number of attempts.
# Install
`pip install wait_response`
# Module
You can use a function from the module to wait for status responses.
```python
import wait_response
from wait_response import wait_response_status
# Make 2 attempts to get status=UP, trying every 1 seconds.
respCode = wait_response_status('http://localhost:8080/health', 2, 1, 'UP')
print(respCode) # 0 if success or else, 1
```
# Script
`wait_response url [OPTIONS]`
`url` is the required endpoint, e.g., `http://localhost:8080/health`.
## Options
* `--max-attempts default=20` The max number of attempts.
* `--sleep defaul=1` Sleep time, in seconds, between checks.
* `--status default=UP` The status to wait for. E.g., `GREEN` or `YELLOW`.
# Developing
## Tests
Use `unittest`
`python -m unittest test.test_wait_response`
## Run script
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distributions
File details
Details for the file wait_response-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: wait_response-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9dfaf53d04f42950ce3ac70e85e7d81a91ecca5c8358b44aa1118ad2b0aa58e |
|
MD5 | b416f5a06d442daf9001bf2db0413407 |
|
BLAKE2b-256 | e4876d044eb88e515089c70edf3dfc283771c08c73effda65b6ff6be4c87c089 |
File details
Details for the file wait_response-1.0.0-py2.7.egg
.
File metadata
- Download URL: wait_response-1.0.0-py2.7.egg
- Upload date:
- Size: 6.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3efbb9f6acb476ec09f24b6f5528c7df431bb653fb0a00ef58c8377fd95747c |
|
MD5 | ffed9d19dd0fb9cde6ef9240d8fb5ba2 |
|
BLAKE2b-256 | 99608e65822415840de80fa0d2038b8d4ed05293de9ddf997e0c7980c6f3e410 |