Skip to content

test(tools): add unit tests for clarify_tool.py#121

Merged
teknium1 merged 1 commit intoNousResearch:mainfrom
Bartok9:test-clarify-tool
Feb 28, 2026
Merged

test(tools): add unit tests for clarify_tool.py#121
teknium1 merged 1 commit intoNousResearch:mainfrom
Bartok9:test-clarify-tool

Conversation

@Bartok9
Copy link
Copy Markdown
Contributor

@Bartok9 Bartok9 commented Feb 27, 2026

Summary

Add comprehensive test coverage for the clarify_tool module that handles interactive clarifying questions.

Changes

  • Add tests/tools/test_clarify_tool.py with 20 unit tests

Test Coverage

TestClarifyToolBasics (5 tests)

  • Simple question with callback
  • Question with choices
  • Empty question returns error
  • Whitespace-only question returns error
  • No callback returns error

TestClarifyToolChoicesValidation (5 tests)

  • Choices trimmed to MAX_CHOICES (4)
  • Empty choices list becomes None
  • Whitespace-only choices stripped
  • Invalid choices type returns error
  • Non-string choices converted to strings

TestClarifyToolCallbackHandling (3 tests)

  • Callback exception returns error
  • Callback receives stripped question
  • User response is stripped

TestCheckClarifyRequirements (1 test)

  • Always returns True (no external deps)

TestClarifySchema (6 tests)

  • Schema name is 'clarify'
  • Schema has description
  • Question is required
  • Choices is optional
  • Choices has maxItems constraint
  • MAX_CHOICES constant is 4

Testing

uv run pytest tests/tools/test_clarify_tool.py -v
# 20 passed
Add comprehensive test coverage for the clarify_tool module:

- TestClarifyToolBasics: 5 tests for core functionality
  - Simple questions, questions with choices, error handling

- TestClarifyToolChoicesValidation: 5 tests for choices parameter
  - MAX_CHOICES enforcement, empty/whitespace handling, type conversion

- TestClarifyToolCallbackHandling: 3 tests for callback behavior
  - Exception handling, question/response trimming

- TestCheckClarifyRequirements: 1 test verifying always-true behavior

- TestClarifySchema: 6 tests verifying OpenAI function schema
  - Required/optional parameters, maxItems constraint

Total: 20 tests covering all public functions and edge cases.
@teknium1 teknium1 merged commit 0d2ac1c into NousResearch:main Feb 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants