averbis / averbis-python-api

Conveniently access the REST API of Averbis products using Python
Apache License 2.0
12 stars 4 forks source link

Test averbis-python-api against a real platform #79

Open DavidHuebner opened 3 years ago

DavidHuebner commented 3 years ago

Is your feature request related to a problem? Please describe. Right now, we are testing the complete functionality in the averbis-python-api against mocked endpoints. This is great for development and for CI testing, but has some major shortcomings, namely that

  1. The quality of the test coverage depends on how well we mocked the endpoints
  2. We do not notice if anything changes in the platform

Describe the solution you'd like I would like to be able to test the averbis-python-api against a real platform, e.g. the Information Discovery running in a Docker container. For this, we need to be able to switch back and forth between mocked endpoints and real http endpoints. Luckily, requests_mock (our library for setting up mocked endpoints) has a flag (real_http) for that. Replacing all mocked requests by real requests can be as easy as overwriting the requests_mock library like this:

import requests_mock as requests_mock_original
@pytest.fixture()
def requests_mock():
    return requests_mock_original.Mocker(real_http=True)

The major work is then to set up the tests in a suitable manner. The obstacle here is that tests are not independent, e.g. client.list_projects() obviously interacts with client.create_project().

Thus, we need to be able to set up appropriate independent test environments (a project, pipeline, document collection, pear, terminology, etc.) for each test. Most of the required API endpoints for creating those resources are already available. What's missing is at least the option to delete a complete project via the API - hence, I flagged the issue as "requires upstream changes".

Describe alternatives you've considered None