test_station_result.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. from yandex_music import StationResult
  2. class TestStationResult:
  3. explanation = ''
  4. prerolls = []
  5. rup_title = 'Моя волна'
  6. rup_description = 'Волна подстраивается под жанр и\xa0вас. Слушайте только то, что\xa0нравится!'
  7. custom_name = "R'n'B"
  8. def test_expected_values(self, station_result, station, rotor_settings, ad_params):
  9. assert station_result.station == station
  10. assert station_result.settings == rotor_settings
  11. assert station_result.settings2 == rotor_settings
  12. assert station_result.ad_params == ad_params
  13. assert station_result.explanation == self.explanation
  14. assert station_result.prerolls == self.prerolls
  15. assert station_result.rup_title == self.rup_title
  16. assert station_result.rup_description == self.rup_description
  17. assert station_result.custom_name == self.custom_name
  18. def test_de_json_none(self, client):
  19. assert StationResult.de_json({}, client) is None
  20. def test_de_list_none(self, client):
  21. assert StationResult.de_list([], client) == []
  22. def test_de_json_required(self, client, station, rotor_settings, ad_params):
  23. json_dict = {
  24. 'station': station.to_dict(),
  25. 'settings': rotor_settings.to_dict(),
  26. 'settings2': rotor_settings.to_dict(),
  27. 'ad_params': ad_params.to_dict(),
  28. 'rup_title': self.rup_title,
  29. 'rup_description': self.rup_description,
  30. }
  31. station_result = StationResult.de_json(json_dict, client)
  32. assert station_result.station == station
  33. assert station_result.settings == rotor_settings
  34. assert station_result.settings2 == rotor_settings
  35. assert station_result.ad_params == ad_params
  36. assert station_result.rup_title == self.rup_title
  37. assert station_result.rup_description == self.rup_description
  38. def test_de_json_all(self, client, station, rotor_settings, ad_params):
  39. json_dict = {
  40. 'station': station.to_dict(),
  41. 'settings': rotor_settings.to_dict(),
  42. 'settings2': rotor_settings.to_dict(),
  43. 'ad_params': ad_params.to_dict(),
  44. 'explanation': self.explanation,
  45. 'prerolls': self.prerolls,
  46. 'rup_title': self.rup_title,
  47. 'rup_description': self.rup_description,
  48. 'custom_name': self.custom_name,
  49. }
  50. station_result = StationResult.de_json(json_dict, client)
  51. assert station_result.station == station
  52. assert station_result.settings == rotor_settings
  53. assert station_result.settings2 == rotor_settings
  54. assert station_result.ad_params == ad_params
  55. assert station_result.explanation == self.explanation
  56. assert station_result.prerolls == self.prerolls
  57. assert station_result.rup_title == self.rup_title
  58. assert station_result.rup_description == self.rup_description
  59. assert station_result.custom_name == self.custom_name
  60. def test_equality(self, station, rotor_settings, ad_params):
  61. a = StationResult(station, rotor_settings, rotor_settings, ad_params)
  62. b = StationResult(None, rotor_settings, rotor_settings, ad_params)
  63. c = StationResult(station, None, rotor_settings, ad_params)
  64. d = StationResult(station, rotor_settings, rotor_settings, ad_params)
  65. assert a != b != c
  66. assert hash(a) != hash(b) != hash(c)
  67. assert a is not b is not c
  68. assert a == d