diff options
author | halcy <halcy@ARARAGI-KUN> | 2022-11-17 20:50:23 +0200 |
---|---|---|
committer | halcy <halcy@ARARAGI-KUN> | 2022-11-17 20:50:23 +0200 |
commit | ec0194c643d1a59cae8a6c8137f382db8fb4e0aa (patch) | |
tree | 166f8191c1746d74c10209d4cf3065da7e9992b7 /tests/test_timeline.py | |
parent | 3ed1cf73999ceef24ea3bf8395855bdde3876573 (diff) | |
download | mastodon.py-ec0194c643d1a59cae8a6c8137f382db8fb4e0aa.tar.gz |
Add additional date based tests
Diffstat (limited to 'tests/test_timeline.py')
-rw-r--r-- | tests/test_timeline.py | 33 |
1 files changed, 30 insertions, 3 deletions
diff --git a/tests/test_timeline.py b/tests/test_timeline.py index 3e6fe22..fbeae8e 100644 --- a/tests/test_timeline.py +++ b/tests/test_timeline.py | |||
@@ -1,8 +1,7 @@ | |||
1 | import pytest | 1 | import pytest |
2 | import time | 2 | import time |
3 | from mastodon.Mastodon import MastodonAPIError,\ | 3 | from mastodon.Mastodon import MastodonAPIError, MastodonIllegalArgumentError, MastodonUnauthorizedError |
4 | MastodonIllegalArgumentError,\ | 4 | import datetime |
5 | MastodonUnauthorizedError | ||
6 | 5 | ||
7 | @pytest.mark.vcr() | 6 | @pytest.mark.vcr() |
8 | def test_public_tl_anonymous(api_anonymous, status3): | 7 | def test_public_tl_anonymous(api_anonymous, status3): |
@@ -61,3 +60,31 @@ def test_conversations(api, api2): | |||
61 | assert account.id in map(lambda x: x.accounts[0].id, conversations) | 60 | assert account.id in map(lambda x: x.accounts[0].id, conversations) |
62 | assert conversations[0].unread == True | 61 | assert conversations[0].unread == True |
63 | assert conversations2[0].unread == False | 62 | assert conversations2[0].unread == False |
63 | |||
64 | @pytest.mark.vcr() | ||
65 | def test_min_max_id(api, status): | ||
66 | time.sleep(3) | ||
67 | tl = api.timeline_home(min_id = status.id - 1000, max_id = status.id + 1000) | ||
68 | assert status['id'] in map(lambda st: st['id'], tl) | ||
69 | |||
70 | tl = api.timeline_home(min_id = status.id - 2000, max_id = status.id - 1000) | ||
71 | assert not status['id'] in map(lambda st: st['id'], tl) | ||
72 | |||
73 | tl = api.timeline_home(min_id = status.id + 1000, max_id = status.id + 2000) | ||
74 | assert not status['id'] in map(lambda st: st['id'], tl) | ||
75 | |||
76 | tl = api.timeline_home(since_id = status.id - 1000) | ||
77 | assert status['id'] in map(lambda st: st['id'], tl) | ||
78 | |||
79 | @pytest.mark.vcr() | ||
80 | def test_min_max_id_datetimes(api, status): | ||
81 | the_past = datetime.datetime.now() - datetime.timedelta(seconds=20) | ||
82 | the_future = datetime.datetime.now() + datetime.timedelta(seconds=20) | ||
83 | the_far_future = datetime.datetime.now() + datetime.timedelta(seconds=40) | ||
84 | |||
85 | time.sleep(3) | ||
86 | tl = api.timeline_home(min_id = the_past, max_id = the_future) | ||
87 | assert status['id'] in map(lambda st: st['id'], tl) | ||
88 | |||
89 | tl = api.timeline_home(min_id = the_future, max_id = the_far_future) | ||
90 | assert not status['id'] in map(lambda st: st['id'], tl) | ||