test_playlist_recommendations.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import pytest
  2. from yandex_music import PlaylistRecommendations
  3. @pytest.fixture(scope='class')
  4. def playlist_recommendations(track):
  5. return PlaylistRecommendations([track], TestPlaylistRecommendations.batch_id)
  6. class TestPlaylistRecommendations:
  7. batch_id = '1588835234913188-6341822935848536902'
  8. def test_expected_values(self, playlist_recommendations, track):
  9. assert playlist_recommendations.batch_id == self.batch_id
  10. assert playlist_recommendations.tracks == [track]
  11. def test_de_json_none(self, client):
  12. assert PlaylistRecommendations.de_json({}, client) is None
  13. def test_de_json_required(self, client, track):
  14. json_dict = {'tracks': [track.to_dict()]}
  15. playlist_recommendations = PlaylistRecommendations.de_json(json_dict, client)
  16. assert playlist_recommendations.tracks == [track]
  17. def test_de_json_all(self, client, track):
  18. json_dict = {'batch_id': self.batch_id, 'tracks': [track.to_dict()]}
  19. playlist_recommendations = PlaylistRecommendations.de_json(json_dict, client)
  20. assert playlist_recommendations.batch_id == self.batch_id
  21. assert playlist_recommendations.tracks == [track]
  22. def test_equality(self, track):
  23. a = PlaylistRecommendations([track])
  24. b = PlaylistRecommendations([])
  25. c = PlaylistRecommendations([track])
  26. assert a != b
  27. assert hash(a) != hash(b)
  28. assert a is not b
  29. assert a == c