Mastodonplus.py/tests
2019-05-11 01:22:55 +02:00
..
cassettes Polls 2019-04-28 23:12:27 +02:00
cassettes_old_pagination Implement, document and test pagination changes 2019-04-27 23:11:37 +02:00
__init__.py not pep8 compliant #71 2017-09-05 22:59:32 +02:00
conftest.py Add endorsements (with docs and tests) 2019-04-27 22:13:27 +02:00
image.jpg add tests for media 2017-11-27 23:49:14 +01:00
README.markdown Add a note about streaming tests 2018-05-07 00:55:13 +02:00
setup.sql New casettes, small fixes 2018-06-05 22:10:31 +02:00
test_account.py Add preferences endpoint 2019-04-28 21:53:01 +02:00
test_auth.py Small test fix 2018-06-05 17:47:26 +02:00
test_blurhash.py Add previously forgotten test 2019-05-11 01:22:55 +02:00
test_constructor.py New casettes, small fixes 2018-06-05 22:10:31 +02:00
test_create_app.py Fix up tests 2019-04-28 18:41:12 +02:00
test_domain_blocks.py add tests for domain block methods 2017-11-30 01:29:20 +01:00
test_errors.py remove extraneous import 2019-04-15 14:31:41 +02:00
test_filters.py Improve filter tests 2018-07-30 23:10:24 +02:00
test_follow_requests.py disable follow request emails on test user 2017-11-30 02:05:09 +01:00
test_hooks.py Add another bunch of tests 2018-05-06 02:50:54 +02:00
test_instance.py Pinning tests 2018-06-04 20:55:44 +02:00
test_lists.py New casettes, small fixes 2018-06-05 22:10:31 +02:00
test_media.py Add push tests 2018-06-05 22:52:18 +02:00
test_notifications.py add tests for notification methods 2017-11-30 02:36:43 +01:00
test_pagination.py Fix broken tests 2019-04-27 23:29:27 +02:00
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 fixups and small 2.8 fixes 2019-04-27 21:04:06 +02:00
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 Make the streaming tests somewhat more stable 2018-07-14 01:04:06 +02:00
test_timeline.py Add conversation read marking + tests/docs 2019-04-28 13:58:18 +02:00

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.

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"