aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-17 20:50:23 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-17 20:50:23 +0200
commitec0194c643d1a59cae8a6c8137f382db8fb4e0aa (patch)
tree166f8191c1746d74c10209d4cf3065da7e9992b7 /tests/test_timeline.py
parent3ed1cf73999ceef24ea3bf8395855bdde3876573 (diff)
downloadmastodon.py-ec0194c643d1a59cae8a6c8137f382db8fb4e0aa.tar.gz
Add additional date based tests
Diffstat (limited to 'tests/test_timeline.py')
-rw-r--r--tests/test_timeline.py33
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 @@
1import pytest 1import pytest
2import time 2import time
3from mastodon.Mastodon import MastodonAPIError,\ 3from mastodon.Mastodon import MastodonAPIError, MastodonIllegalArgumentError, MastodonUnauthorizedError
4 MastodonIllegalArgumentError,\ 4import datetime
5 MastodonUnauthorizedError
6 5
7@pytest.mark.vcr() 6@pytest.mark.vcr()
8def test_public_tl_anonymous(api_anonymous, status3): 7def 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()
65def 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()
80def 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)
Powered by cgit v1.2.3 (git 2.41.0)