Python: Added tests for OpenAI content types + Unit test improvement#3259
Merged
giles17 merged 4 commits intomicrosoft:mainfrom Jan 23, 2026
Merged
Python: Added tests for OpenAI content types + Unit test improvement#3259giles17 merged 4 commits intomicrosoft:mainfrom
giles17 merged 4 commits intomicrosoft:mainfrom
Conversation
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive unit tests for OpenAI content types across three test files, improving test coverage for various content handling scenarios in the agent framework's OpenAI clients.
Changes:
- Added 15+ new test cases for OpenAI Responses client covering content type preparation, parsing, response format handling, and edge cases
- Added 14+ new test cases for OpenAI Chat client covering reasoning content, approval content, usage content, refusal handling, and various edge cases
- Added 2 new test cases for OpenAI Assistants client covering code interpreter and MCP server tool call parsing
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| python/packages/core/tests/openai/test_openai_responses_client.py | Adds tests for FunctionApprovalResponseContent, ErrorContent, UsageContent, HostedVectorStoreContent, HostedFileContent, MCP server tool handling, response format validation, and conversation ID handling |
| python/packages/core/tests/openai/test_openai_chat_client.py | Adds tests for TextReasoningContent parsing/preparation, FunctionApprovalContent skipping, UsageContent in streaming, refusal handling, and various edge cases for options preparation |
| python/packages/core/tests/openai/test_openai_assistants_client.py | Adds tests for parsing code interpreter and MCP server tool calls from assistant run steps |
Comments suppressed due to low confidence (1)
python/packages/core/tests/openai/test_openai_responses_client.py:683
- Python tests do not follow the C# test guidelines for Arrange, Act, Assert comments. While this is acceptable for Python code, consider adding these comments for consistency and readability, especially in complex tests. However, since the custom coding guidelines specifically apply to C# unit tests and this is Python code, this is a minor observation rather than a requirement.
def test_prepare_content_for_openai_function_approval_response() -> None:
"""Test _prepare_content_for_openai with FunctionApprovalResponseContent."""
client = OpenAIResponsesClient(model_id="test-model", api_key="test-key")
# Test approved response
function_call = FunctionCallContent(
call_id="call_123",
name="send_email",
arguments='{"to": "user@example.com"}',
)
approval_response = FunctionApprovalResponseContent(
approved=True,
id="approval_001",
function_call=function_call,
)
result = client._prepare_content_for_openai(Role.ASSISTANT, approval_response, {})
assert result["type"] == "mcp_approval_response"
assert result["approval_request_id"] == "approval_001"
assert result["approve"] is True
python/packages/core/tests/openai/test_openai_responses_client.py
Outdated
Show resolved
Hide resolved
moonbox3
approved these changes
Jan 20, 2026
dmytrostruk
approved these changes
Jan 21, 2026
dmytrostruk
approved these changes
Jan 23, 2026
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
…icrosoft#3259) * added tests for content types+ unit test improvement * small fixes * small fix
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
This PR adds comprehensive unit tests for OpenAI content types across three test files, improving test coverage for various content handling scenarios in the agent framework's OpenAI clients.
Description
Contribution Checklist