test_station.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. from yandex_music import Station
  2. class TestStation:
  3. name = 'На вашей волне'
  4. id_for_from = 'user-561231028'
  5. full_image_url = 'avatars.yandex.net/get-music-misc/30221/rotor-activity-sex-full-image-3sv6j/%%'
  6. mts_full_image_url = 'avatars.yandex.net/get-music-misc/2413828/rotor-activity-sex-mts-full-image-sYtDD/%%'
  7. def test_expected_values(self, station, id_, icon, restrictions):
  8. assert station.id == id_
  9. assert station.name == self.name
  10. assert station.icon == icon
  11. assert station.mts_icon == icon
  12. assert station.geocell_icon == icon
  13. assert station.id_for_from == self.id_for_from
  14. assert station.restrictions == restrictions
  15. assert station.restrictions2 == restrictions
  16. assert station.full_image_url == self.full_image_url
  17. assert station.mts_full_image_url == self.mts_full_image_url
  18. assert station.parent_id == id_
  19. def test_de_json_none(self, client):
  20. assert Station.de_json({}, client) is None
  21. def test_de_json_required(self, client, id_, icon, restrictions):
  22. json_dict = {
  23. 'id': id_.to_dict(),
  24. 'name': self.name,
  25. 'icon': icon.to_dict(),
  26. 'mts_icon': icon.to_dict(),
  27. 'geocell_icon': icon.to_dict(),
  28. 'id_for_from': self.id_for_from,
  29. 'restrictions': restrictions.to_dict(),
  30. 'restrictions2': restrictions.to_dict(),
  31. }
  32. station = Station.de_json(json_dict, client)
  33. assert station.id == id_
  34. assert station.name == self.name
  35. assert station.icon == icon
  36. assert station.mts_icon == icon
  37. assert station.geocell_icon == icon
  38. assert station.id_for_from == self.id_for_from
  39. assert station.restrictions == restrictions
  40. assert station.restrictions2 == restrictions
  41. def test_de_json_all(self, client, id_, icon, restrictions):
  42. json_dict = {
  43. 'id': id_.to_dict(),
  44. 'name': self.name,
  45. 'icon': icon.to_dict(),
  46. 'mts_icon': icon.to_dict(),
  47. 'geocell_icon': icon.to_dict(),
  48. 'id_for_from': self.id_for_from,
  49. 'restrictions': restrictions.to_dict(),
  50. 'restrictions2': restrictions.to_dict(),
  51. 'parent_id': id_.to_dict(),
  52. 'full_image_url': self.full_image_url,
  53. 'mts_full_image_url': self.mts_full_image_url,
  54. }
  55. station = Station.de_json(json_dict, client)
  56. assert station.id == id_
  57. assert station.name == self.name
  58. assert station.icon == icon
  59. assert station.mts_icon == icon
  60. assert station.geocell_icon == icon
  61. assert station.id_for_from == self.id_for_from
  62. assert station.restrictions == restrictions
  63. assert station.restrictions2 == restrictions
  64. assert station.full_image_url == self.full_image_url
  65. assert station.mts_full_image_url == self.mts_full_image_url
  66. assert station.parent_id == id_
  67. def test_equality(self, id_, icon, restrictions):
  68. a = Station(id_, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
  69. b = Station(id_, self.name, None, icon, icon, self.id_for_from, restrictions, restrictions)
  70. c = Station(id_, '', icon, icon, icon, self.id_for_from, restrictions, restrictions)
  71. d = Station(id_, self.name, icon, icon, icon, self.id_for_from, restrictions, restrictions)
  72. assert a != b != c
  73. assert hash(a) != hash(b) != hash(c)
  74. assert a is not b is not c
  75. assert a == d