From 304145f4420180b23e0836a6d11fc0cec0e341bd Mon Sep 17 00:00:00 2001 From: codl Date: Mon, 27 Nov 2017 14:35:02 +0100 Subject: rename mastodon and mastodon_anonymous fixtures to api, api_anonymous it was starting to get confusing --- tests/conftest.py | 18 +++++++++--------- tests/test_hooks.py | 12 ++++++------ tests/test_instance.py | 4 ++-- tests/test_timeline.py | 20 ++++++++++---------- 4 files changed, 27 insertions(+), 27 deletions(-) (limited to 'tests') diff --git a/tests/conftest.py b/tests/conftest.py index ce013cb..a0733b5 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,27 +1,27 @@ import pytest @pytest.fixture -def mastodon(): - import mastodon as _mastodon - return _mastodon.Mastodon( +def api(): + import mastodon + return mastodon.Mastodon( api_base_url='http://localhost:3000', client_id='__MASTODON_PY_TEST_ID', client_secret='__MASTODON_PY_TEST_SECRET', access_token='__MASTODON_PY_TEST_TOKEN') @pytest.fixture -def mastodon_anonymous(): - import mastodon as _mastodon - return _mastodon.Mastodon( +def api_anonymous(): + import mastodon + return mastodon.Mastodon( api_base_url='http://localhost:3000', client_id='__MASTODON_PY_TEST_ID', client_secret='__MASTODON_PY_TEST_SECRET') @pytest.fixture() -def status(mastodon): - _status = mastodon.status_post('Toot!') +def status(api): + _status = api.status_post('Toot!') yield _status - mastodon.status_delete(_status['id']) + api.status_delete(_status['id']) @pytest.fixture() diff --git a/tests/test_hooks.py b/tests/test_hooks.py index 132021b..b31343c 100644 --- a/tests/test_hooks.py +++ b/tests/test_hooks.py @@ -6,21 +6,21 @@ def test_id_hook(status): assert isinstance(status['id'], int) @pytest.mark.vcr() -def test_id_hook_in_reply_to(mastodon, status): - reply = mastodon.status_post('Reply!', in_reply_to_id=status['id']) +def test_id_hook_in_reply_to(api, status): + reply = api.status_post('Reply!', in_reply_to_id=status['id']) try: assert isinstance(reply['in_reply_to_id'], int) assert isinstance(reply['in_reply_to_account_id'], int) finally: - mastodon.status_delete(reply['id']) + api.status_delete(reply['id']) @pytest.mark.vcr() -def test_id_hook_within_reblog(mastodon, status): - reblog = mastodon.status_reblog(status['id']) +def test_id_hook_within_reblog(api, status): + reblog = api.status_reblog(status['id']) try: assert isinstance(reblog['reblog']['id'], int) finally: - mastodon.status_delete(reblog['id']) + api.status_delete(reblog['id']) @pytest.mark.vcr() diff --git a/tests/test_instance.py b/tests/test_instance.py index 3ea3cf1..7b6dc49 100644 --- a/tests/test_instance.py +++ b/tests/test_instance.py @@ -1,8 +1,8 @@ import pytest @pytest.mark.vcr() -def test_instance(mastodon): - instance = mastodon.instance() +def test_instance(api): + instance = api.instance() assert isinstance(instance, dict) # hehe, instance is instance diff --git a/tests/test_timeline.py b/tests/test_timeline.py index 0306391..492d0c7 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py @@ -1,8 +1,8 @@ import pytest @pytest.mark.vcr() -def test_public_tl_anonymous(mastodon_anonymous, status): - tl = mastodon_anonymous.timeline_public() +def test_public_tl_anonymous(api_anonymous, status): + tl = api_anonymous.timeline_public() assert status['id'] in map(lambda st: st['id'], tl) # although tempting, we can't do # assert status in tl @@ -10,21 +10,21 @@ def test_public_tl_anonymous(mastodon_anonymous, status): # pagination-related attributes @pytest.mark.vcr() -def test_public_tl(mastodon, status): - tl = mastodon.timeline_public() +def test_public_tl(api, status): + tl = api.timeline_public() print(tl[0]) assert status['id'] in map(lambda st: st['id'], tl) @pytest.mark.vcr() -def test_home_tl(mastodon, status): - tl = mastodon.timeline_home() +def test_home_tl(api, status): + tl = api.timeline_home() assert status['id'] in map(lambda st: st['id'], tl) @pytest.mark.vcr() -def test_hashtag_tl(mastodon): - status = mastodon.status_post('#hoot (hashtag toot)') - tl = mastodon.timeline_hashtag('hoot') +def test_hashtag_tl(api): + status = api.status_post('#hoot (hashtag toot)') + tl = api.timeline_hashtag('hoot') try: assert status['id'] in map(lambda st: st['id'], tl) finally: - mastodon.status_delete(status['id']) + api.status_delete(status['id']) -- cgit v1.2.3