MCPcopy Create free account
hub / github.com/modelscope/ms-agent / main

Method main

tests/tools/test_server_tools_smoke.py:109–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

107 def test_web_search_tool_smoke_no_network(self):
108
109 async def main():
110 with tempfile.TemporaryDirectory() as td:
111 cfg = _make_config(
112 td,
113 tools={
114 'web_search':
115 SimpleNamespace(
116 engines=['exa', 'serpapi', 'arxiv'],
117 exa_api_key='fake',
118 serpapi_api_key='fake',
119 serpapi_provider='google',
120 fetch_content=True,
121 enable_chunking=False,
122 max_results=3,
123 fetcher='jina_reader',
124 )
125 },
126 )
127
128 # Patch the engine/fetcher factories so connect() is deterministic and offline.
129 import ms_agent.tools.search.websearch_tool as wst
130
131 def _make_engine_cls(engine_type: str):
132 tool_name = {
133 'exa': 'exa_search',
134 'serpapi': 'serpapi_search',
135 'arxiv': 'arxiv_search',
136 }[engine_type]
137
138 class _E(_FakeSearchEngine):
139
140 @classmethod
141 def get_tool_definition(cls,
142 server_name: str = 'web_search'
143 ):
144 base = dict(super().get_tool_definition(
145 server_name=server_name))
146 base['tool_name'] = tool_name
147 base[
148 'description'] = f'Fake {engine_type} search (no network).'
149 return base
150
151 def search(self, search_request):
152 q = (search_request or {}).get('query', '')
153 return _FakeSearchResult([{
154 'url':
155 f'https://example.com/{engine_type}',
156 'title':
157 f'fake {engine_type} result for {q}',
158 'summary':
159 f'fake {engine_type} summary',
160 'published_date':
161 '2026-01-23',
162 }])
163
164 return _E
165
166 with patch.object(wst, 'get_search_engine_class',

Callers

nothing calls this directly

Calls 8

connectMethod · 0.95
call_toolMethod · 0.95
cleanupMethod · 0.95
WebSearchToolClass · 0.90
_make_configFunction · 0.85
_FakeContentFetcherClass · 0.85
getMethod · 0.80
get_toolsMethod · 0.45

Tested by

no test coverage detected