test_generated_playlist.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. from yandex_music import GeneratedPlaylist
  2. class TestGeneratedPlaylist:
  3. type = 'playlistOfTheDay'
  4. ready = True
  5. notify = False
  6. description = []
  7. preview_description = 'Звучит по-вашему каждый день'
  8. def test_expected_values(self, generated_playlist, playlist):
  9. assert generated_playlist.type == self.type
  10. assert generated_playlist.ready == self.ready
  11. assert generated_playlist.notify == self.notify
  12. assert generated_playlist.data == playlist
  13. assert generated_playlist.description == self.description
  14. assert generated_playlist.preview_description == self.preview_description
  15. def test_de_json_none(self, client):
  16. assert GeneratedPlaylist.de_json({}, client) is None
  17. def test_de_list_none(self, client):
  18. assert GeneratedPlaylist.de_list([], client) == []
  19. def test_de_json_required(self, client, playlist):
  20. json_dict = {'type': self.type, 'ready': self.ready, 'notify': self.notify, 'data': playlist.to_dict()}
  21. generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
  22. assert generated_playlist.type == self.type
  23. assert generated_playlist.ready == self.ready
  24. assert generated_playlist.notify == self.notify
  25. assert generated_playlist.data == playlist
  26. def test_de_json_all(self, client, playlist):
  27. json_dict = {
  28. 'type': self.type,
  29. 'ready': self.ready,
  30. 'notify': self.notify,
  31. 'data': playlist.to_dict(),
  32. 'description': self.description,
  33. 'preview_description': self.preview_description,
  34. }
  35. generated_playlist = GeneratedPlaylist.de_json(json_dict, client)
  36. assert generated_playlist.type == self.type
  37. assert generated_playlist.ready == self.ready
  38. assert generated_playlist.notify == self.notify
  39. assert generated_playlist.data == playlist
  40. assert generated_playlist.description == self.description
  41. assert generated_playlist.preview_description == self.preview_description
  42. def test_equality(self, playlist):
  43. a = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
  44. b = GeneratedPlaylist(self.type, False, self.notify, None)
  45. c = GeneratedPlaylist(self.type, self.ready, self.notify, playlist)
  46. assert a != b
  47. assert hash(a) != hash(b)
  48. assert a is not b
  49. assert a == c