Skip to content

Comments

test: add coverage for OllamaLLM edge cases and tool conversion#2305

Merged
openminddev merged 2 commits intoOpenMind:mainfrom
goblin0xcrypto:test/ollama-llm-coverage-improvements
Feb 20, 2026
Merged

test: add coverage for OllamaLLM edge cases and tool conversion#2305
openminddev merged 2 commits intoOpenMind:mainfrom
goblin0xcrypto:test/ollama-llm-coverage-improvements

Conversation

@goblin0xcrypto
Copy link
Contributor

🧪 Improve Test Coverage for OllamaLLM

Summary

This PR adds additional test cases to improve code coverage for the OllamaLLM class, focusing on edge cases and previously untested functionality.

Changes

  • ✅ Add test for tool schema conversion with actual function schemas
  • ✅ Add test for JSON parsing error handling
  • ✅ Add test for base URL with trailing slash normalization
  • ✅ Add test for tool calls with string-formatted arguments

Test Cases Added

  1. test_convert_tools_with_schemas

    • Validates tool conversion logic when function schemas are present
    • Ensures proper Ollama format structure
  2. test_ask_json_parse_error

    • Tests resilience when API returns invalid JSON
    • Verifies graceful error handling
  3. test_base_url_trailing_slash

    • Confirms URL normalization removes trailing slashes
    • Ensures correct endpoint construction
  4. test_tool_calls_with_string_arguments

    • Tests handling of tool call arguments as JSON strings
    • Validates proper parsing and action conversion

Testing

All tests pass successfully:

pytest tests/test_ollama_llm.py -v

Coverage Impact

These additions increase test coverage for:

  • _convert_tools_to_ollama_format method
  • Error handling paths in ask method
  • Configuration initialization edge cases
  • Tool call argument parsing variations

@goblin0xcrypto goblin0xcrypto requested a review from a team as a code owner February 16, 2026 17:51
@github-actions github-actions bot added python Python code tests Test files labels Feb 16, 2026
@goblin0xcrypto
Copy link
Contributor Author

Hi @openminddev
It looks like the required checks are still pending because the workflows are awaiting approval.
Would you mind approving the workflows so the CI can run?
Thanks a lot!

@openminddev openminddev merged commit c6b528c into OpenMind:main Feb 20, 2026
5 checks passed
@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

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

Labels

python Python code tests Test files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants