fix(analyzer): route _analyze_company_safe through cache-aware path

_analyze_company_safe was calling SERP.query directly, bypassing the
SERP query cache in analyze_company. Now delegates fully to
analyze_company() and reads patent_count from the serp_queries cache.
This commit is contained in:
2026-03-24 15:02:19 -04:00
parent 6f0b448044
commit 9c971dac72
2 changed files with 10 additions and 4 deletions
+4 -1
View File
@@ -501,7 +501,7 @@ class TestBatchProcessing:
assert callback.call_count == 2
def test_company_analysis_result_structure(self, mocker):
def test_company_analysis_result_structure(self, mocker, mock_db):
"""Test CompanyAnalysisResult has correct structure."""
mock_query = mocker.patch("SPARC.analyzer.SERP.query")
mock_save = mocker.patch("SPARC.analyzer.SERP.save_patents")
@@ -512,6 +512,9 @@ class TestBatchProcessing:
patent = Patent(patent_id="US123", pdf_link="http://example.com/test.pdf")
mock_query.return_value = Patents(patents=[patent])
# Simulate DB caching: after store, subsequent get returns the IDs
mock_db.get_cached_serp_query.side_effect = [None, ["US123"]]
def save_side_effect(p):
p.pdf_path = "patents/US123.pdf"
return p