Improve server time test
This commit is contained in:
parent
c122f1531f
commit
801cc36720
@ -23,7 +23,7 @@ interactions:
|
||||
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=='';
|
||||
style-src ''self'' http://localhost:3000 ''nonce-nXW9HiLDQqbVti2KZWM53g=='';
|
||||
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
|
||||
@ -33,13 +33,13 @@ interactions:
|
||||
Content-Type:
|
||||
- text/html; charset=utf-8
|
||||
Date:
|
||||
- Thu, 17 Nov 2022 20:42:32 GMT
|
||||
- Thu, 17 Nov 2022 22:29:05 GMT
|
||||
ETag:
|
||||
- W/"9bb3b62cb5fb0388ee3b972a95ee0633"
|
||||
- W/"f8be64695d9085d89a46283e6757ef67"
|
||||
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;
|
||||
- _mastodon_session=9%2Bur1I%2Fdtu02oDpNYK%2FtUWLgOanmWgJYVADb34wLg9y25c7xDikPRFcBo71ZqkBXcr0aeHHGiRIPWrH9x8ly6pIsQW90xYNUylhfPndW7vbZVvJqzaVogpSg1oWJmNLLNPDSSWR%2FWJQ9TRCQjSdZM7YWJyAuS6ybSXsI%2BMt9HQjC3W%2BZ7iVYEQFMPbCZN1s4auBla%2Bh%2BNCxRkBBOzNUO03V%2FJCyiHFwpAoUlElpnOeb1F1Fd2sDi%2FzDoOQfdwDX3pdFMs66tZMxOG3NqwkBRoCjmQ3ZHqkfUZ%2BiUtGKFM3RkxFgf6r7Vs4bPE7tVN9n1jB%2Bix3s%3D--IoU4Z629%2BzDZIN%2B7--ps2kda%2BvTZvcFmNUEmRJPA%3D%3D;
|
||||
path=/; HttpOnly; SameSite=Lax
|
||||
Vary:
|
||||
- Accept
|
||||
@ -52,9 +52,135 @@ interactions:
|
||||
X-Permitted-Cross-Domain-Policies:
|
||||
- none
|
||||
X-Request-Id:
|
||||
- 9d6b0c84-dff7-481a-a975-c669b8469976
|
||||
- 9e2e0a4d-5080-4b95-96cb-88de77e0fed7
|
||||
X-Runtime:
|
||||
- '0.691929'
|
||||
- '0.028315'
|
||||
X-XSS-Protection:
|
||||
- 1; mode=block
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
|
||||
Connection:
|
||||
- keep-alive
|
||||
Cookie:
|
||||
- _mastodon_session=9%2Bur1I%2Fdtu02oDpNYK%2FtUWLgOanmWgJYVADb34wLg9y25c7xDikPRFcBo71ZqkBXcr0aeHHGiRIPWrH9x8ly6pIsQW90xYNUylhfPndW7vbZVvJqzaVogpSg1oWJmNLLNPDSSWR%2FWJQ9TRCQjSdZM7YWJyAuS6ybSXsI%2BMt9HQjC3W%2BZ7iVYEQFMPbCZN1s4auBla%2Bh%2BNCxRkBBOzNUO03V%2FJCyiHFwpAoUlElpnOeb1F1Fd2sDi%2FzDoOQfdwDX3pdFMs66tZMxOG3NqwkBRoCjmQ3ZHqkfUZ%2BiUtGKFM3RkxFgf6r7Vs4bPE7tVN9n1jB%2Bix3s%3D--IoU4Z629%2BzDZIN%2B7--ps2kda%2BvTZvcFmNUEmRJPA%3D%3D
|
||||
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-XiBPioKluGBjIKmMpOnxwg=='';
|
||||
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 22:29:06 GMT
|
||||
ETag:
|
||||
- W/"3b5c660342924ee22adaead4e61b8c61"
|
||||
Referrer-Policy:
|
||||
- origin
|
||||
Set-Cookie:
|
||||
- _mastodon_session=uh3TnZQHpCFWGKegBrpeXz%2F1Vx3brDN4EaOE52yOjkO8LgjV4Zdc%2Fhqyiha6m4g55D%2BBvhpnyTaKtIPze6h7MporjUOzGIp6kz%2Bn%2FYsMoJnbBNaTe0gEcwvSbvD%2FYUG%2F9OWcuNZ6T7wfwoGavkWFhSOGXlfX6WGfAjEwcoY60EqVhjuvNkqASVzND4%2FZgIXkCyKcLWFlgqiKSyTDA5Dr2IsMC1DErEnXxTyZJnvKTEzmAZdmu08QuPlJjFR%2FL2bhP4R%2FsHcDEB%2FCe0PgCLsJIv%2BUMl6Pjyl9Q5xYTyhG6n%2Fwp5qaZo1Xc6s%2BjgRAuEJ%2F7XcYpKU%3D--E6KHuGdfZvSsPXBg--%2F713IcELMZqhavNHEoHyAw%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:
|
||||
- 5a29618e-2aec-445a-b461-cd1e4709a98a
|
||||
X-Runtime:
|
||||
- '0.022491'
|
||||
X-XSS-Protection:
|
||||
- 1; mode=block
|
||||
status:
|
||||
code: 200
|
||||
message: OK
|
||||
- request:
|
||||
body: null
|
||||
headers:
|
||||
Accept:
|
||||
- '*/*'
|
||||
Accept-Encoding:
|
||||
- gzip, deflate
|
||||
Authorization:
|
||||
- Bearer __MASTODON_PY_TEST_ACCESS_TOKEN
|
||||
Connection:
|
||||
- keep-alive
|
||||
Cookie:
|
||||
- _mastodon_session=uh3TnZQHpCFWGKegBrpeXz%2F1Vx3brDN4EaOE52yOjkO8LgjV4Zdc%2Fhqyiha6m4g55D%2BBvhpnyTaKtIPze6h7MporjUOzGIp6kz%2Bn%2FYsMoJnbBNaTe0gEcwvSbvD%2FYUG%2F9OWcuNZ6T7wfwoGavkWFhSOGXlfX6WGfAjEwcoY60EqVhjuvNkqASVzND4%2FZgIXkCyKcLWFlgqiKSyTDA5Dr2IsMC1DErEnXxTyZJnvKTEzmAZdmu08QuPlJjFR%2FL2bhP4R%2FsHcDEB%2FCe0PgCLsJIv%2BUMl6Pjyl9Q5xYTyhG6n%2Fwp5qaZo1Xc6s%2BjgRAuEJ%2F7XcYpKU%3D--E6KHuGdfZvSsPXBg--%2F713IcELMZqhavNHEoHyAw%3D%3D
|
||||
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-3V+Y3NQPR7ogARWAKoOmPA=='';
|
||||
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 22:29:06 GMT
|
||||
ETag:
|
||||
- W/"818a87013531b8f4e9b2052440c21631"
|
||||
Referrer-Policy:
|
||||
- origin
|
||||
Set-Cookie:
|
||||
- _mastodon_session=HzqGfcAAFBlwhl021YjmxBlQrhCMXb93XugXjXbslcjqIHvlI%2B%2BvLHcnjCcKgxeYqu02FNmgARy7eb8m1GrATgUzDzs1HglhEYTeN%2BpKy0q4QwVCB2X1LCRLa84%2FXOG4YE8YF6tOFKGt1zdOcx3Auh20pZ8JoM8eCUP9Fr8%2FfhXDG1wfd5eFDsWJpvntWdqonQfZe%2FKbKxEHysA1HJz3Ke98laJY8cz%2FCq2T%2FjImsL0h4MqxuepbBizGfHgDyyr2b4psJUoru8Yqq93rZhH07gMh0QPBaVCnkYnhhoANksdbG24cOknP5K0RHBjbh4%2Bjj6IsyWQ%3D--fZgRaWLdzjI%2Fu5hU--BU9evoOFE9S%2BdFhVaCaAfQ%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:
|
||||
- 5fdd2421-a8d4-48c5-8e14-6d045ddf6239
|
||||
X-Runtime:
|
||||
- '0.030469'
|
||||
X-XSS-Protection:
|
||||
- 1; mode=block
|
||||
status:
|
||||
|
BIN
tests/cassettes/test_server_time_datetimeobjects.pkl
Normal file
BIN
tests/cassettes/test_server_time_datetimeobjects.pkl
Normal file
Binary file not shown.
@ -2,6 +2,8 @@ import pytest
|
||||
|
||||
from mastodon.Mastodon import MastodonVersionError
|
||||
import datetime
|
||||
import os
|
||||
import pickle
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_instance(api):
|
||||
@ -40,7 +42,18 @@ def test_health(api):
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_server_time(api):
|
||||
# present date...
|
||||
present_time = api.get_approx_server_time()
|
||||
# hahahahaha
|
||||
|
||||
if os.path.exists("tests/cassettes/test_server_time_datetimeobjects.pkl"):
|
||||
present_time_real = datetime.datetime.fromtimestamp(pickle.load(open("tests/cassettes/test_server_time_datetimeobjects.pkl", 'rb')))
|
||||
else:
|
||||
present_time_real = datetime.datetime.now()
|
||||
pickle.dump(present_time_real.timestamp(), open("tests/cassettes/test_server_time_datetimeobjects.pkl", 'wb'))
|
||||
|
||||
assert isinstance(api.get_approx_server_time(), datetime.datetime)
|
||||
assert abs((api.get_approx_server_time() - present_time_real).total_seconds()) < 5
|
||||
|
||||
@pytest.mark.vcr()
|
||||
def test_nodeinfo(api):
|
||||
|
Loading…
x
Reference in New Issue
Block a user