Skip to content

Commit

Permalink
tests(socialaccount): fix timestamp issue in test_stashing
Browse files Browse the repository at this point in the history
Co-authored-by: k-brahma <k-brahma@noreply.codeberg.org>
Co-committed-by: k-brahma <k-brahma@noreply.codeberg.org>
  • Loading branch information
k-brahma authored and pennersr committed Feb 26, 2025
1 parent 4605a6f commit b516fd4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions allauth/socialaccount/internal/tests/test_statekit.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import time
from allauth.socialaccount.internal import statekit


Expand Down Expand Up @@ -31,11 +32,18 @@ def test_gc_states():
def test_stashing(rf):
request = rf.get("/")
request.session = {}

# Stash states with a small delay
state_id = statekit.stash_state(request, {"foo": "bar"})
time.sleep(0.001) # delay for microseconds
state2_id = statekit.stash_state(request, {"foo2": "bar2"})
time.sleep(0.001) # delay for microseconds
state3_id = statekit.stash_state(request, {"foo3": "bar3"})

# Unstash last state and check order
state = statekit.unstash_last_state(request)
assert state == {"foo3": "bar3"}

state = statekit.unstash_state(request, state3_id)
assert state is None
state = statekit.unstash_state(request, state2_id)
Expand Down

0 comments on commit b516fd4

Please sign in to comment.