mirror of
https://github.com/basicmachines-co/basic-memory
synced 2026-06-21 13:47:35 +00:00
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>
This commit is contained in:
@@ -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()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user