Skip to content

Commit

Permalink
Add test for skipping accession numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
spolcyn committed Jun 20, 2024
1 parent c5d826c commit 378443c
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions tests/test_orchestrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,46 @@ def test_fetch_and_save_filings_given_paths_that_already_exist(
assert mock_save_document.call_count == 0


def test_fetch_and_save_filings_given_accession_numbers_to_skip(
user_agent, form_10k, apple_cik
):
limit = 2
download_metadata = DownloadMetadata(
download_folder=Path("."),
form=form_10k,
cik=apple_cik,
limit=limit,
after=DEFAULT_AFTER_DATE,
before=DEFAULT_BEFORE_DATE,
include_amends=False,
download_details=False,
accession_numbers_to_skip={"acc_num_0"},
)

to_download_list = [
ToDownload(
raw_filing_uri=f"raw_{i}",
primary_doc_uri=f"pd_{i}",
accession_number=f"acc_num_{i}",
details_doc_suffix=".xml",
)
for i in range(limit)
]

with patch(
"sec_edgar_downloader._orchestrator.aggregate_filings_to_download",
new=lambda x, y: to_download_list,
), patch(
"sec_edgar_downloader._orchestrator.download_filing", autospec=True
) as mock_download_filing, patch(
"sec_edgar_downloader._orchestrator.save_document", autospec=True
) as mock_save_document:
num_downloaded = fetch_and_save_filings(download_metadata, user_agent)

assert num_downloaded == 1
assert mock_download_filing.call_count == 1
assert mock_save_document.call_count == 1

def test_fetch_and_save_filings_given_exception(user_agent, form_10k, apple_cik):
limit = 2
download_metadata = DownloadMetadata(
Expand Down

0 comments on commit 378443c

Please sign in to comment.