MCPcopy Create free account
hub / github.com/google/adk-python / test_to_attributes_full

Function test_to_attributes_full

tests/unittests/telemetry/test_token_usage.py:152–167  ·  view source on GitHub ↗

Tests to_attributes with all attributes present.

(
    usage_metadata: types.GenerateContentResponseUsageMetadata,
)

Source from the content-addressed store, hash-verified

150
151
152def test_to_attributes_full(
153 usage_metadata: types.GenerateContentResponseUsageMetadata,
154):
155 """Tests to_attributes with all attributes present."""
156 usage_metadata.prompt_token_count = 10
157 usage_metadata.tool_use_prompt_token_count = 5
158 usage_metadata.candidates_token_count = 20
159 usage_metadata.thoughts_token_count = 8
160 usage_metadata.cached_content_token_count = 100
161
162 token_usage = _token_usage.TokenUsage(usage_metadata)
163 attrs = token_usage.to_attributes()
164 assert attrs[_token_usage.GEN_AI_USAGE_INPUT_TOKENS] == 15
165 assert attrs[_token_usage.GEN_AI_USAGE_OUTPUT_TOKENS] == 28
166 assert attrs[_token_usage.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] == 100
167 assert attrs[_token_usage.GEN_AI_USAGE_REASONING_OUTPUT_TOKENS] == 8
168
169
170def test_to_attributes_partial(

Callers

nothing calls this directly

Calls 1

to_attributesMethod · 0.95

Tested by

no test coverage detected