File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,13 @@ class PostgresTableLockMode(Enum):
1919 EXCLUSIVE = "EXCLUSIVE"
2020 ACCESS_EXCLUSIVE = "ACCESS EXCLUSIVE"
2121
22+ @property
23+ def alias (self ) -> str :
24+ return (
25+ "" .join ([word .title () for word in self .name .lower ().split ("_" )])
26+ + "Lock"
27+ )
28+
2229
2330def postgres_lock_table (
2431 table_name : str ,
Original file line number Diff line number Diff line change @@ -66,18 +66,17 @@ def test_postgres_lock_table_in_schema():
6666 assert lock_signature not in get_table_locks ()
6767
6868
69+ @pytest .mark .parametrize ("lock_mode" , list (PostgresTableLockMode ))
6970@pytest .mark .django_db (transaction = True )
70- def test_postgres_lock_mode (mocked_model ):
71+ def test_postgres_lock_model (mocked_model , lock_mode ):
7172 lock_signature = (
7273 "public" ,
7374 mocked_model ._meta .db_table ,
74- "AccessExclusiveLock" ,
75+ lock_mode . alias ,
7576 )
7677
7778 with transaction .atomic ():
78- postgres_lock_model (
79- mocked_model , PostgresTableLockMode .ACCESS_EXCLUSIVE
80- )
79+ postgres_lock_model (mocked_model , lock_mode )
8180 assert lock_signature in get_table_locks ()
8281
8382 assert lock_signature not in get_table_locks ()
You can’t perform that action at this time.
0 commit comments