simple-login/tests/test_prarallel_limiter.py
Adrià Casajús 7f9ce5641f
Feat: Added parallel limiter to prevent sqlalchemy transaction issues (#1360)
* Feat: Added parallel limiter to prevent sqlalchemy transaction issues

* Remove logs

* Moved initialization to its own file

* Throw exception

* Added test

* Add redis to gh actions

* Added v6 to the name

* Removed debug prints

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
2022-10-27 10:07:02 +02:00

14 lines
415 B
Python

from flask_login import login_user
from app.parallel_limiter import _InnerLock
from tests.utils import create_new_user
def test_parallel_limiter(flask_app):
user = create_new_user()
with flask_app.test_request_context():
login_user(user)
pl = _InnerLock("test", max_wait_secs=1, wait_loop_secs=0.1)
for loop_id in range(10):
assert pl(lambda x: x)(loop_id) == loop_id