test_contest.py 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. from yandex_music import Contest
  2. class TestContest:
  3. contest_id = 'disco_contest'
  4. status = 'withdrew-moderator'
  5. can_edit = True
  6. sent = '2019-10-22T09:41:54+00:00'
  7. withdrawn = '2019-10-23T07:02:03+00:00'
  8. def test_expected_values(self, contest):
  9. assert contest.contest_id == self.contest_id
  10. assert contest.status == self.status
  11. assert contest.can_edit == self.can_edit
  12. assert contest.sent == self.sent
  13. assert contest.withdrawn == self.withdrawn
  14. def test_de_json_none(self, client):
  15. assert Contest.de_json({}, client) is None
  16. def test_de_json_required(self, client):
  17. json_dict = {'contest_id': self.contest_id, 'status': self.status, 'can_edit': self.can_edit}
  18. contest = Contest.de_json(json_dict, client)
  19. assert contest.contest_id == self.contest_id
  20. assert contest.status == self.status
  21. assert contest.can_edit == self.can_edit
  22. def test_de_json_all(self, client):
  23. json_dict = {
  24. 'contest_id': self.contest_id,
  25. 'status': self.status,
  26. 'can_edit': self.can_edit,
  27. 'sent': self.sent,
  28. 'withdrawn': self.withdrawn,
  29. }
  30. contest = Contest.de_json(json_dict, client)
  31. assert contest.contest_id == self.contest_id
  32. assert contest.status == self.status
  33. assert contest.can_edit == self.can_edit
  34. assert contest.sent == self.sent
  35. assert contest.withdrawn == self.withdrawn
  36. def test_equality(self):
  37. a = Contest(self.contest_id, self.status, self.can_edit)
  38. b = Contest('', self.status, self.can_edit)
  39. c = Contest(self.contest_id, self.status, self.can_edit)
  40. assert a != b
  41. assert hash(a) != hash(b)
  42. assert a is not b
  43. assert a == c