-
Notifications
You must be signed in to change notification settings - Fork 8
Add comprehensive test coverage for AgenticModelClass #876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Minimum allowed line rate is |
- Created dummy_agentic_model.py with mock MCP clients and tools for testing - Created test_agentic_model.py with extensive test coverage including: * MCP connection pool management tests * Connection lifecycle and caching tests * Tool discovery and execution tests * Streaming and non-streaming mode tests * Error handling scenarios * Connection verification and cleanup tests * Token tracking tests * Integration tests for full workflows - Tests cover all major functionality mentioned in the review feedback Co-authored-by: luv-bansal <[email protected]>
- Added comprehensive module docstrings to test_agentic_model.py - Enhanced documentation in dummy_agentic_model.py - Documented all test coverage areas and key components Co-authored-by: luv-bansal <[email protected]>
- Remove flaky time.sleep() in test_connection_touch_updates_last_used - Clarify complex assertion in test_openai_transport_with_mcp_tools - Add documentation for _pool attribute in DummyAgenticModel Co-authored-by: luv-bansal <[email protected]>
|
@copilot fix |
- Applied ruff check --fix to both test files (179 issues fixed) - Applied ruff format to both test files - Removed unused imports - Fixed line length issues - Improved code formatting and whitespace Co-authored-by: luv-bansal <[email protected]>
|
@copilot Seeing below failures for some tests |
... Could you please share the complete error message? The comment appears to be cut off. I'll investigate the |
|
@copilot that's a complete logs |
Fixed the Future mock in test_create_connection to properly return the same Future instance each time __aenter__ is called. The previous implementation created a new Future on each call but only set the result on the first one, causing the await to hang or fail. Co-authored-by: luv-bansal <[email protected]>
The log appears to be truncated at the test name. This typically happens when a test hangs or times out. The fix in commit bcceca4 addresses the async mock issue that would cause The problem was that If you're still seeing this issue after bcceca4, could you check:
|
Added asyncio_mode = "auto" to pytest configuration to ensure proper handling of async tests. This prevents potential hanging or timeout issues with async tests by ensuring pytest-asyncio auto-detects and properly manages async fixtures and test functions. Co-authored-by: luv-bansal <[email protected]>
|
tests are failing |
Why
The
AgenticModelClassintroduced in PR #869 lacked test coverage. The repository has comprehensive tests for similar classes (e.g.,OpenAIModelClassintests/runners/test_openai_model.py), but the new agentic class had none.How
Added two files totaling 1,413 lines:
clarifai/runners/models/dummy_agentic_model.py(446 lines)tests/runners/test_agentic_model.py(967 lines)Coverage areas:
Code Quality Fixes:
test_create_connectionto properly handle Future instancesasyncio_mode = "auto"to pytest configuration inpyproject.tomlTests
All 38 tests use mocks to avoid external dependencies. No secrets required, CI-compatible. Follows patterns from
test_openai_model.py.Fixed async test issues:
__aenter__was creating new Future instances on each call instead of returning a pre-configured Future with result set, which was causing the test to hangNotes
Tests are marked with
@pytest.mark.asynciowhere appropriate but do not require@pytest.mark.requires_secrets, making them suitable for all CI environments including external PRs.The pytest-asyncio configuration (
asyncio_mode = "auto") ensures pytest-asyncio properly detects and manages async fixtures and test functions across the entire test suite.💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.