diff options
author | codl <[email protected]> | 2017-11-28 14:11:00 +0100 |
---|---|---|
committer | codl <[email protected]> | 2017-11-28 14:12:15 +0100 |
commit | d41e4f42d5d3d222498c8f8b9a91c70b3c5a97e2 (patch) | |
tree | a219b7031409c3466683e6aebaa32bf23a1e3da7 /tests/README.markdown | |
parent | 95777fe58e2c61640e377f447594b9c4f4f91542 (diff) | |
download | mastodon.py-d41e4f42d5d3d222498c8f8b9a91c70b3c5a97e2.tar.gz |
add test documentation
Diffstat (limited to 'tests/README.markdown')
-rw-r--r-- | tests/README.markdown | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/README.markdown b/tests/README.markdown new file mode 100644 index 0000000..ad27a31 --- /dev/null +++ b/tests/README.markdown | |||
@@ -0,0 +1,40 @@ | |||
1 | ## Running | ||
2 | |||
3 | To run this test suite, install the testing dependencies: | ||
4 | |||
5 | pip install -e .[test] | ||
6 | |||
7 | Then, run `pytest`. | ||
8 | |||
9 | If you wish to check test coverage: | ||
10 | |||
11 | pytest --cov=mastodon | ||
12 | |||
13 | And if you want a complete HTML coverage report: | ||
14 | |||
15 | pytest --cov=mastodon --cov-report html:coverage | ||
16 | # then open coverage/index.html in your favourite web browser | ||
17 | |||
18 | |||
19 | ## Contributing | ||
20 | |||
21 | [VCR.py]: https://vcrpy.readthedocs.io/ | ||
22 | |||
23 | This test suite uses [VCR.py][] to record requests to Mastodon and replay them in successive runs. | ||
24 | |||
25 | If you want to add or change tests, you will need a Mastodon development server running on `http://localhost:3000`, with the default `admin` user and default password. | ||
26 | |||
27 | It also needs a test OAuth app to be set up by applying the provided `setup_app.sql` to Mastodon's database: | ||
28 | |||
29 | psql -d mastodon_development < tests/setup_app.sql | ||
30 | |||
31 | Tests that send requests to Mastodon should be marked as needing VCR with the `pytest.mark.vcr` decorator. | ||
32 | |||
33 | ```python | ||
34 | import pytest | ||
35 | |||
36 | @pytest.mark.vcr() | ||
37 | def test_fun_new_feature(api): | ||
38 | foo = api.fun_new_feature() | ||
39 | assert foo = "bar" | ||
40 | ``` | ||