Skip to content

Commit

Permalink
Added tests for not blocking lock timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
WisdomPill committed Oct 20, 2024
1 parent 9cecd04 commit b45d68d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,15 +677,27 @@ def test_expire_at(self, cache: RedisCache):

def test_lock(self, cache: RedisCache):
lock = cache.lock("foobar")
lock.acquire(blocking=True)
assert lock.acquire(blocking=True)

assert cache.has_key("foobar")
lock.release()
assert not cache.has_key("foobar")

def test_lock_not_blocking(self, cache: RedisCache):
lock = cache.lock("foobar")
assert lock.acquire(blocking=False)

lock2 = cache.lock("foobar")

assert not lock2.acquire(blocking=False)

assert cache.has_key("foobar")
lock.release()
assert not cache.has_key("foobar")

def test_lock_released_by_thread(self, cache: RedisCache):
lock = cache.lock("foobar", thread_local=False)
lock.acquire(blocking=True)
assert lock.acquire(blocking=True)

def release_lock(lock_):
lock_.release()
Expand Down

0 comments on commit b45d68d

Please sign in to comment.