test_video.py 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. from yandex_music import Video
  2. class TestVideo:
  3. cover = 'https://avatars.mds.yandex.net/get-vh/1427422/10413967802532191922-QdZD9kEoIbQknQSxuy2zaQ-1557613291/%%'
  4. title = 'Back to Beautiful'
  5. embed_url = 'https://frontend.vh.yandex.ru/player/10413967802532191922?no_ad=true&from=ya-music'
  6. provider = 'yandex'
  7. provider_video_id = '10413967802532191922'
  8. youtube_url = None
  9. thumbnail_url = None
  10. duration = None
  11. text = None
  12. html_auto_play_video_player = None
  13. regions = None
  14. def test_expected_values(self, video):
  15. assert video.title == self.title
  16. assert video.cover == self.cover
  17. assert video.embed_url == self.embed_url
  18. assert video.provider == self.provider
  19. assert video.provider_video_id == self.provider_video_id
  20. assert video.youtube_url == self.youtube_url
  21. assert video.thumbnail_url == self.thumbnail_url
  22. assert video.duration == self.duration
  23. assert video.text == self.text
  24. assert video.html_auto_play_video_player == self.html_auto_play_video_player
  25. assert video.regions == self.regions
  26. def test_de_json_none(self, client):
  27. assert Video.de_json({}, client) is None
  28. def test_de_list_none(self, client):
  29. assert Video.de_list([], client) == []
  30. def test_de_json_required(self, client):
  31. json_dict = {'title': self.title}
  32. video = Video.de_json(json_dict, client)
  33. assert video.title == self.title
  34. def test_de_json_all(self, client):
  35. json_dict = {
  36. 'title': self.title,
  37. 'cover': self.cover,
  38. 'embed_url': self.embed_url,
  39. 'provider': self.provider,
  40. 'provider_video_id': self.provider_video_id,
  41. 'youtube_url': self.youtube_url,
  42. 'thumbnail_url': self.thumbnail_url,
  43. 'duration': self.duration,
  44. 'text': self.text,
  45. 'html_auto_play_video_player': self.html_auto_play_video_player,
  46. 'regions': self.regions,
  47. }
  48. video = Video.de_json(json_dict, client)
  49. assert video.title == self.title
  50. assert video.cover == self.cover
  51. assert video.embed_url == self.embed_url
  52. assert video.provider == self.provider
  53. assert video.provider_video_id == self.provider_video_id
  54. assert video.youtube_url == self.youtube_url
  55. assert video.thumbnail_url == self.thumbnail_url
  56. assert video.duration == self.duration
  57. assert video.text == self.text
  58. assert video.html_auto_play_video_player == self.html_auto_play_video_player
  59. assert video.regions == self.regions
  60. def test_equality(self):
  61. a = Video(self.title, '', provider_video_id=self.provider_video_id)
  62. b = Video('', self.cover, self.embed_url)
  63. c = Video(self.title, provider_video_id=self.provider_video_id)
  64. assert a != b
  65. assert hash(a) != hash(b)
  66. assert a is not b
  67. assert a == c