* chore: dedupe src/search/cache.py into a re-export shim src/search/cache.py was a byte-identical copy of services/search/cache.py. Convert it to a sys.modules alias of the canonical services module (matching src/search/core.py, providers.py, ranking.py) so the two cannot drift, and add an identity assertion to test_search_module_consolidation.py. content.py and query.py are intentionally left as-is: the copies have drifted and services lacks fixes that src has, so they need services reconciled first before they can be shimmed safely. * chore: dedupe src/search content.py and query.py into shims Convert src/search/content.py and query.py to sys.modules aliases of the canonical services/search/* (matching cache.py, core.py, providers.py, ranking.py) so the duplicate copies cannot drift. Repoint the two tests that were coupled to the src-copy internals onto the canonical services surface (behaviour is equivalent): - test_src_search_query_nonstring.py: import services.search.query instead of loading the src file by path. - test_security_regressions.py::test_web_fetch_guard_blocks_redirect_into_private: mock httpx.get (services uses the module-level get, not httpx.Client) and assert on the canonical 'Blocked' message. Drop the now-redundant [src_content, service_content] parametrization in test_search_content_extraction_parity.py and test_search_content_url_guards.py (after the shim both params are the same object); add content/query identity assertions to test_search_module_consolidation.py.
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""Search consolidation regression tests.
|
|
|
|
``src.search`` is still a public import path for agent/deep-research code, but
|
|
core/provider behavior should come from the services.search implementation.
|
|
"""
|
|
|
|
import importlib
|
|
|
|
|
|
def test_src_search_core_aliases_services_core():
|
|
src_core = importlib.import_module("src.search.core")
|
|
service_core = importlib.import_module("services.search.core")
|
|
|
|
assert src_core is service_core
|
|
assert src_core.comprehensive_web_search is service_core.comprehensive_web_search
|
|
assert src_core.invalidate_search_cache is service_core.invalidate_search_cache
|
|
|
|
|
|
def test_src_search_providers_aliases_services_providers():
|
|
src_providers = importlib.import_module("src.search.providers")
|
|
service_providers = importlib.import_module("services.search.providers")
|
|
|
|
assert src_providers is service_providers
|
|
assert src_providers._resolve_ddg_redirect is service_providers._resolve_ddg_redirect
|
|
assert src_providers._safesearch_for is service_providers._safesearch_for
|
|
|
|
|
|
def test_src_search_package_exports_still_resolve():
|
|
import src.search as search
|
|
import services.search as service_search
|
|
|
|
assert search.comprehensive_web_search is service_search.comprehensive_web_search
|
|
assert search.searxng_search_results is service_search.searxng_search_results
|
|
assert search.searxng_search_api is service_search.searxng_search_api
|
|
assert search.PROVIDER_INFO is service_search.PROVIDER_INFO
|
|
|
|
|
|
def test_src_search_cache_content_query_alias_services():
|
|
for name in ("cache", "content", "query"):
|
|
src_mod = importlib.import_module(f"src.search.{name}")
|
|
svc_mod = importlib.import_module(f"services.search.{name}")
|
|
assert src_mod is svc_mod, f"src.search.{name} should alias services.search.{name}"
|