-
Get an access key using Weatherstack Quickstart Guide
-
Create a virtual environment
-
Install dependencies from requirements.txt
-
Create a .env file and save your access key
ACCESS_KEY=your_access_key -
Run tests in command line with:
pytest --html=reports/report.html --self-contained-html -
Add -m debug/smoke/regression for specific test cases
- Structure is inspired by POM, using a class for each endpoint
- Each class should include all methods (GET, POST, etc) and parameters
- Can be improved by using a BaseAPI if the tests need to be executed on multiple servers (local, stage, prod)
- Authentication and other variables are stored in local environment, preparation for running tests in CI/CD pipeline
- Parametrized test cases with test data stored in JSON files
- Pytest markers are used to allow running tests only for smoke, regression, a specific endpoint / API component
- JSON Schema validation for each response
- Logging and debugging - both for CLI (debugging) and for captured logs (pipelines)
- HTML report - basic, can be improved with Allure reports
- Delays between executions - required by the API rate limitations, running without delays will return 429 error
- test_valid_city_name - checks that the weather for a specific city is returned
- test_valid_gps_location - checks that the city is correctly identified (name, country and region)
- test_missing_access_key - checks the error codes for unauthorized requests
- will fail because the response status should be 401, not 200
- test_invalid_city_name - checks the error code for failure to identify the city by name
- test_missing_query_parameter - check the error code for incorrect request format
- will fail intentionally to display the schema validation error
