Mastodon.py/tests
Lorenz Diener fbd4122fec Add emoji test 2018-05-06 15:52:55 +02:00
..
cassettes Add emoji test 2018-05-06 15:52:55 +02:00
README.markdown
__init__.py
conftest.py
image.jpg
setup.sql
test_account.py
test_auth.py
test_constructor.py Add another bunch of tests 2018-05-06 02:50:54 +02:00
test_create_app.py
test_domain_blocks.py
test_follow_requests.py
test_hooks.py Add another bunch of tests 2018-05-06 02:50:54 +02:00
test_instance.py Add emoji test 2018-05-06 15:52:55 +02:00
test_lists.py Add lists tests and fix a bug 2018-05-06 15:42:38 +02:00
test_media.py Add another bunch of tests 2018-05-06 02:50:54 +02:00
test_notifications.py
test_pagination.py
test_reports.py Add reports test 2018-05-06 02:58:43 +02:00
test_search.py
test_status.py
test_streaming.py
test_timeline.py

README.markdown

Running

To run this test suite, install the testing dependencies:

pip install -e .[test]

Then, run pytest.

If you wish to check test coverage:

pytest --cov=mastodon

And if you want a complete HTML coverage report:

pytest --cov=mastodon --cov-report html:coverage
# then open coverage/index.html in your favourite web browser

Contributing

This test suite uses VCR.py to record requests to Mastodon and replay them in successive runs.

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.

It also needs a test OAuth app and an additional test user to be set up by applying the provided setup.sql to Mastodon's database:

psql -d mastodon_development < tests/setup.sql

Tests that send requests to Mastodon should be marked as needing VCR with the pytest.mark.vcr decorator.

import pytest

@pytest.mark.vcr()
def test_fun_new_feature(api):
    foo = api.fun_new_feature()
    assert foo = "bar"