Skip to content

Commit

Permalink
tests: create tests for Album endpoint
Browse files Browse the repository at this point in the history
* (tests): tests for `.album_image()` of `Album`
  • Loading branch information
nautics889 committed Feb 25, 2024
1 parent c0af464 commit 6cf0ba9
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/test_album.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from pyimgurapi.endpoints import Album
from pyimgurapi.utils import DynamicResponseData
from tests.utils import get_random_imgur_id


class TestAlbum:
Expand Down Expand Up @@ -46,3 +47,21 @@ def test_create(
assert description_fixture in urlopen_mock.call_args[0][0].data.decode(
"utf-8"
)

@patch("urllib.request.urlopen")
def test_get_album_image(self, urlopen_mock, imgur_image_get_200_response):
urlopen_mock.return_value = imgur_image_get_200_response
album_id = get_random_imgur_id()
image_id = (
imgur_image_get_200_response.json().get("data", {}).get("id")
)

album = Album()
res = album.album_image(album_id, image_id)

urlopen_mock.assert_called_once()
assert urlopen_mock.call_args[0][0].method == "GET"
assert f"album/{album_id}" in urlopen_mock.call_args[0][0].full_url
assert f"image/{image_id}" in urlopen_mock.call_args[0][0].full_url
assert isinstance(res, DynamicResponseData)
assert res.data.id == image_id

0 comments on commit 6cf0ba9

Please sign in to comment.