diff --git a/src/tests/functional/auth_test.py b/src/tests/functional/auth_test.py index 3fb4e4c..5c8cc5b 100644 --- a/src/tests/functional/auth_test.py +++ b/src/tests/functional/auth_test.py @@ -85,11 +85,11 @@ def test_login(self, test_client, login_response): """ GIVEN the '/auth/login' is posted to (POST) WHEN using valid credencials username: 'test', password: 'test' - THEN check we get redirected to '/', and player_uid is saved in 'g' and session + THEN check we get redirected to '/', and player is saved in 'g' """ assert login_response.status_code == 200 assert b"Typefight!" in login_response.data # route redirects to index.html if data is correct - assert session["player_uid"] == "bff618f7-9aaa-43a5-9e1a-1b151bd5882f" + assert session["session_hash"] # making sure we're logged in new_response = test_client.get("/") @@ -136,7 +136,7 @@ def test_logout(self, login_response, test_client): assert b"Typefight!" in logout_response.data assert logout_response.status_code == 200 - assert not "player_uid" in session + assert not "session_hash" in session # making sure we're logged out home_response = test_client.get("/") diff --git a/src/tests/functional/game_test.py b/src/tests/functional/game_test.py index 8d113c4..940b2ab 100644 --- a/src/tests/functional/game_test.py +++ b/src/tests/functional/game_test.py @@ -114,12 +114,22 @@ def test_set_new_score(self, test_client, login_response): with g.db as db: cur = db.cursor() + + cur.execute( + """ + SELECT player_uid + FROM players + WHERE player_name = %s; + """, (g.user["player_name"], ) + ) + player_uid = cur.fetchone() + cur.execute( """ DELETE FROM scores WHERE player_uid = %s AND quote_uid = %s; - """, (session["player_uid"], session["quote"]["quote_id"]) + """, (player_uid, session["quote"]["quote_id"]) ) cur.close() @@ -146,12 +156,22 @@ def test_update_score(self, test_client, login_response): # resetting the score with g.db as db: cur = db.cursor() + + cur.execute( + """ + SELECT player_uid + FROM players + WHERE player_name = %s; + """, (g.user["player_name"], ) + ) + player_uid = cur.fetchone() + cur.execute( """ UPDATE scores SET score = 13.37 WHERE player_uid = %s; - """, (session["player_uid"], ) + """, (player_uid, ) ) db.commit() cur.close()