diff --git a/openverse_catalog/dags/providers/provider_api_scripts/science_museum.py b/openverse_catalog/dags/providers/provider_api_scripts/science_museum.py index 1c1aa9ae8..5a2f465e2 100644 --- a/openverse_catalog/dags/providers/provider_api_scripts/science_museum.py +++ b/openverse_catalog/dags/providers/provider_api_scripts/science_museum.py @@ -223,6 +223,9 @@ def _get_license(image_data) -> None | tuple[str, str]: return license_, version return None + def get_should_continue(self, response_json) -> bool: + return response_json.get("links", {}).get("next") is not None + def main(): logger.info("Begin: Science Museum data ingestion") diff --git a/tests/dags/providers/provider_api_scripts/test_science_museum.py b/tests/dags/providers/provider_api_scripts/test_science_museum.py index f9bb7d6a3..dd5a23b24 100644 --- a/tests/dags/providers/provider_api_scripts/test_science_museum.py +++ b/tests/dags/providers/provider_api_scripts/test_science_museum.py @@ -327,3 +327,15 @@ def test_handle_obj_data_none(object_data): actual_images = sm.get_record_data(object_data) assert actual_images is None + + +def test_get_should_continue(): + response_json = {"links": {"next": ""}} + + assert sm.get_should_continue(response_json) is True + + +def test_get_should_continue_last_page(): + response_json = {"links": {"next": None}} + + assert sm.get_should_continue(response_json) is False