forked from 0xWheatyz/SPARC
Add test coverage for analyze_single_patent auto-download path #1661
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
SPARC/analyzer.pyanalyze_single_patent()was updated to automatically download a patent PDF from a cached metadata link when the file is not present on disk. The existing test intests/test_analyzer.pyonly covers the happy path wherepatents/{patent_id}.pdfalready exists on disk, and the error path whereparse_patent_pdfraisesFileNotFoundError. Neither test exercises the auto-download branch.What to do
Add two additional test cases to
TestCompanyAnalyzerintests/test_analyzer.py:Auto-download success path: patch
os.path.existsto returnFalse, provide a mockDatabaseClientthat returns a cached patent with apdf_url, patch the download function to succeed, verifyparse_patent_pdfis called with the downloaded path.Auto-download fallback failure: patch
os.path.existsto returnFalse, provide a mock DB that returns a patent with nopdf_url(or DB miss), verifyFileNotFoundError(or equivalent) is raised with a meaningful message.Acceptance criteria
pytest tests/ -vruff check tests/passes with no errorsRoadmap reference
Related to P2 "analyze_single_patent assumes local file path" — now fixed in code but untested auto-download branch.
PR #1662 has been created for this issue. Work was completed on branch and is ready for review.