Skip to content

Commit 6840baa

Browse files
committed
fix: unit test failure
Change-Id: I371d749769371cfa12cc1a6e6c53fb4aef5d2097 Co-developed-by: Cursor <[email protected]>
1 parent 8ab753c commit 6840baa

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

instrumentation-loongsuite/loongsuite-instrumentation-google-adk/tests/test_vcr_integration.py

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import pytest
2424

25-
from opentelemetry import trace as trace_api
26-
2725
# Skip all VCR tests if google-adk is not installed
2826
pytest.importorskip("google.adk")
2927

@@ -46,13 +44,14 @@ async def test_llm_chat_with_content_capture(
4644
- Content capture (prompts and completions)
4745
- Finish reasons as array
4846
"""
49-
from google.adk.agents import LlmAgent
50-
from google.adk.models.lite_llm import LiteLlm
51-
from google.adk.runners import Runner
52-
from google.adk.sessions.in_memory_session_service import (
47+
# Import Google ADK dependencies (conditionally available)
48+
from google.adk.agents import LlmAgent # noqa: PLC0415
49+
from google.adk.models.lite_llm import LiteLlm # noqa: PLC0415
50+
from google.adk.runners import Runner # noqa: PLC0415
51+
from google.adk.sessions.in_memory_session_service import ( # noqa: PLC0415
5352
InMemorySessionService,
5453
)
55-
from google.genai import types
54+
from google.genai import types # noqa: PLC0415
5655

5756
# Create model
5857
model = LiteLlm(
@@ -86,7 +85,9 @@ async def test_llm_chat_with_content_capture(
8685
# Make API call (recorded by VCR on first run)
8786
user_message = types.Content(
8887
role="user",
89-
parts=[types.Part(text="What is 2+2? Answer with just the number.")],
88+
parts=[
89+
types.Part(text="What is 2+2? Answer with just the number.")
90+
],
9091
)
9192

9293
events = []
@@ -152,13 +153,14 @@ async def test_llm_chat_without_content_capture(
152153
153154
Validates that prompts and completions are NOT captured.
154155
"""
155-
from google.adk.agents import LlmAgent
156-
from google.adk.models.lite_llm import LiteLlm
157-
from google.adk.runners import Runner
158-
from google.adk.sessions.in_memory_session_service import (
156+
# Import Google ADK dependencies (conditionally available)
157+
from google.adk.agents import LlmAgent # noqa: PLC0415
158+
from google.adk.models.lite_llm import LiteLlm # noqa: PLC0415
159+
from google.adk.runners import Runner # noqa: PLC0415
160+
from google.adk.sessions.in_memory_session_service import ( # noqa: PLC0415
159161
InMemorySessionService,
160162
)
161-
from google.genai import types
163+
from google.genai import types # noqa: PLC0415
162164

163165
model = LiteLlm(
164166
model="dashscope/qwen-plus",
@@ -189,7 +191,9 @@ async def test_llm_chat_without_content_capture(
189191
user_message = types.Content(
190192
role="user",
191193
parts=[
192-
types.Part(text="This is sensitive data that should not be captured")
194+
types.Part(
195+
text="This is sensitive data that should not be captured"
196+
)
193197
],
194198
)
195199

@@ -246,13 +250,14 @@ async def test_metrics_recorded(
246250
- Positive token counts
247251
4. No non-standard attributes (callType, spanKind, session_id, user_id)
248252
"""
249-
from google.adk.agents import LlmAgent
250-
from google.adk.models.lite_llm import LiteLlm
251-
from google.adk.runners import Runner
252-
from google.adk.sessions.in_memory_session_service import (
253+
# Import Google ADK dependencies (conditionally available)
254+
from google.adk.agents import LlmAgent # noqa: PLC0415
255+
from google.adk.models.lite_llm import LiteLlm # noqa: PLC0415
256+
from google.adk.runners import Runner # noqa: PLC0415
257+
from google.adk.sessions.in_memory_session_service import ( # noqa: PLC0415
253258
InMemorySessionService,
254259
)
255-
from google.genai import types
260+
from google.genai import types # noqa: PLC0415
256261

257262
model = LiteLlm(
258263
model="dashscope/qwen-plus",
@@ -329,7 +334,9 @@ async def test_metrics_recorded(
329334
)
330335

331336
# ===== 5. 验证 operation.duration metric =====
332-
duration_metric = metrics_by_name["gen_ai.client.operation.duration"][0]
337+
duration_metric = metrics_by_name["gen_ai.client.operation.duration"][
338+
0
339+
]
333340
duration_points = list(duration_metric.data.data_points)
334341
assert len(duration_points) >= 1, (
335342
"Should have at least 1 duration data point"

0 commit comments

Comments
 (0)