test(tools): comprehensive test suite for web_search module (+31 tests) - #168
Open
manus-use wants to merge 1 commit into
Open
test(tools): comprehensive test suite for web_search module (+31 tests)#168manus-use wants to merge 1 commit into
manus-use wants to merge 1 commit into
Conversation
Add tests for the web_search module covering: SearchEngine base class (1 test): - Verifies NotImplementedError for abstract search method DuckDuckGoSearch (7 tests): - Async-to-sync delegation - Formatted result structure (href/link key variants) - Empty results handling - max_results parameter passing - Missing field defaults (empty strings) - ImportError when duckduckgo-search not installed GoogleSearch (6 tests): - Credential initialization - ValueError when API key or CX missing - Empty credentials rejection - Placeholder behavior with valid credentials get_search_engine factory (5 tests): - Config-driven engine selection (duckduckgo, google, unknown) - Direct config argument passing - Singleton caching behavior web_search_async (4 tests): - Success with formatted results - Custom max_results override - Config default max_results usage - Error returns Search Error result web_search sync tool (5 tests): - Direct _search_sync method usage - Custom max_results - Error handling returns error result - Fallback to async when no _search_sync method - Empty results Backward compatibility + structure (3 tests): - web_search_sync alias verification - Result keys (title, url, snippet) - Result value types (all strings) All tests 100% mocked — no real HTTP calls or search API usage.
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.
Summary
Comprehensive test suite for the
web_searchmodule (src/manus_agent/tools/web_search.py), which provides the web search capability used by the agent for information gathering.Test Coverage (31 tests)
SearchEnginebase class — 1 testsearch()raisesNotImplementedErrorDuckDuckGoSearch— 7 tests_search_synchref+linkkey variants)max_resultsparameter correctly passed to DDGSImportErrorraised whenduckduckgo-searchpackage not installedGoogleSearch— 6 testsValueErrorraised when API key or CX missingget_search_enginefactory — 5 tests"duckduckgo"→DuckDuckGoSearch"google"→GoogleSearchDuckDuckGoSearchconfigargument accepted (bypassesConfig.from_file())web_search_async— 4 testsmax_resultsoverride workstools.max_search_resultsas defaultweb_search(sync tool) — 5 tests_search_syncmethod when available (avoids event loop)max_resultspassed through_search_syncBackward compatibility + structure — 3 tests
web_search_syncis an alias forweb_searchtitle,url,snippet)Technical Notes
setup_methodFiles Changed
tests/test_web_search.py— new test file (31 tests)