MCPcopy Create free account
hub / github.com/CJackHwang/AIstudioProxyAPI / test_calculate_usage_stats

Function test_calculate_usage_stats

tests/api_utils/test_utils_ext.py:36–50  ·  view source on GitHub ↗

Test token usage statistics calculation for messages and responses.

()

Source from the content-addressed store, hash-verified

34
35
36def test_calculate_usage_stats():
37 """Test token usage statistics calculation for messages and responses."""
38 messages = [
39 {"role": "user", "content": "hello"},
40 {"role": "assistant", "content": "hi"},
41 ]
42 response = "response"
43 reasoning = "reasoning"
44
45 stats = calculate_usage_stats(messages, response, reasoning)
46
47 assert "prompt_tokens" in stats
48 assert "completion_tokens" in stats
49 assert "total_tokens" in stats
50 assert stats["total_tokens"] == stats["prompt_tokens"] + stats["completion_tokens"]
51
52
53# --- validation.py tests ---

Callers

nothing calls this directly

Calls 1

calculate_usage_statsFunction · 0.90

Tested by

no test coverage detected