Harden private search fallback and freshness handling
This commit is contained in:
@@ -39,6 +39,23 @@ class WebSearchMcpTests(unittest.TestCase):
|
||||
self.assertEqual(results, [])
|
||||
wikipedia.assert_not_called()
|
||||
|
||||
def test_empty_fresh_search_relaxes_once_and_marks_result(self) -> None:
|
||||
hit = {"title": "Current page", "url": "https://example.com/current"}
|
||||
with mock.patch.object(
|
||||
WEB,
|
||||
"general_discovery",
|
||||
side_effect=[([], []), ([hit], [])],
|
||||
) as discovery:
|
||||
result = WEB.web_search({
|
||||
"query": "current test release",
|
||||
"freshness": "week",
|
||||
"max_results": 3,
|
||||
})
|
||||
self.assertTrue(result["task_complete"])
|
||||
self.assertFalse(result["freshness_applied"])
|
||||
self.assertIn("unfiltered", result["backend_warning"])
|
||||
self.assertEqual(discovery.call_count, 2)
|
||||
|
||||
def test_related_search_budget_is_enforced(self) -> None:
|
||||
with mock.patch.object(WEB, "SEARCH_BUDGET_MAX_RELATED_CALLS", 2):
|
||||
self.assertTrue(WEB.consume_search_budget("latest Proper People video")[0])
|
||||
|
||||
Reference in New Issue
Block a user