Skip to content

Commit f177fb5

Browse files
committed
Increase code coverage
1 parent 8d2ce62 commit f177fb5

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

aws-opentelemetry-distro/tests/amazon/opentelemetry/distro/patches/test_instrumentation_patch.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,22 @@ def _test_patched_extract_tool_calls(self):
689689
result = bedrock_utils.extract_tool_calls(message_with_string_content, True)
690690
self.assertIsNone(result)
691691

692+
# Test with toolUse format to exercise the for loop
693+
message_with_tool_use = {
694+
"role": "assistant",
695+
"content": [{"toolUse": {"toolUseId": "id1", "name": "func1"}}]
696+
}
697+
result = bedrock_utils.extract_tool_calls(message_with_tool_use, True)
698+
self.assertEqual(len(result), 1)
699+
700+
# Test with tool_use format to exercise the for loop
701+
message_with_type_tool_use = {
702+
"role": "assistant",
703+
"content": [{"type": "tool_use", "id": "id2", "name": "func2"}]
704+
}
705+
result = bedrock_utils.extract_tool_calls(message_with_type_tool_use, True)
706+
self.assertEqual(len(result), 1)
707+
692708
def _test_patched_process_anthropic_claude_chunk(
693709
self, input_value: Dict[str, str], expected_output: Dict[str, str]
694710
):
@@ -760,6 +776,11 @@ def _test_process_anthropic_claude_chunk(
760776
else:
761777
self.assertNotIn("input", tool_block)
762778

779+
# Just adding this to do basic sanity checks and increase code coverage
780+
wrapper._process_anthropic_claude_chunk({'type': 'content_block_delta', 'index': 0 })
781+
wrapper._process_anthropic_claude_chunk({ 'type': 'message_delta' })
782+
wrapper._process_anthropic_claude_chunk({ 'type': 'message_stop' })
783+
763784
def _test_patched_bedrock_agent_instrumentation(self):
764785
"""For bedrock-agent service, both extract_attributes and on_success provides attributes,
765786
the attributes depend on the API being invoked."""

0 commit comments

Comments
 (0)