test_queue_item.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import pytest
  2. from yandex_music import QueueItem
  3. @pytest.fixture(scope='class')
  4. def queue_item(context):
  5. return QueueItem(TestQueueItem.id_, context, TestQueueItem.modified)
  6. class TestQueueItem:
  7. id_ = '503646255:69814820'
  8. modified = '2020-06-20T13:29:09Z'
  9. def test_expected_values(self, queue_item, context):
  10. assert queue_item.id == self.id_
  11. assert queue_item.context == context
  12. assert queue_item.modified == self.modified
  13. def test_de_json_none(self, client):
  14. assert QueueItem.de_json({}, client) is None
  15. def test_de_list_none(self, client):
  16. assert QueueItem.de_list([], client) == []
  17. def test_de_json_required(self, client, context):
  18. json_dict = {'id': self.id_, 'context': context.to_dict(), 'modified': self.modified}
  19. queue_item = QueueItem.de_json(json_dict, client)
  20. assert queue_item.id == self.id_
  21. assert queue_item.context == context
  22. assert queue_item.modified == self.modified
  23. def test_de_json_all(self, client, context):
  24. json_dict = {'id': self.id_, 'context': context.to_dict(), 'modified': self.modified}
  25. queue_item = QueueItem.de_json(json_dict, client)
  26. assert queue_item.id == self.id_
  27. assert queue_item.context == context
  28. assert queue_item.modified == self.modified
  29. def test_equality(self, context):
  30. a = QueueItem(self.id_, context, self.modified)
  31. b = QueueItem('', context, self.modified)
  32. c = QueueItem(self.id_, context, self.modified)
  33. assert a != b
  34. assert hash(a) != hash(b)
  35. assert a is not b
  36. assert a == c