test_promo_code_status.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import pytest
  2. from yandex_music import PromoCodeStatus
  3. @pytest.fixture(scope='class')
  4. def promo_code_status(status):
  5. return PromoCodeStatus(TestPromoCodeStatus.status, TestPromoCodeStatus.status_desc, status)
  6. class TestPromoCodeStatus:
  7. status = 'user-temporary-banned'
  8. status_desc = 'You entered the wrong code more than 10 times. You will be able to continue in 24 hours.'
  9. def test_expected_values(self, promo_code_status, status):
  10. assert promo_code_status.status == self.status
  11. assert promo_code_status.status_desc == self.status_desc
  12. assert promo_code_status.account_status == status
  13. def test_de_json_none(self, client):
  14. assert PromoCodeStatus.de_json({}, client) is None
  15. def test_de_json_required(self, client, status):
  16. json_dict = {'status': self.status, 'status_desc': self.status_desc, 'account_status': status.to_dict()}
  17. promo_code_status = PromoCodeStatus.de_json(json_dict, client)
  18. assert promo_code_status.status == self.status
  19. assert promo_code_status.status_desc == self.status_desc
  20. assert promo_code_status.account_status == status
  21. def test_de_json_all(self, client, status):
  22. json_dict = {'status': self.status, 'status_desc': self.status_desc, 'account_status': status.to_dict()}
  23. promo_code_status = PromoCodeStatus.de_json(json_dict, client)
  24. assert promo_code_status.status == self.status
  25. assert promo_code_status.status_desc == self.status_desc
  26. assert promo_code_status.account_status == status
  27. def test_equality(self, status):
  28. a = PromoCodeStatus(self.status, self.status_desc, status)
  29. b = PromoCodeStatus(self.status, '', status)
  30. c = PromoCodeStatus(self.status, self.status_desc, status)
  31. assert a != b
  32. assert hash(a) != hash(b)
  33. assert a is not b
  34. assert a == c