diff options
author | Lorenz Diener <[email protected]> | 2019-04-27 23:11:37 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2019-04-27 23:11:37 +0200 |
commit | dc6c80bad74dd22ebe1d75869e99bc3f735380b5 (patch) | |
tree | e026e472981f50e215cb03d879db7c59a8269c48 /tests/test_pagination.py | |
parent | 72e3290d8c9ed1dc0babf66ef70a6835a0dcacf4 (diff) | |
download | mastodon.py-dc6c80bad74dd22ebe1d75869e99bc3f735380b5.tar.gz |
Implement, document and test pagination changes
Diffstat (limited to 'tests/test_pagination.py')
-rw-r--r-- | tests/test_pagination.py | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/tests/test_pagination.py b/tests/test_pagination.py index 4f2b9c2..fc64854 100644 --- a/tests/test_pagination.py +++ b/tests/test_pagination.py | |||
@@ -1,5 +1,8 @@ | |||
1 | import pytest | 1 | import pytest |
2 | import vcr | ||
3 | |||
2 | from contextlib import contextmanager | 4 | from contextlib import contextmanager |
5 | |||
3 | try: | 6 | try: |
4 | from mock import MagicMock | 7 | from mock import MagicMock |
5 | except ImportError: | 8 | except ImportError: |
@@ -21,7 +24,6 @@ def many_statuses(api, n=10, suffix=''): | |||
21 | 24 | ||
22 | 25 | ||
23 | @pytest.mark.vcr() | 26 | @pytest.mark.vcr() |
24 | @pytest.mark.skip(reason="will have to add code to handle the new backwards pagination without breaking the old one") | ||
25 | def test_fetch_next_previous(api): | 27 | def test_fetch_next_previous(api): |
26 | account = api.account_verify_credentials() | 28 | account = api.account_verify_credentials() |
27 | with many_statuses(api): | 29 | with many_statuses(api): |
@@ -33,7 +35,6 @@ def test_fetch_next_previous(api): | |||
33 | 35 | ||
34 | 36 | ||
35 | @pytest.mark.vcr() | 37 | @pytest.mark.vcr() |
36 | @pytest.mark.skip(reason="will have to add code to handle the new backwards pagination without breaking the old one") | ||
37 | def test_fetch_next_previous_from_pagination_info(api): | 38 | def test_fetch_next_previous_from_pagination_info(api): |
38 | account = api.account_verify_credentials() | 39 | account = api.account_verify_credentials() |
39 | with many_statuses(api): | 40 | with many_statuses(api): |
@@ -43,6 +44,26 @@ def test_fetch_next_previous_from_pagination_info(api): | |||
43 | previous_statuses = api.fetch_previous(next_statuses[0]._pagination_prev) | 44 | previous_statuses = api.fetch_previous(next_statuses[0]._pagination_prev) |
44 | assert previous_statuses | 45 | assert previous_statuses |
45 | 46 | ||
47 | def test_fetch_next_previous_old_pagination(api): | ||
48 | with vcr.use_cassette('test_fetch_next_previous.yaml', cassette_library_dir='tests/cassettes_old_pagination', record_mode='none'): | ||
49 | account = api.account_verify_credentials() | ||
50 | |||
51 | with many_statuses(api): | ||
52 | statuses = api.account_statuses(account['id'], limit=5) | ||
53 | next_statuses = api.fetch_next(statuses) | ||
54 | assert next_statuses | ||
55 | previous_statuses = api.fetch_previous(next_statuses) | ||
56 | assert previous_statuses | ||
57 | |||
58 | def test_fetch_next_previous_from_pagination_info_old_pagination(api): | ||
59 | account = api.account_verify_credentials() | ||
60 | with vcr.use_cassette('test_fetch_next_previous_from_pagination_info.yaml', cassette_library_dir='tests/cassettes_old_pagination', record_mode='none'): | ||
61 | with many_statuses(api): | ||
62 | statuses = api.account_statuses(account['id'], limit=5) | ||
63 | next_statuses = api.fetch_next(statuses[-1]._pagination_next) | ||
64 | assert next_statuses | ||
65 | previous_statuses = api.fetch_previous(next_statuses[0]._pagination_prev) | ||
66 | assert previous_statuses | ||
46 | 67 | ||
47 | @pytest.mark.vcr() | 68 | @pytest.mark.vcr() |
48 | def test_fetch_remaining(api): | 69 | def test_fetch_remaining(api): |