Test token usage statistics calculation for messages and responses.
()
| 34 | |
| 35 | |
| 36 | def 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 --- |
nothing calls this directly
no test coverage detected