Testing for API data (python)

This page summarizes the projects mentioned and recommended in the original post on /r/dataengineering

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • responses

    A utility for mocking out the Python Requests library.

  • I like using responses for mocking API calls in unit tests. It's easy to use and has less boilerplate than doing the mocks yourself. The bulk of your unit tests should be around any data transformation you do, and unit testing them should be fairly straightforward. I'd recommend writing integration tests as well, especially as IME the most common reason why data pipelines with API sources break is due to breaking API changes out of your control. I'd make them as high level as possible and make real API calls, preferably using credentials for a designated testing account. Assert the response from the API call conforms to the contract you expect. Additionally to integration test your code, you can test the main entrypoint to your script and make sure it spits out a file with the shape and contents you expect.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts