Skip to content

Commit 82a6fc9

Browse files
committed
Increase code coverage
1 parent 8d2ce62 commit 82a6fc9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,19 @@ 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 = {"role": "assistant", "content": [{"toolUse": {"toolUseId": "id1", "name": "func1"}}]}
694+
result = bedrock_utils.extract_tool_calls(message_with_tool_use, True)
695+
self.assertEqual(len(result), 1)
696+
697+
# Test with tool_use format to exercise the for loop
698+
message_with_type_tool_use = {
699+
"role": "assistant",
700+
"content": [{"type": "tool_use", "id": "id2", "name": "func2"}],
701+
}
702+
result = bedrock_utils.extract_tool_calls(message_with_type_tool_use, True)
703+
self.assertEqual(len(result), 1)
704+
692705
def _test_patched_process_anthropic_claude_chunk(
693706
self, input_value: Dict[str, str], expected_output: Dict[str, str]
694707
):
@@ -760,6 +773,11 @@ def _test_process_anthropic_claude_chunk(
760773
else:
761774
self.assertNotIn("input", tool_block)
762775

776+
# Just adding this to do basic sanity checks and increase code coverage
777+
wrapper._process_anthropic_claude_chunk({"type": "content_block_delta", "index": 0})
778+
wrapper._process_anthropic_claude_chunk({"type": "message_delta"})
779+
wrapper._process_anthropic_claude_chunk({"type": "message_stop"})
780+
763781
def _test_patched_bedrock_agent_instrumentation(self):
764782
"""For bedrock-agent service, both extract_attributes and on_success provides attributes,
765783
the attributes depend on the API being invoked."""

0 commit comments

Comments
 (0)