test_price.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from yandex_music import Price
  2. class TestPrice:
  3. amount = 99
  4. currency = 'RUB'
  5. def test_expected_values(self, price):
  6. assert price.amount == self.amount
  7. assert price.currency == self.currency
  8. def test_de_json_none(self, client):
  9. assert Price.de_json({}, client) is None
  10. def test_de_json_required(self, client):
  11. json_dict = {'amount': self.amount, 'currency': self.currency}
  12. price = Price.de_json(json_dict, client)
  13. assert price.amount == self.amount
  14. assert price.currency == self.currency
  15. def test_de_json_all(self, client):
  16. json_dict = {'amount': self.amount, 'currency': self.currency}
  17. price = Price.de_json(json_dict, client)
  18. assert price.amount == self.amount
  19. assert price.currency == self.currency
  20. def test_equality(self):
  21. a = Price(self.amount, self.currency)
  22. b = Price(10, self.currency)
  23. c = Price(self.amount, 'USD')
  24. d = Price(self.amount, self.currency)
  25. assert a != b != c
  26. assert hash(a) != hash(b) != hash(c)
  27. assert a is not b is not c
  28. assert a == d