Openverse is a search engine for openly-licensed media. This monorepo includes all application code.
Patch Stocksnap tests that called out to external API (#628)
Madison Swain-Bowden4451ee03eef0
diff --git a/tests/dags/providers/provider_api_scripts/test_stocksnap.py b/tests/dags/providers/provider_api_scripts/test_stocksnap.pyindex 00ccba81f..cd3f58b69 100644--- a/tests/dags/providers/provider_api_scripts/test_stocksnap.py+++ b/tests/dags/providers/provider_api_scripts/test_stocksnap.py@@ -3,6 +3,7 @@ import loggingimport osfrom unittest.mock import patch+import pytestfrom common.licenses import get_license_infofrom common.loader import provider_details as provfrom common.storage.image import ImageStore@@ -30,6 +31,12 @@ def _get_resource_json(json_name):return resource_json[email protected](autouse=True)+def filesize_mock():+ with patch.object(stocksnap, "_get_filesize") as get_filesize_mock:+ yield get_filesize_mock++def test_get_media_type():expect_result = "image"actual_result = stocksnap.get_media_type(_get_resource_json("full_item.json"))@@ -172,12 +179,10 @@ def test_get_creator_data_returns_none_when_no_author():assert actual_creator_url is None-def test_get_record_data_handles_example_dict():- with open(os.path.join(RESOURCES, "full_item.json")) as f:- image_data = json.load(f)-- with patch.object(stocksnap, "_get_filesize", return_value=123456):- actual_image_info = stocksnap.get_record_data(image_data)+def test_get_record_data_handles_example_dict(filesize_mock):+ image_data = _get_resource_json("full_item.json")+ filesize_mock.return_value = 123456+ actual_image_info = stocksnap.get_record_data(image_data)image_url = "https://cdn.stocksnap.io/img-thumbs/960w/7VAQUG1X3B.jpg"expected_image_info = {"title": "Female Fitness",