Skip to content

ThinGlass/weatherstack-api-tests

Repository files navigation

weatherstack-api-tests

Setup

  1. Get an access key using Weatherstack Quickstart Guide

  2. Create a virtual environment

  3. Install dependencies from requirements.txt

  4. Create a .env file and save your access key

    ACCESS_KEY=your_access_key

  5. Run tests in command line with:

    pytest --html=reports/report.html --self-contained-html

  6. Add -m debug/smoke/regression for specific test cases

Features

  • 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 cases

  • 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

Test execution GIF

test_execution

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published