feat(system): fix: Python 3.10 mock.patch — add detector import to monitor/__init__.py + fix chroma_client module split in symbolic tests

Co-Authored-By: @devpulse <devpulse@aipass>
This commit is contained in:
AIOSAI
2026-04-26 01:08:45 -07:00
co-authored by @devpulse
parent bbb61540f3
commit a4e1244e56
2 changed files with 15 additions and 0 deletions
@@ -1,2 +1,6 @@
# Minimal __init__.py - handler independence pattern
# No exports - handlers import directly when needed
# Python 3.10 mock.patch compatibility — submodules must be importable as
# attributes for mock._dot_lookup to resolve dotted paths.
from . import detector # noqa: F401
@@ -1177,6 +1177,13 @@ class TestDeleteFragment:
s = _import_storage()
client = _mock_chroma_client()
# Re-import chroma_client so mock.patch and the code resolve to the
# same module object. The autouse fixture deletes it from sys.modules;
# on Python 3.10 mock._dot_lookup finds a stale parent attribute.
import importlib
importlib.import_module("aipass.memory.apps.handlers.symbolic.chroma_client")
with patch(
"aipass.memory.apps.handlers.symbolic.chroma_client.get_client",
return_value=client,
@@ -1193,6 +1200,10 @@ class TestDeleteFragment:
client = _mock_chroma_client()
client.get_or_create_collection.side_effect = RuntimeError("db locked")
import importlib
importlib.import_module("aipass.memory.apps.handlers.symbolic.chroma_client")
with patch(
"aipass.memory.apps.handlers.symbolic.chroma_client.get_client",
return_value=client,