MCPcopy
hub / github.com/Aider-AI/aider / test_analytics_event_logging

Function test_analytics_event_logging

tests/basic/test_analytics.py:60–79  ·  view source on GitHub ↗
(temp_analytics_file, temp_data_dir)

Source from the content-addressed store, hash-verified

58
59
60def test_analytics_event_logging(temp_analytics_file, temp_data_dir):
61 analytics = Analytics(logfile=temp_analytics_file)
62 analytics.asked_opt_in = True
63 analytics.enable()
64
65 test_event = "test_event"
66 test_properties = {"test_key": "test_value"}
67
68 # with patch.object(analytics.mp, "track") as mock_mp_track:
69 with patch.object(analytics.ph, "capture") as mock_ph_capture:
70 analytics.event(test_event, **test_properties)
71
72 # mock_mp_track.assert_called_once()
73 mock_ph_capture.assert_called_once()
74
75 # Verify logfile
76 with open(temp_analytics_file) as f:
77 log_entry = json.loads(f.read().strip())
78 assert log_entry["event"] == test_event
79 assert "test_key" in log_entry["properties"]
80
81
82def test_system_info(temp_data_dir):

Callers

nothing calls this directly

Calls 3

enableMethod · 0.95
eventMethod · 0.95
AnalyticsClass · 0.90

Tested by

no test coverage detected