Mastodonplus.py/tests
2017-11-29 17:48:56 +01:00
..
cassettes add test for fetch_remaining 2017-11-28 01:49:15 +01:00
__init__.py not pep8 compliant #71 2017-09-05 22:59:32 +02:00
conftest.py rename mastodon and mastodon_anonymous fixtures to api, api_anonymous 2017-11-27 14:35:02 +01:00
image.jpg add tests for media 2017-11-27 23:49:14 +01:00
README.markdown add test documentation 2017-11-28 14:12:15 +01:00
setup_app.sql typo 2017-11-27 14:56:07 +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_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 fetch_remaining 2017-11-28 01:49:15 +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 update public tl test to also test local tl 2017-11-27 15:26:33 +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 to be set up by applying the provided setup_app.sql to Mastodon's database:

psql -d mastodon_development < tests/setup_app.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"