diff options
author | codl <[email protected]> | 2017-11-27 14:35:02 +0100 |
---|---|---|
committer | codl <[email protected]> | 2017-11-27 14:35:02 +0100 |
commit | 304145f4420180b23e0836a6d11fc0cec0e341bd (patch) | |
tree | e35d03c41a4f6b3f11c52257b62d0c4666ea9ce3 /tests | |
parent | cfc9c1ce0c6440506d3a88397c65ad47bdd2d662 (diff) | |
download | mastodon.py-304145f4420180b23e0836a6d11fc0cec0e341bd.tar.gz |
rename mastodon and mastodon_anonymous fixtures to api, api_anonymous
it was starting to get confusing
Diffstat (limited to 'tests')
-rw-r--r-- | tests/conftest.py | 18 | ||||
-rw-r--r-- | tests/test_hooks.py | 12 | ||||
-rw-r--r-- | tests/test_instance.py | 4 | ||||
-rw-r--r-- | tests/test_timeline.py | 20 |
4 files changed, 27 insertions, 27 deletions
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 @@ | |||
1 | import pytest | 1 | import pytest |
2 | 2 | ||
3 | @pytest.fixture | 3 | @pytest.fixture |
4 | def mastodon(): | 4 | def api(): |
5 | import mastodon as _mastodon | 5 | import mastodon |
6 | return _mastodon.Mastodon( | 6 | return mastodon.Mastodon( |
7 | api_base_url='http://localhost:3000', | 7 | api_base_url='http://localhost:3000', |
8 | client_id='__MASTODON_PY_TEST_ID', | 8 | client_id='__MASTODON_PY_TEST_ID', |
9 | client_secret='__MASTODON_PY_TEST_SECRET', | 9 | client_secret='__MASTODON_PY_TEST_SECRET', |
10 | access_token='__MASTODON_PY_TEST_TOKEN') | 10 | access_token='__MASTODON_PY_TEST_TOKEN') |
11 | 11 | ||
12 | @pytest.fixture | 12 | @pytest.fixture |
13 | def mastodon_anonymous(): | 13 | def api_anonymous(): |
14 | import mastodon as _mastodon | 14 | import mastodon |
15 | return _mastodon.Mastodon( | 15 | return mastodon.Mastodon( |
16 | api_base_url='http://localhost:3000', | 16 | api_base_url='http://localhost:3000', |
17 | client_id='__MASTODON_PY_TEST_ID', | 17 | client_id='__MASTODON_PY_TEST_ID', |
18 | client_secret='__MASTODON_PY_TEST_SECRET') | 18 | client_secret='__MASTODON_PY_TEST_SECRET') |
19 | 19 | ||
20 | @pytest.fixture() | 20 | @pytest.fixture() |
21 | def status(mastodon): | 21 | def status(api): |
22 | _status = mastodon.status_post('Toot!') | 22 | _status = api.status_post('Toot!') |
23 | yield _status | 23 | yield _status |
24 | mastodon.status_delete(_status['id']) | 24 | api.status_delete(_status['id']) |
25 | 25 | ||
26 | 26 | ||
27 | @pytest.fixture() | 27 | @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): | |||
6 | assert isinstance(status['id'], int) | 6 | assert isinstance(status['id'], int) |
7 | 7 | ||
8 | @pytest.mark.vcr() | 8 | @pytest.mark.vcr() |
9 | def test_id_hook_in_reply_to(mastodon, status): | 9 | def test_id_hook_in_reply_to(api, status): |
10 | reply = mastodon.status_post('Reply!', in_reply_to_id=status['id']) | 10 | reply = api.status_post('Reply!', in_reply_to_id=status['id']) |
11 | try: | 11 | try: |
12 | assert isinstance(reply['in_reply_to_id'], int) | 12 | assert isinstance(reply['in_reply_to_id'], int) |
13 | assert isinstance(reply['in_reply_to_account_id'], int) | 13 | assert isinstance(reply['in_reply_to_account_id'], int) |
14 | finally: | 14 | finally: |
15 | mastodon.status_delete(reply['id']) | 15 | api.status_delete(reply['id']) |
16 | 16 | ||
17 | @pytest.mark.vcr() | 17 | @pytest.mark.vcr() |
18 | def test_id_hook_within_reblog(mastodon, status): | 18 | def test_id_hook_within_reblog(api, status): |
19 | reblog = mastodon.status_reblog(status['id']) | 19 | reblog = api.status_reblog(status['id']) |
20 | try: | 20 | try: |
21 | assert isinstance(reblog['reblog']['id'], int) | 21 | assert isinstance(reblog['reblog']['id'], int) |
22 | finally: | 22 | finally: |
23 | mastodon.status_delete(reblog['id']) | 23 | api.status_delete(reblog['id']) |
24 | 24 | ||
25 | 25 | ||
26 | @pytest.mark.vcr() | 26 | @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 @@ | |||
1 | import pytest | 1 | import pytest |
2 | 2 | ||
3 | @pytest.mark.vcr() | 3 | @pytest.mark.vcr() |
4 | def test_instance(mastodon): | 4 | def test_instance(api): |
5 | instance = mastodon.instance() | 5 | instance = api.instance() |
6 | 6 | ||
7 | assert isinstance(instance, dict) # hehe, instance is instance | 7 | assert isinstance(instance, dict) # hehe, instance is instance |
8 | 8 | ||
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 @@ | |||
1 | import pytest | 1 | import pytest |
2 | 2 | ||
3 | @pytest.mark.vcr() | 3 | @pytest.mark.vcr() |
4 | def test_public_tl_anonymous(mastodon_anonymous, status): | 4 | def test_public_tl_anonymous(api_anonymous, status): |
5 | tl = mastodon_anonymous.timeline_public() | 5 | tl = api_anonymous.timeline_public() |
6 | assert status['id'] in map(lambda st: st['id'], tl) | 6 | assert status['id'] in map(lambda st: st['id'], tl) |
7 | # although tempting, we can't do | 7 | # although tempting, we can't do |
8 | # assert status in tl | 8 | # assert status in tl |
@@ -10,21 +10,21 @@ def test_public_tl_anonymous(mastodon_anonymous, status): | |||
10 | # pagination-related attributes | 10 | # pagination-related attributes |
11 | 11 | ||
12 | @pytest.mark.vcr() | 12 | @pytest.mark.vcr() |
13 | def test_public_tl(mastodon, status): | 13 | def test_public_tl(api, status): |
14 | tl = mastodon.timeline_public() | 14 | tl = api.timeline_public() |
15 | print(tl[0]) | 15 | print(tl[0]) |
16 | assert status['id'] in map(lambda st: st['id'], tl) | 16 | assert status['id'] in map(lambda st: st['id'], tl) |
17 | 17 | ||
18 | @pytest.mark.vcr() | 18 | @pytest.mark.vcr() |
19 | def test_home_tl(mastodon, status): | 19 | def test_home_tl(api, status): |
20 | tl = mastodon.timeline_home() | 20 | tl = api.timeline_home() |
21 | assert status['id'] in map(lambda st: st['id'], tl) | 21 | assert status['id'] in map(lambda st: st['id'], tl) |
22 | 22 | ||
23 | @pytest.mark.vcr() | 23 | @pytest.mark.vcr() |
24 | def test_hashtag_tl(mastodon): | 24 | def test_hashtag_tl(api): |
25 | status = mastodon.status_post('#hoot (hashtag toot)') | 25 | status = api.status_post('#hoot (hashtag toot)') |
26 | tl = mastodon.timeline_hashtag('hoot') | 26 | tl = api.timeline_hashtag('hoot') |
27 | try: | 27 | try: |
28 | assert status['id'] in map(lambda st: st['id'], tl) | 28 | assert status['id'] in map(lambda st: st['id'], tl) |
29 | finally: | 29 | finally: |
30 | mastodon.status_delete(status['id']) | 30 | api.status_delete(status['id']) |