test_artist_tracks.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pytest
  2. from yandex_music import ArtistTracks
  3. @pytest.fixture(scope='class')
  4. def artist_tracks(track, pager):
  5. return ArtistTracks([track], pager)
  6. class TestArtistTracks:
  7. def test_expected_values(self, artist_tracks, track, pager):
  8. assert artist_tracks.tracks == [track]
  9. assert artist_tracks.pager == pager
  10. def test_de_json_none(self, client):
  11. assert ArtistTracks.de_json({}, client) is None
  12. def test_de_json_required(self, client, track, pager):
  13. json_dict = {'tracks': [track.to_dict()], 'pager': pager.to_dict()}
  14. artist_tracks = ArtistTracks.de_json(json_dict, client)
  15. assert artist_tracks.tracks == [track]
  16. assert artist_tracks.pager == pager
  17. def test_de_json_all(self, client, track, pager):
  18. json_dict = {'tracks': [track.to_dict()], 'pager': pager.to_dict()}
  19. artist_tracks = ArtistTracks.de_json(json_dict, client)
  20. assert artist_tracks.tracks == [track]
  21. assert artist_tracks.pager == pager
  22. def test_equality(self, track, pager):
  23. a = ArtistTracks([track], pager)
  24. b = ArtistTracks([], pager)
  25. c = ArtistTracks([track], 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_tracks):
  31. assert len(artist_tracks) == len(artist_tracks.tracks)
  32. def test_getitem(self, artist_tracks):
  33. assert artist_tracks[0] == artist_tracks.tracks[0]
  34. def test_iter(self, artist_tracks):
  35. assert list(artist_tracks) == artist_tracks.tracks