Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
obulat committed May 10, 2023
1 parent 096d0bb commit d1c714b
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions catalog/dags/providers/provider_api_scripts/phylopic.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ def get_record_data(self, data: dict) -> dict | list[dict] | None:
if not (license_info := get_license_info(license_url)):
return None

title = data.get("self", {}).get("title")
creator, creator_url = self._get_creator(data.get("contributor", {}))
width, height = self._get_image_sizes(data)
title = links.get("self", {}).get("title")
creator, creator_url = self._get_creator(links.get("contributor", {}))
width, height = self._get_image_sizes(links)

return {
"license_info": license_info,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_get_record_data():
[
pytest.param(["owner"], id="owner-foreign_landing_url"),
pytest.param(["license"], id="license"),
pytest.param(["url_l", "url_m", "url_s"], id="url_x-image_url"),
pytest.param(["url_l", "url_m", "url_s"], id="url_x-url"),
pytest.param(["id"], id="id-foreign_identifier"),
],
)
Expand All @@ -197,7 +197,7 @@ def test_get_record_data_returns_none_when_missing_required_params(missing_param
[
pytest.param(["owner"], id="owner-foreign_landing_url"),
pytest.param(["license"], id="license"),
pytest.param(["url_l", "url_m", "url_s"], id="url_x-image_url"),
pytest.param(["url_l", "url_m", "url_s"], id="url_x-url"),
pytest.param(["id"], id="id-foreign_identifier"),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ def test_get_image_data(image_size, expected_height, expected_width, expected_fi
f"329745-{image_size}.jpg"
)

actual_image_url, actual_height, actual_width, actual_filesize = mv._get_image_data(
actual_url, actual_height, actual_width, actual_filesize = mv._get_image_data(
image_data
)

assert actual_image_url == expected_url
assert actual_url == expected_url
assert actual_height == expected_height
assert actual_width == expected_width
assert actual_filesize == expected_filesize
Expand All @@ -184,11 +184,11 @@ def test_get_image_data(image_size, expected_height, expected_width, expected_fi
def test_get_image_data_none():
image_data = {}

actual_image_url, actual_height, actual_width, actual_filesize = mv._get_image_data(
actual_url, actual_height, actual_width, actual_filesize = mv._get_image_data(
image_data
)

assert actual_image_url is None
assert actual_url is None
assert actual_height is None
assert actual_width is None
assert actual_filesize is None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def test_get_record_data_missing_required_params_returns_empty_list(
assert images == []


def test_get_record_data_missing_image_urls_returns_empty_dictionary():
def test_get_record_data_missing_urls_returns_empty_dictionary():
search_response = _get_resource_json("response_search_success.json")
result = search_response["nyplAPI"]["response"]["result"][0]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def test_get_record_data_returns_none_for_falsy_foreign_landing_url_and_multimed
"links": {"self": "link"},
"attributes": {"multimedia": [{"admin": {"uid": ""}}]},
},
# missing image_url
# missing url
{
"links": {"self": "link"},
"attributes": {"multimedia": [{"admin": {"uid": "fid"}}]},
Expand Down
4 changes: 2 additions & 2 deletions catalog/tests/dags/providers/provider_api_scripts/test_smk.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def test_get_record_data_returns_main_image():
"height": 5141,
"width": 3076,
"thumbnail_url": "https://iip-thumb.smk.dk/iiif/jp2/kks1615.tif.jp2/full/!1024,/0/default.jpg",
"image_url": "https://iip.smk.dk/iiif/jp2/kks1615.tif.jp2/full/!2048,/0/default.jpg",
"url": "https://iip.smk.dk/iiif/jp2/kks1615.tif.jp2/full/!2048,/0/default.jpg",
"license_info": CC0_SMK,
"meta_data": {
"collection": "Gammel bestand",
Expand All @@ -167,7 +167,7 @@ def test_get_record_data_returns_main_image():
pytest.param(["object_number"], id="falsy foreign_landing_url"),
pytest.param(["rights"], id="falsy license_info"),
# For items with iiif id, the image_url is constructed from it.
pytest.param(["image_native", "image_iiif_id"], id="falsy image_url"),
pytest.param(["image_native", "image_iiif_id"], id="falsy url"),
pytest.param(["id", "image_iiif_id"], id="falsy foreign_identifier"),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def test_get_record_data_returns_none_when_necessary_data_is_falsy(
assert actual_image_info is None


def test_get_record_data_returns_none_when_no_image_url(ingester):
def test_get_record_data_returns_none_when_no_url(ingester):
image_data = _get_resource_json("full_item.json")
image_data["_embedded"]["wp:featuredmedia"][0]["media_details"].pop("sizes")
actual_image_info = ingester.get_record_data(image_data)
Expand Down

0 comments on commit d1c714b

Please sign in to comment.