Skip to content

Commit

Permalink
Update test_login.py for client login sync
Browse files Browse the repository at this point in the history
Update tests to suit #60d684a8ad3441c89f947a7aad4efffe291f4de6: Add current_time to the command welcome sent to the client on login.
  • Loading branch information
baterflyrity authored Feb 3, 2024
1 parent 60d684a commit 04c1bbc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/integration_tests/test_login.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from datetime import datetime
from time import time

import jwt
Expand All @@ -10,6 +11,8 @@
read_until_command
)

TIMEOUT = 10 # login timeout in seconds

Check failure on line 14 in tests/integration_tests/test_login.py

View workflow job for this annotation

GitHub Actions / flake8

at least two spaces before inline comment


async def test_server_login_invalid(lobby_server):
proto = await connect_client(lobby_server)
Expand Down Expand Up @@ -118,9 +121,12 @@ async def test_server_login_valid(lobby_server):
assert msg == {
"command": "welcome",
"me": me,
"current_time": msg.get("current_time", None),
"id": 3,
"login": "Rhiza"
}
assert isinstance(msg.get("current_time", None), float)
assert abs(msg.get("current_time", -1) - datetime.utcnow().timestamp()) <= TIMEOUT
msg = await proto.read_message()
assert msg == {
"command": "player_info",
Expand Down Expand Up @@ -163,9 +169,12 @@ async def test_server_login_valid_admin(lobby_server):
assert msg == {
"command": "welcome",
"me": me,
"current_time": msg.get("current_time", None),
"id": 1,
"login": "test"
}
assert isinstance(msg.get("current_time", None), float)
assert abs(msg.get("current_time", -1) - datetime.utcnow().timestamp()) <= TIMEOUT
msg = await proto.read_message()
assert msg == {
"command": "player_info",
Expand Down Expand Up @@ -207,9 +216,12 @@ async def test_server_login_valid_moderator(lobby_server):
assert msg == {
"command": "welcome",
"me": me,
"current_time": msg.get("current_time", None),
"id": 20,
"login": "moderator"
}
assert isinstance(msg.get("current_time", None), float)
assert abs(msg.get("current_time", -1) - datetime.utcnow().timestamp()) <= TIMEOUT
msg = await proto.read_message()
assert msg == {
"command": "player_info",
Expand Down Expand Up @@ -305,9 +317,12 @@ async def test_server_login_token_valid(lobby_server, jwk_priv_key, jwk_kid):
assert msg == {
"command": "welcome",
"me": me,
"current_time": msg.get("current_time", None),
"id": 3,
"login": "Rhiza"
}
assert isinstance(msg.get("current_time", None), float)
assert abs(msg.get("current_time", -1) - datetime.utcnow().timestamp()) <= TIMEOUT
msg = await proto.read_message()
assert msg == {
"command": "player_info",
Expand Down

0 comments on commit 04c1bbc

Please sign in to comment.