Skip to content
Snippets Groups Projects
Verified Commit 45f416d7 authored by Georg Krause's avatar Georg Krause
Browse files

Add a basic guide how to write tests

parent ab50a69b
No related branches found
No related tags found
No related merge requests found
Pipeline #23629 failed
...@@ -92,3 +92,16 @@ If you want to install this client into another project without publishing it (e ...@@ -92,3 +92,16 @@ If you want to install this client into another project without publishing it (e
### Run tests ### Run tests
To run the tests, run `poetry run pytest`. To run the tests, run `poetry run pytest`.
### How to write test cases
There are two things to test: The models and the API functions.
Lets imagine you want to write a test case for the endpoint `/api/v1/albums`
focusing on the models for now. Since this endpoint lists the Albums, the
correct API call is in `api/albums/albums_list.py`. Check the function called
`_parse_response()`. The model used to parse the response is called
`PaginatedAlbumList`, which we will run tests against. Now curl the endpoint you
want to write tests for and put the response into `tests/data/albums.json`. Now
we can load this json file, load it with the model and do some assertions. The
example is available in `tests/unit/test_model_paginated_album_list.py`.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment