Skip to content

Commit

Permalink
Fixed image dimensions as floats
Browse files Browse the repository at this point in the history
  • Loading branch information
kingosticks committed Feb 29, 2024
1 parent 784fb1f commit b8d323d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mopidy_spotify/translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,6 @@ def web_to_track(web_track, bitrate=None, album=None):
def web_to_image(web_image):
return models.Image(
uri=web_image["url"],
height=web_image["height"],
width=web_image["width"],
height=int_or_none(web_image.get("height")),
width=int_or_none(web_image.get("width")),
)
14 changes: 14 additions & 0 deletions tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,10 +724,24 @@ def test_web_to_image():
assert image.width == 200


def test_web_to_image_no_dimensions():
data = {"height": 640, "url": "img://1/a"}

image = translator.web_to_image(data)

assert isinstance(image, models.Image)
assert image.uri == "img://1/a"
assert image.height == 640
assert image.width is None


@pytest.mark.parametrize(
"height,width",
[
(600, 400),
(600.0, 400.0),
("600", "400"),
("600.0", "400.0"),
],
)
def test_web_to_image_ints_might_be_floats(height, width):
Expand Down

0 comments on commit b8d323d

Please sign in to comment.