Skip to content

Add comprehensive unit tests for UniversityPlugin and GeminiChatCompletionFactory#16

Open
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1760304381-unit-tests-university-gemini
Open

Add comprehensive unit tests for UniversityPlugin and GeminiChatCompletionFactory#16
devin-ai-integration[bot] wants to merge 2 commits intomainfrom
devin/1760304381-unit-tests-university-gemini

Conversation

@devin-ai-integration
Copy link

Description

This PR adds comprehensive isolated unit tests for two components in the teal-agents platform:

  • UniversityPlugin (from assistant-orchestrator example)
  • GeminiChatCompletionFactory (from sk-agents core)

All tests use mocked dependencies to ensure no external API calls are made during test execution.

Link to Devin run: https://app.devin.ai/sessions/cd405e0e45544468a117496c39d4e670
Requested by: Shawn Azman (@ShawnAzman)

Changes

Test Infrastructure

  • Created tests/conftest.py with shared pytest fixtures:
    • university_api_responses: Loads mock university API response data
    • mock_app_config: Mocked AppConfig for testing
    • mock_requests_response: Reusable mock response object
  • Added tests/fixtures/university_api_responses.json with realistic test data
  • Created tests/unit/ directory structure

UniversityPlugin Tests (19 tests)

  • Success paths: Valid searches by name and country
  • Error handling: Network failures, API errors, malformed JSON responses
  • Edge cases: Empty queries, special characters, empty results
  • Business logic: Result limits (10 for name search, 20 for country search)
  • URL construction: Parameter handling with name, country, both, and neither

GeminiChatCompletionFactory Tests (16 tests)

  • Initialization: Valid config, missing API key scenarios
  • Service creation: All supported Gemini models (1.5-flash, 1.5-pro, 1.0-pro, 2.0-flash-lite)
  • Model detection: Model type identification and structured output support
  • Error cases: Unsupported model handling
  • Integration: Default model behavior, custom service IDs, API key consistency

Test Results

  • Total tests: 35 (19 UniversityPlugin + 16 GeminiChatCompletionFactory)
  • Execution time: < 2 seconds
  • Lint status: All checks passed with ruff
  • Coverage: 100% for GeminiChatCompletionFactory

Type of Change

  • New feature (unit test coverage)
  • Bugfix
  • Refactor
  • Documentation
  • Other

Important Review Notes

⚠️ Path complexity: The UniversityPlugin tests use sys.path manipulation with a complex relative path to import from src/orchestrators/assistant-orchestrator/example/university/. This works but is fragile - consider whether:

  1. These tests should live in the assistant-orchestrator directory instead
  2. The UniversityPlugin should be moved to a more central location
  3. This cross-directory testing pattern is acceptable for the project

⚠️ Import suppression: Uses # noqa: E402 to suppress linting warnings about imports after sys.path modification - this is necessary but worth noting.

Review Checklist

Please verify:

  • No actual network calls are made during test execution (all external dependencies are properly mocked)
  • The path manipulation approach for UniversityPlugin is acceptable for this project structure
  • Test assertions are comprehensive enough for each scenario
  • Mock configurations accurately represent real component behavior
  • All edge cases mentioned in the task are covered

…etionFactory

- Create test infrastructure with fixtures and conftest.py
- Implement 19 unit tests for UniversityPlugin covering:
  * Successful searches and error handling
  * Network failures and malformed responses
  * Result limits (10 for name search, 20 for country search)
  * URL construction and parameter handling
- Implement 16 unit tests for GeminiChatCompletionFactory covering:
  * Factory initialization with valid/missing API keys
  * Service creation for all supported Gemini models
  * Model type detection and structured output support
  * Default model behavior and custom service IDs
- All tests are isolated with no external dependencies
- Total execution time: <2 seconds for 35 tests
- 100% coverage for GeminiChatCompletionFactory
- All tests pass lint checks with ruff
@devin-ai-integration
Copy link
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant