test_status.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. from yandex_music import Status
  2. class TestStatus:
  3. advertisement = 'Оформите постоянную подписку – первый месяц бесплатно!'
  4. cache_limit = 99
  5. subeditor = False
  6. subeditor_level = 0
  7. default_email = 'yandex_music@yandex.com'
  8. skips_per_hour = None
  9. station_exists = None
  10. premium_region = None
  11. experiment = 109
  12. pretrial_active = False
  13. userhash = '2a1d970ce4dadc3333280aa8727d1c41a380a7622521ecef67928cd4213adb8f'
  14. def test_expected_values(self, status, account, permissions, subscription, plus, alert):
  15. assert status.account == account
  16. assert status.permissions == permissions
  17. assert status.subscription == subscription
  18. assert status.advertisement == self.advertisement
  19. assert status.cache_limit == self.cache_limit
  20. assert status.subeditor == self.subeditor
  21. assert status.subeditor_level == self.subeditor_level
  22. assert status.plus == plus
  23. assert status.default_email == self.default_email
  24. assert status.skips_per_hour == self.skips_per_hour
  25. assert status.station_exists == self.station_exists
  26. assert status.bar_below == alert
  27. assert status.premium_region == self.premium_region
  28. assert status.experiment == self.experiment
  29. assert status.pretrial_active == self.pretrial_active
  30. assert status.userhash == self.userhash
  31. def test_de_json_none(self, client):
  32. assert Status.de_json({}, client) is None
  33. def test_de_json_required(self, client, account, permissions):
  34. json_dict = {'account': account.to_dict(), 'permissions': permissions.to_dict()}
  35. status = Status.de_json(json_dict, client)
  36. assert status.account == account
  37. assert status.permissions == permissions
  38. def test_de_json_all(self, client, account, permissions, subscription, plus, alert):
  39. json_dict = {
  40. 'account': account.to_dict(),
  41. 'permissions': permissions.to_dict(),
  42. 'subscription': subscription.to_dict(),
  43. 'cache_limit': self.cache_limit,
  44. 'subeditor': self.subeditor,
  45. 'subeditor_level': self.subeditor_level,
  46. 'plus': plus.to_dict(),
  47. 'default_email': self.default_email,
  48. 'skips_per_hour': self.skips_per_hour,
  49. 'station_exists': self.station_exists,
  50. 'premium_region': self.premium_region,
  51. 'advertisement': self.advertisement,
  52. 'bar_below': alert.to_dict(),
  53. 'experiment': self.experiment,
  54. 'pretrial_active': self.pretrial_active,
  55. 'userhash': self.userhash,
  56. }
  57. status = Status.de_json(json_dict, client)
  58. assert status.account == account
  59. assert status.permissions == permissions
  60. assert status.subscription == subscription
  61. assert status.advertisement == self.advertisement
  62. assert status.cache_limit == self.cache_limit
  63. assert status.subeditor == self.subeditor
  64. assert status.subeditor_level == self.subeditor_level
  65. assert status.plus == plus
  66. assert status.default_email == self.default_email
  67. assert status.skips_per_hour == self.skips_per_hour
  68. assert status.station_exists == self.station_exists
  69. assert status.bar_below == alert
  70. assert status.premium_region == self.premium_region
  71. assert status.experiment == self.experiment
  72. assert status.pretrial_active == self.pretrial_active
  73. assert status.userhash == self.userhash
  74. def test_equality(self, account, permissions, subscription):
  75. a = Status(account, permissions)
  76. b = Status(None, permissions)
  77. c = Status(account, permissions)
  78. assert a != b
  79. assert hash(a) != hash(b)
  80. assert a is not b
  81. assert a == c