test_shot.py 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. from yandex_music import Shot
  2. class TestShot:
  3. order = 0
  4. played = False
  5. shot_id = '1036797'
  6. status = 'ready'
  7. def test_expected_values(self, shot, shot_data):
  8. assert shot.order == self.order
  9. assert shot.played == self.played
  10. assert shot.shot_id == self.shot_id
  11. assert shot.status == self.status
  12. assert shot.shot_data == shot_data
  13. def test_de_json_none(self, client):
  14. assert Shot.de_json({}, client) is None
  15. def test_de_list_none(self, client):
  16. assert Shot.de_list([], client) == []
  17. def test_de_json_required(self, client, shot_data):
  18. json_dict = {
  19. 'order': self.order,
  20. 'played': self.played,
  21. 'shot_id': self.shot_id,
  22. 'status': self.status,
  23. 'shot_data': shot_data.to_dict(),
  24. }
  25. shot = Shot.de_json(json_dict, client)
  26. assert shot.order == self.order
  27. assert shot.played == self.played
  28. assert shot.shot_id == self.shot_id
  29. assert shot.status == self.status
  30. assert shot.shot_data == shot_data
  31. def test_de_json_all(self, client, shot_data):
  32. json_dict = {
  33. 'order': self.order,
  34. 'played': self.played,
  35. 'shot_id': self.shot_id,
  36. 'status': self.status,
  37. 'shot_data': shot_data.to_dict(),
  38. }
  39. shot = Shot.de_json(json_dict, client)
  40. assert shot.order == self.order
  41. assert shot.played == self.played
  42. assert shot.shot_id == self.shot_id
  43. assert shot.status == self.status
  44. assert shot.shot_data == shot_data
  45. def test_equality(self, shot_data):
  46. a = Shot(self.order, self.played, shot_data, self.shot_id, self.status)
  47. b = Shot(self.order, True, shot_data, self.shot_id, self.status)
  48. c = Shot(self.order, self.played, shot_data, '10', self.status)
  49. d = Shot(self.order, self.played, shot_data, self.shot_id, self.status)
  50. assert a != b != c != d
  51. assert hash(a) != hash(b) != hash(c) != hash(d)
  52. assert a is not b is not c is not d
  53. assert a == d
  54. assert hash(a) == hash(d)