test_ingest_file_locks_static.py
998 Bytes
from pathlib import Path
import unittest
class IngestFileLocksStaticTest(unittest.TestCase):
def test_ingest_is_global_serial_but_egress_only_uses_file_lock(self):
source = Path("src/api/routes/ingest.py").read_text(encoding="utf-8")
self.assertIn("ingest_global_lock = asyncio.Lock()", source)
self.assertIn("async with ingest_global_lock:", source)
self.assertIn("file_operation_locks", source)
self.assertIn("def _get_file_operation_lock(file_id: str)", source)
self.assertIn("async with _get_file_operation_lock(file_id):", source)
self.assertIn("[Egress] waiting_for_file_lock", source)
self.assertNotIn("[Egress] waiting_for_ingest_global_lock", source)
self.assertNotIn("[Egress] acquired_ingest_global_lock", source)
self.assertIn("[IngestTask] waiting_for_file_lock", source)
self.assertIn("[IngestTask] waiting_for_ingest_global_lock", source)
if __name__ == "__main__":
unittest.main()