test_artist_event.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from yandex_music import ArtistEvent
  2. class TestArtistEvent:
  3. subscribed = True
  4. def test_expected_values(self, artist_event, artist, track):
  5. assert artist_event.artist == artist
  6. assert artist_event.tracks == [track]
  7. assert artist_event.similar_to_artists_from_history == [artist]
  8. assert artist_event.subscribed == self.subscribed
  9. def test_de_json_none(self, client):
  10. assert ArtistEvent.de_json({}, client) is None
  11. def test_de_list_none(self, client):
  12. assert ArtistEvent.de_list([], client) == []
  13. def test_de_json_required(self, client, artist, track):
  14. json_dict = {
  15. 'artist': artist.to_dict(),
  16. 'tracks': [track.to_dict()],
  17. 'similar_to_artists_from_history': [artist.to_dict()],
  18. }
  19. artist_event = ArtistEvent.de_json(json_dict, client)
  20. assert artist_event.artist == artist
  21. assert artist_event.tracks == [track]
  22. assert artist_event.similar_to_artists_from_history == [artist]
  23. def test_de_json_all(self, client, artist, track):
  24. json_dict = {
  25. 'artist': artist.to_dict(),
  26. 'tracks': [track.to_dict()],
  27. 'similar_to_artists_from_history': [artist.to_dict()],
  28. 'subscribed': self.subscribed,
  29. }
  30. artist_event = ArtistEvent.de_json(json_dict, client)
  31. assert artist_event.artist == artist
  32. assert artist_event.tracks == [track]
  33. assert artist_event.similar_to_artists_from_history == [artist]
  34. assert artist_event.subscribed == self.subscribed
  35. def test_equality(self, artist, track):
  36. a = ArtistEvent(artist, [track], [artist])
  37. b = ArtistEvent(None, [track], [artist])
  38. c = ArtistEvent(artist, [track], [artist])
  39. assert a != b
  40. assert hash(a) != hash(b)
  41. assert a is not b
  42. assert a == c