Skip to content

Commit 3acd4e7

Browse files
committed
test: Fix last failing tests
1 parent e28aca3 commit 3acd4e7

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

tests/sessions/claims/test_get_claim_value.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,7 @@ async def test_should_get_the_right_value_using_session_handle():
4545
assert isinstance(res, GetClaimValueOkResult)
4646
assert res.value is True
4747

48-
import pytest
4948

50-
@pytest.mark.skip
5149
async def test_should_work_for_non_existing_handle():
5250
new_st_init = {
5351
**st_init_common_args,
@@ -58,5 +56,5 @@ async def test_should_work_for_non_existing_handle():
5856
init(**new_st_init) # type: ignore
5957
start_st()
6058

61-
res = await get_claim_value("non_existing_handle", TrueClaim)
59+
res = await get_claim_value("non-existing-handle", TrueClaim)
6260
assert isinstance(res, SessionDoesNotExistError)

tests/test_session.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ async def test_creating_many_sessions_for_one_user_and_looping():
202202

203203
assert len(session_handles) == 7
204204

205-
for i, handle in enumerate(session_handles):
205+
for handle in session_handles:
206206
info = await get_session_information(handle)
207207
assert info is not None
208208
assert info.user_id == "someUser"
@@ -224,19 +224,22 @@ async def test_creating_many_sessions_for_one_user_and_looping():
224224
assert info.custom_claims_in_access_token_payload == {"someKey2": "someValue"}
225225
assert info.session_data_in_database == {"foo": "bar"}
226226

227+
regenerated_session_handles: List[str] = []
227228
# Regenerate access token with new access_token_payload
228-
for i, token in enumerate(access_tokens):
229+
for token in access_tokens:
229230
result = await regenerate_access_token(token, {"bar": "baz"})
230231
assert result is not None
231-
assert (
232-
result.session.handle == session_handles[i]
233-
) # Session handle should remain the same
232+
regenerated_session_handles.append(result.session.handle)
234233

235234
# Confirm that update worked:
236235
info = await get_session_information(result.session.handle)
237236
assert info is not None
238237
assert info.custom_claims_in_access_token_payload == {"bar": "baz"}
239238

239+
# Session handle should remain the same session handle should remain the same
240+
# but order isn't guaranteed so we should sort them
241+
assert sorted(regenerated_session_handles) == sorted(session_handles)
242+
240243
# Try updating invalid handles:
241244
is_updated = await merge_into_access_token_payload("invalidHandle", {"foo": "bar"})
242245
assert is_updated is False

0 commit comments

Comments
 (0)