Mastodon.py/tests
Lorenz Diener f920f8b584 Add final round of tests for moderation API 2019-06-22 22:48:30 +02:00
..
cassettes Add final round of tests for moderation API 2019-06-22 22:48:30 +02:00
cassettes_old_pagination
README.markdown Test fixups pre-2.9.1 2019-06-22 15:28:27 +02:00
__init__.py
conftest.py Prepare tests for 2.9.2 compat 2019-06-22 22:09:44 +02:00
image.jpg
setup.sql Add first half of tests for moderation API 2019-06-22 22:32:21 +02:00
test_account.py Add preferences endpoint 2019-04-28 21:53:01 +02:00
test_admin.py Add final round of tests for moderation API 2019-06-22 22:48:30 +02:00
test_auth.py Test fixups pre-2.9.1 2019-06-22 15:28:27 +02:00
test_blurhash.py Add previously forgotten test 2019-05-11 01:22:55 +02:00
test_constructor.py
test_create_app.py
test_domain_blocks.py
test_errors.py Test fixups pre-2.9.1 2019-06-22 15:28:27 +02:00
test_filters.py
test_follow_requests.py
test_hooks.py
test_instance.py
test_lists.py
test_media.py
test_notifications.py
test_pagination.py
test_polls.py Oops I forgot to commit the polls test 2019-04-29 17:36:07 +02:00
test_push.py Add blurhash code 2019-05-11 00:55:40 +02:00
test_reports.py
test_search.py Add more parameters to search API 2019-04-28 21:15:47 +02:00
test_status.py Try to fix the scheduled status test, 2.7 edition 2019-04-28 21:33:15 +02:00
test_streaming.py Add, document and test stream_healthy 2019-06-22 16:41:32 +02:00
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

Note that some tests are slightly unstable, as they require sidekiq to do things at the right time, and will thus sometimes break.

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. To set this up, follow the development guide and set up the database using "rails db:setup".

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"