US02-03: Execute Jobs with Leases, Locks, and Recovery (#56)
This commit was merged in pull request #56.
This commit is contained in:
28
tests/unit/test_lock_order.py
Normal file
28
tests/unit/test_lock_order.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""Lock acquisition ordering (deadlock prevention)."""
|
||||
|
||||
import pytest
|
||||
|
||||
from photo_pipeline.jobs import locks
|
||||
|
||||
|
||||
def test_broad_to_narrow_ranks():
|
||||
assert locks.rank("library") < locks.rank("rename")
|
||||
assert locks.rank("rename") < locks.rank("album")
|
||||
assert locks.rank("album") < locks.rank("asset")
|
||||
|
||||
|
||||
def test_acquiring_narrower_while_holding_broader_is_allowed():
|
||||
locks.validate_acquisition(["library"], "asset") # no raise
|
||||
locks.validate_acquisition(["library", "album"], "asset")
|
||||
|
||||
|
||||
def test_acquiring_broader_while_holding_narrower_is_rejected():
|
||||
with pytest.raises(locks.LockOrderError):
|
||||
locks.validate_acquisition(["asset"], "library")
|
||||
with pytest.raises(locks.LockOrderError):
|
||||
locks.validate_acquisition(["album"], "rename")
|
||||
|
||||
|
||||
def test_unknown_lock_is_rejected():
|
||||
with pytest.raises(locks.LockOrderError):
|
||||
locks.rank("nonsense")
|
||||
Reference in New Issue
Block a user