-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_sessionlog.py
More file actions
56 lines (46 loc) · 1.69 KB
/
Copy pathtest_sessionlog.py
File metadata and controls
56 lines (46 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
"""Tests for parsing Copilot session events into metrics."""
from __future__ import annotations
from copilot_experiments.sessionlog import parse_metrics
def _events():
return [
{"type": "session.start", "timestamp": "2026-01-01T00:00:00.000Z", "data": {}},
{
"type": "session.model_change",
"timestamp": "2026-01-01T00:00:00.100Z",
"data": {"newModel": "gpt-5.2"},
},
{"type": "assistant.turn_start", "timestamp": "2026-01-01T00:00:00.200Z", "data": {}},
{
"type": "assistant.message",
"timestamp": "2026-01-01T00:00:00.500Z",
"data": {"text": "hi", "model": "gpt-5.2"},
},
{
"type": "tool.execution_complete",
"timestamp": "2026-01-01T00:00:00.800Z",
"data": {"success": True},
},
{
"type": "tool.execution_complete",
"timestamp": "2026-01-01T00:00:01.000Z",
"data": {"success": False},
},
{"type": "session.warning", "timestamp": "2026-01-01T00:00:01.100Z", "data": {}},
{"type": "assistant.turn_end", "timestamp": "2026-01-01T00:00:02.000Z", "data": {}},
]
def test_parse_metrics_counts():
m = parse_metrics(_events())
assert m.n_turns == 1
assert m.n_assistant_messages == 1
assert m.n_tool_calls == 2
assert m.n_tool_failures == 1
assert m.n_warnings == 1
assert "gpt-5.2" in m.models
def test_parse_metrics_duration():
m = parse_metrics(_events())
assert m.duration_s is not None
assert m.duration_s == 2.0
def test_parse_metrics_empty():
m = parse_metrics([])
assert m.n_turns == 0
assert m.duration_s is None