From 897b3a23cf4177675f0769de68f08ad8c4faf335 Mon Sep 17 00:00:00 2001 From: halcy Date: Thu, 17 Nov 2022 23:25:41 +0200 Subject: add server datetime retriever, fix tests some more --- tests/cassettes/test_server_time.yaml | 63 +++++++++++++++++++++++++++++++++++ tests/test_instance.py | 7 +++- tests/test_notifications.py | 1 + tests/test_status.py | 1 + 4 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tests/cassettes/test_server_time.yaml (limited to 'tests') 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 @@ +interactions: +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Authorization: + - Bearer __MASTODON_PY_TEST_ACCESS_TOKEN + Connection: + - keep-alive + User-Agent: + - tests/v311 + method: HEAD + uri: http://localhost:3000/ + response: + body: + string: '' + headers: + Cache-Control: + - max-age=0, public + Content-Security-Policy: + - 'base-uri ''none''; default-src ''none''; frame-ancestors ''none''; font-src + ''self'' http://localhost:3000; img-src ''self'' https: data: blob: http://localhost:3000; + style-src ''self'' http://localhost:3000 ''nonce-2+ENJYUdR8BJrDBHHtp0Iw==''; + media-src ''self'' https: data: http://localhost:3000; frame-src ''self'' + https:; manifest-src ''self'' http://localhost:3000; connect-src ''self'' + data: blob: http://localhost:3000 http://localhost:3000 ws://localhost:4000 + ws://localhost:3035 http://localhost:3035; script-src ''self'' ''unsafe-inline'' + ''unsafe-eval'' http://localhost:3000; child-src ''self'' blob: http://localhost:3000; + worker-src ''self'' blob: http://localhost:3000' + Content-Type: + - text/html; charset=utf-8 + Date: + - Thu, 17 Nov 2022 20:42:32 GMT + ETag: + - W/"9bb3b62cb5fb0388ee3b972a95ee0633" + Referrer-Policy: + - origin + Set-Cookie: + - _mastodon_session=S%2F25BrjlEMmL38vg%2FCMcsvHcd8%2BW45HbUkMBwTiqvTgNnzQ%2FhKVYvwORXtqZ5IgNVXl7gMcJ7SxG9y1ks1LN%2Bw3rvgb%2FxECYIlBWY7C3m%2B0aWsWG%2F8iNJsZfHvXlEY3xQxDzenmA2Mw35wRyPiT%2FSUJvwM9I5RtY1iUDsaCPzUbhGFcw3aoGUTdeag37%2FfGsJuG%2F9JsR0jj%2FCgWAlokV8%2Freu8XPUBFFDmjV9SdyFfzsIvP8%2Bd7cAebpCpaqp2DPngNSm8k6xgqXCuMCqpNc09slWQHzfDVqtWPTCMc95SmGpO0DOethwA44F8WbsfX1x5HGml8%3D--x1Ipi2xI5V5ct712--m3eM1Vf8f4oi87fjm0LEvw%3D%3D; + path=/; HttpOnly; SameSite=Lax + Vary: + - Accept + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Request-Id: + - 9d6b0c84-dff7-481a-a975-c669b8469976 + X-Runtime: + - '0.691929' + X-XSS-Protection: + - 1; mode=block + status: + code: 200 + message: OK +version: 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 @@ import pytest from mastodon.Mastodon import MastodonVersionError +import datetime @pytest.mark.vcr() def test_instance(api): @@ -36,7 +37,11 @@ def test_emoji(api): @pytest.mark.vcr() def test_health(api): assert api.instance_health() == True - + +@pytest.mark.vcr() +def test_server_time(api): + assert isinstance(api.get_approx_server_time(), datetime.datetime) + @pytest.mark.vcr() def test_nodeinfo(api): 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): try: status = api2.status_post('@mastodonpy_test hello!') notifications = api.notifications() + api.verify_minimum_version("2.9.2", cached=False) api.notifications_dismiss(notifications[0]) finally: 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): import time status = api.status_post("http://example.org/") time.sleep(5) # Card generation may take time + api.verify_minimum_version("2.9.2", cached=False) card = api.status_card(status['id']) try: assert card -- cgit v1.2.3