test_tag_result.py 1.2 KB

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