# -*- coding: utf-8 -*- import os from services.cache import MaterialCache, _extract_cache_key def test_cache_lock_acquire_release(tmp_path): cache = MaterialCache(cache_dir=str(tmp_path), enabled=True, max_size_gb=0) cache_key = _extract_cache_key("https://example.com/path/file.mp4?token=abc") lock_path = cache._acquire_lock(cache_key) assert lock_path assert os.path.exists(lock_path) cache._release_lock(lock_path) assert not os.path.exists(lock_path)