test_video_supplement.py 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. from yandex_music import VideoSupplement
  2. class TestVideoSupplement:
  3. title = 'pyrokinesis - терновый венец эволюции'
  4. provider = 'youtube'
  5. provider_video_id = '2lAjWy3Rzco'
  6. url = 'http://www.youtube.com/watch?v=2lAjWy3Rzco'
  7. embed_url = None
  8. embed = (
  9. '<iframe src="//www.youtube.com/embed/2lAjWy3Rzco?autoplay=1&amp;enablejsapi=1&amp;wmode=opaque" '
  10. 'frameborder="0" scrolling="no" allowfullscreen="1" allow="autoplay; fullscreen; accelerometer; '
  11. 'gyroscope; picture-in-picture" aria-label="Video"></iframe> '
  12. )
  13. cover = 'https://avatars.mds.yandex.net/get-vthumb/467750/8b52265a71a894918440ede6d63e45b5/%%x%%'
  14. def test_expected_values(self, video_supplement):
  15. assert video_supplement.cover == self.cover
  16. assert video_supplement.title == self.title
  17. assert video_supplement.provider == self.provider
  18. assert video_supplement.provider_video_id == self.provider_video_id
  19. assert video_supplement.url == self.url
  20. assert video_supplement.embed_url == self.embed_url
  21. assert video_supplement.embed == self.embed
  22. def test_de_json_none(self, client):
  23. assert VideoSupplement.de_json({}, client) is None
  24. def test_de_list_none(self, client):
  25. assert VideoSupplement.de_list([], client) == []
  26. def test_de_json_required(self, client):
  27. json_dict = {'cover': self.cover, 'provider': self.provider}
  28. video_supplement = VideoSupplement.de_json(json_dict, client)
  29. assert video_supplement.cover == self.cover
  30. assert video_supplement.provider == self.provider
  31. def test_de_json_all(self, client):
  32. json_dict = {
  33. 'cover': self.cover,
  34. 'title': self.title,
  35. 'provider': self.provider,
  36. 'provider_video_id': self.provider_video_id,
  37. 'url': self.url,
  38. 'embed_url': self.embed_url,
  39. 'embed': self.embed,
  40. }
  41. video_supplement = VideoSupplement.de_json(json_dict, client)
  42. assert video_supplement.cover == self.cover
  43. assert video_supplement.title == self.title
  44. assert video_supplement.provider == self.provider
  45. assert video_supplement.provider_video_id == self.provider_video_id
  46. assert video_supplement.url == self.url
  47. assert video_supplement.embed_url == self.embed_url
  48. assert video_supplement.embed == self.embed
  49. def test_equality(self):
  50. a = VideoSupplement(self.cover, self.provider, self.title, self.provider_video_id)
  51. b = VideoSupplement(self.cover, self.provider, None, self.provider_video_id)
  52. c = VideoSupplement(self.cover, self.provider, self.title, self.provider_video_id)
  53. assert a != b
  54. assert hash(a) != hash(b)
  55. assert a is not b
  56. assert a == c