test_play_counter.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from yandex_music import PlayCounter
  2. class TestPlayCounter:
  3. description = 'А вот и ответ на главный вопрос жизни, вселенной и всего такого'
  4. value = 42
  5. updated = True
  6. def test_expected_values(self, play_counter):
  7. assert play_counter.value == self.value
  8. assert play_counter.description == self.description
  9. assert play_counter.updated == self.updated
  10. def test_de_json_none(self, client):
  11. assert PlayCounter.de_json({}, client) is None
  12. def test_de_json_required(self, client):
  13. json_dict = {'value': self.value, 'description': self.description, 'updated': self.updated}
  14. play_counter = PlayCounter.de_json(json_dict, client)
  15. assert play_counter.value == self.value
  16. assert play_counter.description == self.description
  17. assert play_counter.updated == self.updated
  18. def test_de_json_all(self, client):
  19. json_dict = {'value': self.value, 'description': self.description, 'updated': self.updated}
  20. play_counter = PlayCounter.de_json(json_dict, client)
  21. assert play_counter.value == self.value
  22. assert play_counter.description == self.description
  23. assert play_counter.updated == self.updated
  24. def test_equality(self):
  25. a = PlayCounter(self.value, self.description, self.updated)
  26. b = PlayCounter(30, self.description, self.updated)
  27. c = PlayCounter(self.value, self.description, False)
  28. d = PlayCounter(self.value, self.description, self.updated)
  29. assert a != b != c
  30. assert hash(a) != hash(b) != hash(c)
  31. assert a is not b is not c
  32. assert a == d