2019-11-08 02:09:39 +09:00
|
|
|
from yandex_music import VideoSupplement
|
|
|
|
|
|
|
|
|
|
|
|
class TestVideoSupplement:
|
2019-11-08 04:52:26 +09:00
|
|
|
title = 'pyrokinesis - терновый венец эволюции'
|
|
|
|
provider = 'youtube'
|
|
|
|
provider_video_id = '2lAjWy3Rzco'
|
|
|
|
url = 'http://www.youtube.com/watch?v=2lAjWy3Rzco'
|
2019-11-08 02:09:39 +09:00
|
|
|
embed_url = None
|
2021-02-03 21:28:10 +09:00
|
|
|
embed = (
|
|
|
|
'<iframe src="//www.youtube.com/embed/2lAjWy3Rzco?autoplay=1&enablejsapi=1&wmode=opaque" '
|
|
|
|
'frameborder="0" scrolling="no" allowfullscreen="1" allow="autoplay; fullscreen; accelerometer; '
|
|
|
|
'gyroscope; picture-in-picture" aria-label="Video"></iframe> '
|
|
|
|
)
|
2019-11-08 04:52:26 +09:00
|
|
|
cover = 'https://avatars.mds.yandex.net/get-vthumb/467750/8b52265a71a894918440ede6d63e45b5/%%x%%'
|
2019-11-08 02:09:39 +09:00
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
def test_expected_values(self, video_supplement):
|
|
|
|
assert video_supplement.cover == self.cover
|
2019-11-08 02:09:39 +09:00
|
|
|
assert video_supplement.title == self.title
|
|
|
|
assert video_supplement.provider == self.provider
|
|
|
|
assert video_supplement.provider_video_id == self.provider_video_id
|
|
|
|
assert video_supplement.url == self.url
|
|
|
|
assert video_supplement.embed_url == self.embed_url
|
|
|
|
assert video_supplement.embed == self.embed
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert VideoSupplement.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert VideoSupplement.de_list({}, client) == []
|
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
def test_de_json_required(self, client):
|
2021-02-01 21:57:06 +09:00
|
|
|
json_dict = {'cover': self.cover, 'provider': self.provider}
|
2019-11-08 02:09:39 +09:00
|
|
|
video_supplement = VideoSupplement.de_json(json_dict, client)
|
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
assert video_supplement.cover == self.cover
|
2019-11-08 02:09:39 +09:00
|
|
|
assert video_supplement.provider == self.provider
|
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
def test_de_json_all(self, client):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'cover': self.cover,
|
|
|
|
'title': self.title,
|
|
|
|
'provider': self.provider,
|
|
|
|
'provider_video_id': self.provider_video_id,
|
|
|
|
'url': self.url,
|
|
|
|
'embed_url': self.embed_url,
|
|
|
|
'embed': self.embed,
|
|
|
|
}
|
2019-11-08 02:09:39 +09:00
|
|
|
video_supplement = VideoSupplement.de_json(json_dict, client)
|
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
assert video_supplement.cover == self.cover
|
2019-11-08 02:09:39 +09:00
|
|
|
assert video_supplement.title == self.title
|
|
|
|
assert video_supplement.provider == self.provider
|
|
|
|
assert video_supplement.provider_video_id == self.provider_video_id
|
|
|
|
assert video_supplement.url == self.url
|
|
|
|
assert video_supplement.embed_url == self.embed_url
|
|
|
|
assert video_supplement.embed == self.embed
|
|
|
|
|
|
|
|
def test_equality(self):
|
2021-02-01 21:57:06 +09:00
|
|
|
a = VideoSupplement(self.cover, self.provider, self.title, self.provider_video_id)
|
|
|
|
b = VideoSupplement(self.cover, self.provider, None, self.provider_video_id)
|
|
|
|
c = VideoSupplement(self.cover, self.provider, self.title, self.provider_video_id)
|
2019-11-08 04:52:26 +09:00
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert a == c
|