This is a proof-of-concept project, showing how PyTest could be used in combination with a custom API client, to quickly and easily build api tests for a data-delivery service that is deployed and active on an existing environment.
1. Add a `.env` file to your local copy of the repo. By default, this demo project will look for `.env.qa` in the root of the project. You can find a template to base this on, in `apiclient/env_template`. Info on how to set the values in that file can be found by asking Greg.
2. Create your virtual env:
```shell
python3 -m venv venv
```
3. Activate the environment:
```shell
source venv/bin/activate
```
On Windows:
```shell
.\venv\Scripts\activate
```
4. Install requirements (pip will come from your venv)
```shell
pip install -r requirements.txt
```
Once this is done, executing the tests is just a matter of invoking pytest:
======================================================================================================== test session starts ========================================================================================================
C:\Users\GregGauthier\Projects\local\pytest-api\.venv\Lib\site-packages\urllib3\connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api-spectrumqa.teledynecontrols.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
====================================================================================================== short test summary info ======================================================================================================
================================================================================================== 5 passed, 5 warnings in 17.20s ===================================================================================================
```
PyTest is configured to show the top 25 test durations, as well as the pass/fail status of all the tests. The tests have been marked with various tags, to allow for granular test selection. To see all the available markers:
======================================================================================================== test session starts ========================================================================================================
C:\Users\GregGauthier\Projects\local\pytest-api\.venv\Lib\site-packages\urllib3\connectionpool.py:1099: InsecureRequestWarning: Unverified HTTPS request is being made to host 'api-spectrumqa.teledynecontrols.com'. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
====================================================================================================== short test summary info ======================================================================================================