File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change 33
44import pytest
55from django .db import connection
6+ from django .db .utils import OperationalError
67
78from ansible_base .lib .utils .db import advisory_lock , migrations_are_complete
89
@@ -40,3 +41,25 @@ def test_determine_lock_is_held(django_db_blocker):
4041 else :
4142 raise RuntimeError ('Other thread never obtained lock' )
4243 thread .join ()
44+
45+
46+ @pytest .mark .django_db
47+ def test_tuple_lock ():
48+ with advisory_lock ([1234 , 4321 ]):
49+ pass
50+
51+
52+ @pytest .mark .django_db
53+ def test_invalid_tuple_name ():
54+ with pytest .raises (ValueError ):
55+ with advisory_lock (['test_invalid_tuple_name' , 'foo' ]):
56+ pass
57+
58+
59+ @pytest .mark .django_db
60+ def test_lock_session_timeout_milliseconds ():
61+ with pytest .raises (OperationalError ) as exc :
62+ # uses miliseconds units
63+ with advisory_lock ('test_lock_session_timeout_milliseconds' , lock_session_timeout_milliseconds = 2 ):
64+ time .sleep (3 )
65+ assert 'the connection is lost' in str (exc )
You can’t perform that action at this time.
0 commit comments