Mastodonplus.py/tests
2018-04-18 22:11:32 +02:00
..
cassettes Attempt 2 at fixing the tests for travis 2018-04-18 22:07:03 +02:00
__init__.py not pep8 compliant #71 2017-09-05 22:59:32 +02:00
conftest.py Update the tests 2018-04-18 22:00:35 +02:00
image.jpg add tests for media 2017-11-27 23:49:14 +01:00
README.markdown update test docs 2017-11-29 23:46:51 +01:00
setup.sql Update the tests 2018-04-18 22:00:35 +02:00
test_account.py Attempt 3 at fixing the tests 2018-04-18 22:11:32 +02:00
test_auth.py add test case for log_in with no log in method given 2017-11-27 20:59:14 +01:00
test_constructor.py shouting!!!!!! ahhh python 2 is bad 2017-11-27 20:51:12 +01:00
test_create_app.py use pytest tmpdir fixture instead of making our own temp file 2017-11-27 17:43:37 +01:00
test_domain_blocks.py add tests for domain block methods 2017-11-30 01:29:20 +01:00
test_follow_requests.py disable follow request emails on test user 2017-11-30 02:05:09 +01:00
test_hooks.py id hook test shouldn't be marked as expected to fail anymore 2017-11-29 18:32:37 +01:00
test_instance.py rename mastodon and mastodon_anonymous fixtures to api, api_anonymous 2017-11-27 14:35:02 +01:00
test_media.py add tests for media 2017-11-27 23:49:14 +01:00
test_notifications.py add tests for notification methods 2017-11-30 02:36:43 +01:00
test_pagination.py add test for using _pagination_prev and _pagination_next directly 2017-11-29 23:59:53 +01:00
test_search.py add test for search method 2017-11-30 02:13:44 +01:00
test_status.py Update the tests 2018-04-18 22:00:35 +02:00
test_streaming.py Adjust streaming tests 2017-12-21 11:06:13 +01:00
test_timeline.py update tests 2018-01-03 11:44:14 +01: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

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"