fix(hooks): presence tests cross-platform — patch _presence_lock not fcntl (FPLAN-0289 P1)

Windows CI was red on f460cd5: the patch_flock fixture patched presence.fcntl,
which only exists on POSIX (msvcrt on win32), erroring all 16 presence-test
setups. Now patches the platform-agnostic _presence_lock context manager
(-> nullcontext per call) and skips the inherently-POSIX flock-acquire test on
win32. Dormant prod code unchanged.

705 tests pass, seedgo 100%. Fix by @hooks.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GFihce1oLtp6UDAPGryYSv
This commit is contained in:
AIOSAI
2026-06-29 14:16:02 -07:00
co-authored by Claude Opus 4.8
parent f460cd577e
commit 13983b614a
+6 -5
View File
@@ -1,6 +1,8 @@
"""Tests for the presence service module."""
import json
import sys
from contextlib import nullcontext
from unittest.mock import patch
import pytest
@@ -31,11 +33,9 @@ def patch_paths(presence_dir):
@pytest.fixture
def patch_flock():
"""Patch flock to be a no-op (avoid real file locking in tests)."""
with patch("aipass.hooks.apps.modules.presence.fcntl") as mock_fcntl:
mock_fcntl.LOCK_EX = 2
mock_fcntl.LOCK_UN = 8
yield mock_fcntl
"""Make the presence lock a no-op (avoid real file locking in tests)."""
with patch.object(presence, "_presence_lock", side_effect=lambda: nullcontext()):
yield
# ── claim tests ──────────────────────────────────────────────────────────
@@ -390,6 +390,7 @@ class TestLiveness:
class TestFileLocking:
@pytest.mark.skipif(sys.platform == "win32", reason="fcntl is POSIX-only")
def test_presence_lock_acquires_flock(self, patch_paths):
with patch("aipass.hooks.apps.modules.presence.fcntl") as mock_fcntl:
mock_fcntl.LOCK_EX = 2