docker run -d -p 56733:80 litovsky/flask-api-test
And check in browser
http://localhost:56733/
You will see response
{
"GitHub": "https://github.com/berpress/flask-restful-api",
"swagger": "https://app.swaggerhub.com/apis-docs/berpress/flask-rest-api/1.0.0"
}
In tests change url
def pytest_addoption(parser):
parser.addoption(
"--api-url",
action="store",
help="enter api url",
default="http://localhost:56733/",
),
This is a tutorial project that shows how to implement api tests in Python
The project uses:
- Python
- Requests
- Allure for reports
- CI (GitHub actions)
Testing application (write with Flask):
git: https://github.com/berpress/flask-restful-api
url: https://stores-tests-api.herokuapp.com
swagger: https://app.swaggerhub.com/apis/berpress/flask-rest-api/1.0.0
Use python 3.8 + Create and activate virtual environments
python3 -m venv env
source env/bin/activate
Run in terminal
pip install -r requirements.txt
or install poetry https://python-poetry.org/, then
poetry install
and add pre-commit
pre-commit install
pytest
Some requests require an authorization token. Use header like
"Authorization": "JWT {token}"
Download the yes common/report to view the API test coverage report