Mastodonplus.py/tests
2017-11-30 02:05:09 +01:00
..
cassettes add tests for follow request methods 2017-11-30 01:54:52 +01:00
__init__.py not pep8 compliant #71 2017-09-05 22:59:32 +02:00
conftest.py add another user to the test setup 2017-11-29 22:06:24 +01: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 disable follow request emails on test user 2017-11-30 02:05:09 +01:00
test_account.py add tests for account methods 2017-11-30 00:56:35 +01: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 hooks: mark failing test resolved in upstream as xfail 2017-11-27 20:42:54 +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_pagination.py add test for using _pagination_prev and _pagination_next directly 2017-11-29 23:59:53 +01:00
test_status.py add tests for writing statuses 2017-11-27 22:52:19 +01:00
test_streaming.py fix streaming tests 2017-11-28 13:50:57 +01:00
test_timeline.py add test for throwing when requesting a hashtag tl with a leading hash 2017-11-29 22:34:13 +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"