aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorhalcy <halcy@ARARAGI-KUN>2022-11-17 23:25:41 +0200
committerhalcy <halcy@ARARAGI-KUN>2022-11-17 23:25:41 +0200
commit897b3a23cf4177675f0769de68f08ad8c4faf335 (patch)
treee7eb1c75028792509e7f64f1a5eee3eb6e5643ae /tests
parent725f79466de65743df0c3498a1bb08e106b5209e (diff)
downloadmastodon.py-897b3a23cf4177675f0769de68f08ad8c4faf335.tar.gz
add server datetime retriever, fix tests some more
Diffstat (limited to 'tests')
-rw-r--r--tests/cassettes/test_server_time.yaml63
-rw-r--r--tests/test_instance.py7
-rw-r--r--tests/test_notifications.py1
-rw-r--r--tests/test_status.py1
4 files changed, 71 insertions, 1 deletions
diff --git a/tests/cassettes/test_server_time.yaml b/tests/cassettes/test_server_time.yaml
new file mode 100644
index 0000000..a94b3aa
--- /dev/null
+++ b/tests/cassettes/test_server_time.yaml
@@ -0,0 +1,63 @@
1interactions:
2- request:
3 body: null
4 headers:
5 Accept:
6 - '*/*'
7 Accept-Encoding:
8 - gzip, deflate
9 Authorization:
10 - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
11 Connection:
12 - keep-alive
13 User-Agent:
14 - tests/v311
15 method: HEAD
16 uri: http://localhost:3000/
17 response:
18 body:
19 string: ''
20 headers:
21 Cache-Control:
22 - max-age=0, public
23 Content-Security-Policy:
24 - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src
25 ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000;
26 style-src ''self'' http://localhost:3000 ''nonce-2+ENJYUdR8BJrDBHHtp0Iw=='';
27 media-src ''self'' https: data: http://localhost:3000; frame-src ''self''
28 https:; manifest-src ''self'' http://localhost:3000; connect-src ''self''
29 data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000
30 ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline''
31 ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000;
32 worker-src ''self'' blob: http://localhost:3000'
33 Content-Type:
34 - text/html; charset=utf-8
35 Date:
36 - Thu, 17 Nov 2022 20:42:32 GMT
37 ETag:
38 - W/"9bb3b62cb5fb0388ee3b972a95ee0633"
39 Referrer-Policy:
40 - origin
41 Set-Cookie:
42 - _mastodon_session=S%2F25BrjlEMmL38vg%2FCMcsvHcd8%2BW45HbUkMBwTiqvTgNnzQ%2FhKVYvwORXtqZ5IgNVXl7gMcJ7SxG9y1ks1LN%2Bw3rvgb%2FxECYIlBWY7C3m%2B0aWsWG%2F8iNJsZfHvXlEY3xQxDzenmA2Mw35wRyPiT%2FSUJvwM9I5RtY1iUDsaCPzUbhGFcw3aoGUTdeag37%2FfGsJuG%2F9JsR0jj%2FCgWAlokV8%2Freu8XPUBFFDmjV9SdyFfzsIvP8%2Bd7cAebpCpaqp2DPngNSm8k6xgqXCuMCqpNc09slWQHzfDVqtWPTCMc95SmGpO0DOethwA44F8WbsfX1x5HGml8%3D--x1Ipi2xI5V5ct712--m3eM1Vf8f4oi87fjm0LEvw%3D%3D;
43 path=/; HttpOnly; SameSite=Lax
44 Vary:
45 - Accept
46 X-Content-Type-Options:
47 - nosniff
48 X-Download-Options:
49 - noopen
50 X-Frame-Options:
51 - SAMEORIGIN
52 X-Permitted-Cross-Domain-Policies:
53 - none
54 X-Request-Id:
55 - 9d6b0c84-dff7-481a-a975-c669b8469976
56 X-Runtime:
57 - '0.691929'
58 X-XSS-Protection:
59 - 1; mode=block
60 status:
61 code: 200
62 message: OK
63version: 1
diff --git a/tests/test_instance.py b/tests/test_instance.py
index 2762ecb..5de61f6 100644
--- a/tests/test_instance.py
+++ b/tests/test_instance.py
@@ -1,6 +1,7 @@
1import pytest 1import pytest
2 2
3from mastodon.Mastodon import MastodonVersionError 3from mastodon.Mastodon import MastodonVersionError
4import datetime
4 5
5@pytest.mark.vcr() 6@pytest.mark.vcr()
6def test_instance(api): 7def test_instance(api):
@@ -36,7 +37,11 @@ def test_emoji(api):
36@pytest.mark.vcr() 37@pytest.mark.vcr()
37def test_health(api): 38def test_health(api):
38 assert api.instance_health() == True 39 assert api.instance_health() == True
39 40
41@pytest.mark.vcr()
42def test_server_time(api):
43 assert isinstance(api.get_approx_server_time(), datetime.datetime)
44
40@pytest.mark.vcr() 45@pytest.mark.vcr()
41def test_nodeinfo(api): 46def test_nodeinfo(api):
42 nodeinfo = api.instance_nodeinfo() 47 nodeinfo = api.instance_nodeinfo()
diff --git a/tests/test_notifications.py b/tests/test_notifications.py
index 0be81c6..6e761ce 100644
--- a/tests/test_notifications.py
+++ b/tests/test_notifications.py
@@ -26,6 +26,7 @@ def test_notifications_dismiss_pre_2_9_2(api, api2):
26 try: 26 try:
27 status = api2.status_post('@mastodonpy_test hello!') 27 status = api2.status_post('@mastodonpy_test hello!')
28 notifications = api.notifications() 28 notifications = api.notifications()
29 api.verify_minimum_version("2.9.2", cached=False)
29 api.notifications_dismiss(notifications[0]) 30 api.notifications_dismiss(notifications[0])
30 finally: 31 finally:
31 if not status is None: 32 if not status is None:
diff --git a/tests/test_status.py b/tests/test_status.py
index 7e30362..f45634f 100644
--- a/tests/test_status.py
+++ b/tests/test_status.py
@@ -53,6 +53,7 @@ def test_status_card_pre_2_9_2(api):
53 import time 53 import time
54 status = api.status_post("http://example.org/") 54 status = api.status_post("http://example.org/")
55 time.sleep(5) # Card generation may take time 55 time.sleep(5) # Card generation may take time
56 api.verify_minimum_version("2.9.2", cached=False)
56 card = api.status_card(status['id']) 57 card = api.status_card(status['id'])
57 try: 58 try:
58 assert card 59 assert card
Powered by cgit v1.2.3 (git 2.41.0)