test_operator.py 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. from yandex_music import Operator
  2. class TestOperator:
  3. product_id = 'bz.649'
  4. phone = '+998905555555'
  5. payment_regularity = 'Списание средств производится\nавтоматически каждый день'
  6. title = 'Maxsus taklif!'
  7. suspended = False
  8. def test_expected_values(self, operator, deactivation):
  9. assert operator.product_id == self.product_id
  10. assert operator.phone == self.phone
  11. assert operator.payment_regularity == self.payment_regularity
  12. assert operator.deactivation == [deactivation]
  13. assert operator.title == self.title
  14. assert operator.suspended == self.suspended
  15. def test_de_json_none(self, client):
  16. assert Operator.de_json({}, client) is None
  17. def test_de_list_none(self, client):
  18. assert Operator.de_list([], client) == []
  19. def test_de_json_required(self, client, deactivation):
  20. json_dict = {
  21. 'product_id': self.product_id,
  22. 'phone': self.phone,
  23. 'payment_regularity': self.payment_regularity,
  24. 'deactivation': [deactivation.to_dict()],
  25. 'title': self.title,
  26. 'suspended': self.suspended,
  27. }
  28. operator = Operator.de_json(json_dict, client)
  29. assert operator.product_id == self.product_id
  30. assert operator.phone == self.phone
  31. assert operator.payment_regularity == self.payment_regularity
  32. assert operator.deactivation == [deactivation]
  33. assert operator.title == self.title
  34. assert operator.suspended == self.suspended
  35. def test_de_json_all(self, client, deactivation):
  36. json_dict = {
  37. 'product_id': self.product_id,
  38. 'phone': self.phone,
  39. 'payment_regularity': self.payment_regularity,
  40. 'deactivation': [deactivation.to_dict()],
  41. 'title': self.title,
  42. 'suspended': self.suspended,
  43. }
  44. operator = Operator.de_json(json_dict, client)
  45. assert operator.product_id == self.product_id
  46. assert operator.phone == self.phone
  47. assert operator.payment_regularity == self.payment_regularity
  48. assert operator.deactivation == [deactivation]
  49. assert operator.title == self.title
  50. assert operator.suspended == self.suspended
  51. def test_equality(self, deactivation):
  52. a = Operator(self.product_id, self.phone, self.payment_regularity, [deactivation], self.title, self.suspended)
  53. b = Operator('', self.phone, self.payment_regularity, [deactivation], self.title, self.suspended)
  54. c = Operator(self.product_id, self.phone, self.payment_regularity, [deactivation], self.title, self.suspended)
  55. assert a != b
  56. assert hash(a) != hash(b)
  57. assert a is not b
  58. assert a == c