test_account.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. from yandex_music import Account
  2. class TestAccount:
  3. now = '2019-11-07T21:49:54+00:00'
  4. region = 149
  5. service_available = True
  6. uid = 1130000002804451
  7. login = 'Ilya@marshal.by'
  8. full_name = 'Семёнов Илья'
  9. second_name = 'Семёнов'
  10. first_name = 'Илья'
  11. display_name = 'Il`ya (Marshal)'
  12. hosted_user = False
  13. birthday = '1999-08-10'
  14. registered_at = '2018-06-10T09:34:22+00:00'
  15. has_info_for_app_metrica = False
  16. child = False
  17. def test_expected_values(self, account, passport_phone):
  18. assert account.now == self.now
  19. assert account.region == self.region
  20. assert account.service_available == self.service_available
  21. assert account.uid == self.uid
  22. assert account.login == self.login
  23. assert account.full_name == self.full_name
  24. assert account.second_name == self.second_name
  25. assert account.first_name == self.first_name
  26. assert account.display_name == self.display_name
  27. assert account.hosted_user == self.hosted_user
  28. assert account.birthday == self.birthday
  29. assert account.passport_phones == [passport_phone]
  30. assert account.registered_at == self.registered_at
  31. assert account.has_info_for_app_metrica == self.has_info_for_app_metrica
  32. assert account.child == self.child
  33. def test_de_json_none(self, client):
  34. assert Account.de_json({}, client) is None
  35. def test_de_json_required(self, client):
  36. json_dict = {'now': self.now, 'service_available': self.service_available, 'child': self.child}
  37. account = Account.de_json(json_dict, client)
  38. assert account.now == self.now
  39. assert account.service_available == self.service_available
  40. assert account.child == self.child
  41. def test_de_json_all(self, client, passport_phone):
  42. json_dict = {
  43. 'now': self.now,
  44. 'region': self.region,
  45. 'service_available': self.service_available,
  46. 'uid': self.uid,
  47. 'login': self.login,
  48. 'full_name': self.full_name,
  49. 'second_name': self.second_name,
  50. 'first_name': self.first_name,
  51. 'display_name': self.display_name,
  52. 'hosted_user': self.hosted_user,
  53. 'birthday': self.birthday,
  54. 'passport_phones': [passport_phone.to_dict()],
  55. 'registered_at': self.registered_at,
  56. 'has_info_for_app_metrica': self.has_info_for_app_metrica,
  57. 'child': self.child,
  58. }
  59. account = Account.de_json(json_dict, client)
  60. assert account.now == self.now
  61. assert account.region == self.region
  62. assert account.service_available == self.service_available
  63. assert account.uid == self.uid
  64. assert account.login == self.login
  65. assert account.full_name == self.full_name
  66. assert account.second_name == self.second_name
  67. assert account.first_name == self.first_name
  68. assert account.display_name == self.display_name
  69. assert account.hosted_user == self.hosted_user
  70. assert account.birthday == self.birthday
  71. assert account.passport_phones == [passport_phone]
  72. assert account.registered_at == self.registered_at
  73. assert account.has_info_for_app_metrica == self.has_info_for_app_metrica
  74. assert account.child == self.child
  75. def test_equality(self, user):
  76. a = Account(self.now, self.service_available, self.child)
  77. assert a != user
  78. assert hash(a) != hash(user)
  79. assert a is not user