Skip to content

Commit fe4a7b1

Browse files
phernandezclaude
andcommitted
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 <noreply@anthropic.com> Signed-off-by: phernandez <paul@basicmachines.co>
1 parent 7d2012a commit fe4a7b1

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

tests/cli/test_analytics.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def test_sends_event_when_configured(self, monkeypatch):
7676

7777
captured_target = None
7878

79-
def fake_thread(target, daemon):
79+
def fake_thread(target):
8080
nonlocal captured_target
8181
captured_target = target
8282
mock = MagicMock()
@@ -103,7 +103,7 @@ def fake_urlopen(req, timeout=None):
103103
with patch("basic_memory.cli.analytics.urllib.request.urlopen", fake_urlopen):
104104
with patch("basic_memory.cli.analytics.threading.Thread") as mock_thread:
105105
# Capture the target function and call it directly
106-
def run_target(target, daemon):
106+
def run_target(target):
107107
target() # Execute synchronously
108108
return MagicMock()
109109

@@ -113,6 +113,7 @@ def run_target(target, daemon):
113113
assert captured_request is not None
114114
assert captured_request.full_url == "https://analytics.example.com/api/send"
115115
body = json.loads(captured_request.data)
116+
assert body["type"] == "event"
116117
assert body["payload"]["name"] == "cli-cloud-login-started"
117118
assert body["payload"]["website"] == "test-site-id"
118119
assert body["payload"]["hostname"] == "cli.basicmemory.com"
@@ -129,7 +130,7 @@ def fake_urlopen(req, timeout=None):
129130
with patch("basic_memory.cli.analytics.urllib.request.urlopen", fake_urlopen):
130131
with patch("basic_memory.cli.analytics.threading.Thread") as mock_thread:
131132

132-
def run_target(target, daemon):
133+
def run_target(target):
133134
target() # Should not raise
134135
return MagicMock()
135136

0 commit comments

Comments
 (0)