test_invocation_info.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. from yandex_music import InvocationInfo
  2. class TestInvocationInfo:
  3. hostname = 'myt1-0261-c2e-msk-myt-music-st-e72-18274.gencfg-c.yandex.net'
  4. req_id = '1573172241066040-16981638052883278246'
  5. exec_duration_millis = 0
  6. def test_expected_values(self, invocation_info):
  7. assert invocation_info.hostname == self.hostname
  8. assert invocation_info.req_id == self.req_id
  9. assert invocation_info.exec_duration_millis == self.exec_duration_millis
  10. def test_de_json_none(self, client):
  11. assert InvocationInfo.de_json({}, client) is None
  12. def test_de_json_required(self, client):
  13. json_dict = {'hostname': self.hostname, 'req_id': self.req_id}
  14. invocation_info = InvocationInfo.de_json(json_dict, client)
  15. assert invocation_info.hostname == self.hostname
  16. assert invocation_info.req_id == self.req_id
  17. def test_de_json_all(self, client):
  18. json_dict = {
  19. 'hostname': self.hostname,
  20. 'req_id': self.req_id,
  21. 'exec_duration_millis': self.exec_duration_millis,
  22. }
  23. invocation_info = InvocationInfo.de_json(json_dict, client)
  24. assert invocation_info.hostname == self.hostname
  25. assert invocation_info.req_id == self.req_id
  26. assert invocation_info.exec_duration_millis == self.exec_duration_millis
  27. def test_equality(self):
  28. a = InvocationInfo(self.hostname, self.req_id)
  29. b = InvocationInfo('', self.req_id, 0)
  30. c = InvocationInfo(self.hostname, self.req_id, 20)
  31. assert a != b
  32. assert hash(a) != hash(b)
  33. assert a is not b
  34. assert a == c