From fe4a7b1622d87a3398a758d96864697ca90c0b5d Mon Sep 17 00:00:00 2001 From: phernandez Date: Mon, 2 Mar 2026 21:26:54 -0600 Subject: [PATCH] fix: update analytics test mocks for non-daemon thread change Thread constructor no longer receives daemon=True, update mock signatures to match. Also assert on the new "type": "event" field. Co-Authored-By: Claude Opus 4.6 Signed-off-by: phernandez --- tests/cli/test_analytics.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/cli/test_analytics.py b/tests/cli/test_analytics.py index b43c837c..056bb6f0 100644 --- a/tests/cli/test_analytics.py +++ b/tests/cli/test_analytics.py @@ -76,7 +76,7 @@ class TestTrack: captured_target = None - def fake_thread(target, daemon): + def fake_thread(target): nonlocal captured_target captured_target = target mock = MagicMock() @@ -103,7 +103,7 @@ class TestTrack: with patch("basic_memory.cli.analytics.urllib.request.urlopen", fake_urlopen): with patch("basic_memory.cli.analytics.threading.Thread") as mock_thread: # Capture the target function and call it directly - def run_target(target, daemon): + def run_target(target): target() # Execute synchronously return MagicMock() @@ -113,6 +113,7 @@ class TestTrack: assert captured_request is not None assert captured_request.full_url == "https://analytics.example.com/api/send" body = json.loads(captured_request.data) + assert body["type"] == "event" assert body["payload"]["name"] == "cli-cloud-login-started" assert body["payload"]["website"] == "test-site-id" assert body["payload"]["hostname"] == "cli.basicmemory.com" @@ -129,7 +130,7 @@ class TestTrack: with patch("basic_memory.cli.analytics.urllib.request.urlopen", fake_urlopen): with patch("basic_memory.cli.analytics.threading.Thread") as mock_thread: - def run_target(target, daemon): + def run_target(target): target() # Should not raise return MagicMock()