test_artist_albums.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pytest
  2. from yandex_music import ArtistAlbums
  3. @pytest.fixture(scope='class')
  4. def artist_albums(album, pager):
  5. return ArtistAlbums([album], pager)
  6. class TestArtistAlbums:
  7. def test_expected_values(self, artist_albums, album, pager):
  8. assert artist_albums.albums == [album]
  9. assert artist_albums.pager == pager
  10. def test_de_json_none(self, client):
  11. assert ArtistAlbums.de_json({}, client) is None
  12. def test_de_json_required(self, client, album, pager):
  13. json_dict = {'albums': [album.to_dict()], 'pager': pager.to_dict()}
  14. artist_albums = ArtistAlbums.de_json(json_dict, client)
  15. assert artist_albums.albums == [album]
  16. assert artist_albums.pager == pager
  17. def test_de_json_all(self, client, album, pager):
  18. json_dict = {'albums': [album.to_dict()], 'pager': pager.to_dict()}
  19. artist_albums = ArtistAlbums.de_json(json_dict, client)
  20. assert artist_albums.albums == [album]
  21. assert artist_albums.pager == pager
  22. def test_equality(self, album, pager):
  23. a = ArtistAlbums([album], pager)
  24. b = ArtistAlbums([], pager)
  25. c = ArtistAlbums([album], pager)
  26. assert a != b
  27. assert hash(a) != hash(b)
  28. assert a is not b
  29. assert a == c
  30. def test_len(self, artist_albums):
  31. assert len(artist_albums) == len(artist_albums.albums)
  32. def test_getitem(self, artist_albums):
  33. assert artist_albums[0] == artist_albums.albums[0]
  34. def test_iter(self, artist_albums):
  35. assert list(artist_albums) == artist_albums.albums