Mastodon.py/tests
Aljoscha Rittner bd04a0f886 Fixed overseen test failure with new app name in "secret" file 2022-06-28 13:22:06 +02:00
..
cassettes Preserves storage of pagination in items for compatibility reason 2022-06-24 17:23:00 +02:00
cassettes_old_pagination
cassettes_pre_2_9_2 Update tests for 3.0.1 and fix regressions 2019-10-11 23:59:24 +02:00
README.markdown Introduces pagin parameters for bookmarks 2022-06-24 15:46:27 +02:00
__init__.py
conftest.py Supports a User-Agent header 2022-06-27 11:13:35 +02:00
image.jpg
setup.sql Fix tests for 3.1.1 2020-02-22 20:31:33 +01:00
test_account.py Implement, test and document featured and suggested tags APIs (fixes #191) 2019-10-12 21:47:58 +02:00
test_admin.py Add final round of tests for moderation API 2019-06-22 22:48:30 +02:00
test_auth.py Add ability to persist base urls with clientid/secret/token (fixes #200) 2019-10-12 18:58:46 +02:00
test_blurhash.py
test_bookmarks.py Introduces pagin parameters for bookmarks 2022-06-24 15:46:27 +02:00
test_constructor.py
test_create_app.py Fixed overseen test failure with new app name in "secret" file 2022-06-28 13:22:06 +02:00
test_domain_blocks.py
test_errors.py
test_filters.py Update tests for 3.0.1 and fix regressions 2019-10-11 23:59:24 +02:00
test_follow_requests.py Fresh batch of test runs 2019-06-22 23:16:47 +02:00
test_hooks.py
test_instance.py Add, test and document profile directory API (fixes #188) 2019-10-12 22:05:35 +02:00
test_lists.py
test_markers.py Add, test and document last-read markers. Fixes #192 2019-10-12 22:55:17 +02:00
test_media.py
test_notifications.py Update tests for 3.0.1 and fix regressions 2019-10-11 23:59:24 +02:00
test_pagination.py Preserves storage of pagination in items for compatibility reason 2022-06-24 17:23:00 +02:00
test_polls.py Improve own_votes test 2019-10-12 19:57:14 +02:00
test_push.py Update tests for 3.0.1 and fix regressions 2019-10-11 23:59:24 +02:00
test_reports.py
test_search.py Add new parameter for search 2019-10-12 20:13:38 +02:00
test_status.py Improve card test 2019-10-12 00:02:56 +02:00
test_streaming.py Support of processing unknown events and event names with dots. 2022-06-24 17:39:26 +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-registriation 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"