Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
ceholden committed Nov 22, 2024
1 parent 124d33c commit 83da57a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lambdas/link_fetcher/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ def _handler(
# Don't search again if we've fetched all of the totalResults to help prevent
# queries that exceed maximum offset (10,000)
if fetched_links == total_results:
print(f"Completed fetching {fetched_links}/{total_results} links for {query_date}. Exiting.")
print(
f"Completed fetching {fetched_links}/{total_results} links for {query_date}. Exiting."
)
break

search_results, _ = get_page_for_query_and_total_results(params)
Expand Down
6 changes: 3 additions & 3 deletions lambdas/link_fetcher/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ def generate_mock_responses_for_one_day(mock_search_response):

# Set totalResults to the number we're going to mock
total_results = (
len(search_response_2020_page1["features"]) +
len(search_response_2020_page2["features"]) +
len(search_response_2020_empty["features"])
len(search_response_2020_page1["features"])
+ len(search_response_2020_page2["features"])
+ len(search_response_2020_empty["features"])
)
search_response_2020_page1["properties"]["totalResults"] = total_results
search_response_2020_page2["properties"]["totalResults"] = total_results
Expand Down
8 changes: 6 additions & 2 deletions lambdas/link_fetcher/tests/test_link_fetcher_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,11 +577,14 @@ def test_that_link_fetcher_handler_doesnt_query_after_fetching_total_results(
search offset (10,000). See,
https://github.com/NASA-IMPACT/hls-sentinel2-downloader-serverless/issues/45
"""

class MockContext:
def get_remaining_time_in_millis(self) -> int:
return MIN_REMAINING_MILLIS

spy_get_page_for_query_and_total_results = mocker.spy(handler, "get_page_for_query_and_total_results")
spy_get_page_for_query_and_total_results = mocker.spy(
handler, "get_page_for_query_and_total_results"
)

result = _handler({"query_date": "2020-01-01"}, MockContext(), lambda: db_session)

Expand All @@ -591,6 +594,7 @@ def get_remaining_time_in_millis(self) -> int:
# Check our spy on get_page_for_query_and_total_results -> it should not have been
# called with index={totalResults} where `totalResults=10` from our mocked response
index_call_args = [
call.args[0]["index"] for call in spy_get_page_for_query_and_total_results.call_args_list
call.args[0]["index"]
for call in spy_get_page_for_query_and_total_results.call_args_list
]
assert 10 not in index_call_args

0 comments on commit 83da57a

Please sign in to comment.