2019-11-08 02:09:39 +09:00
|
|
|
|
from yandex_music import Playlist
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestPlaylist:
|
2019-11-10 03:11:43 +09:00
|
|
|
|
uid = 503646255
|
|
|
|
|
kind = 69814820
|
|
|
|
|
title = 'Плейлист дня'
|
|
|
|
|
track_count = 57
|
|
|
|
|
tags = []
|
|
|
|
|
revision = 0
|
|
|
|
|
snapshot = 1
|
|
|
|
|
visibility = 'public'
|
|
|
|
|
collective = False
|
2020-06-06 18:37:03 +09:00
|
|
|
|
url_part = 'daily'
|
2019-11-10 03:11:43 +09:00
|
|
|
|
created = '2018-04-29T21:00:00+00:00'
|
|
|
|
|
modified = '2019-11-09T03:00:00+00:00'
|
|
|
|
|
available = True
|
|
|
|
|
is_banner = False
|
|
|
|
|
is_premiere = False
|
|
|
|
|
duration_ms = 12402690
|
|
|
|
|
og_image = 'avatars.yandex.net/get-music-user-playlist/38125/q0ahkhfQE3neTk/%%?1572609906461'
|
2020-06-06 18:37:03 +09:00
|
|
|
|
og_title = 'Плейлист дня'
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
og_description = 'Слушайте с пользой: подкасты, которые могут вам понравиться'
|
2020-06-06 18:37:03 +09:00
|
|
|
|
image = ''
|
|
|
|
|
background_color = ''
|
|
|
|
|
text_color = ''
|
|
|
|
|
id_for_from = 'playlist_of_the_day'
|
2019-11-10 03:11:43 +09:00
|
|
|
|
prerolls = []
|
|
|
|
|
likes_count = 1
|
|
|
|
|
generated_playlist_type = 'playlistOfTheDay'
|
|
|
|
|
animated_cover_uri = 'avatars.yandex.net/get-music-user-playlist/30088/q0ahjvoZK5FT4A/%%'
|
|
|
|
|
ever_played = True
|
|
|
|
|
description = 'Каждый день — новый. Каждый день — ваш!'
|
|
|
|
|
description_formatted = 'Каждый день — новый. Каждый день — ваш!'
|
2019-11-08 02:09:39 +09:00
|
|
|
|
is_for_from = None
|
|
|
|
|
regions = None
|
|
|
|
|
|
2020-06-06 18:37:03 +09:00
|
|
|
|
def test_expected_values(self, playlist, user, cover, made_for, track_short, play_counter, playlist_absence,
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
playlist_without_nested_playlists, artist):
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.owner == user
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.uid == self.uid
|
|
|
|
|
assert playlist.kind == self.kind
|
|
|
|
|
assert playlist.title == self.title
|
|
|
|
|
assert playlist.track_count == self.track_count
|
|
|
|
|
assert playlist.cover == cover
|
|
|
|
|
assert playlist.made_for == made_for
|
|
|
|
|
assert playlist.play_counter == play_counter
|
2019-11-24 08:23:24 +09:00
|
|
|
|
assert playlist.playlist_absence == playlist_absence
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.tags == self.tags
|
|
|
|
|
assert playlist.revision == self.revision
|
|
|
|
|
assert playlist.snapshot == self.snapshot
|
|
|
|
|
assert playlist.visibility == self.visibility
|
|
|
|
|
assert playlist.collective == self.collective
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.url_part == self.url_part
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.created == self.created
|
|
|
|
|
assert playlist.modified == self.modified
|
|
|
|
|
assert playlist.available == self.available
|
|
|
|
|
assert playlist.is_banner == self.is_banner
|
|
|
|
|
assert playlist.is_premiere == self.is_premiere
|
|
|
|
|
assert playlist.duration_ms == self.duration_ms
|
|
|
|
|
assert playlist.og_image == self.og_image
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.og_title == self.og_title
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
assert playlist.og_description == self.og_description
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.image == self.image
|
|
|
|
|
assert playlist.cover_without_text == cover
|
|
|
|
|
assert playlist.background_color == self.background_color
|
|
|
|
|
assert playlist.text_color == self.text_color
|
|
|
|
|
assert playlist.id_for_from == self.id_for_from
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
assert playlist.top_artist == [artist]
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.tracks == [track_short]
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.prerolls == self.prerolls
|
|
|
|
|
assert playlist.likes_count == self.likes_count
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.similar_playlists == [playlist_without_nested_playlists]
|
|
|
|
|
assert playlist.last_owner_playlists == [playlist_without_nested_playlists]
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.generated_playlist_type == self.generated_playlist_type
|
|
|
|
|
assert playlist.animated_cover_uri == self.animated_cover_uri
|
|
|
|
|
assert playlist.ever_played == self.ever_played
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.description == self.description
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.description_formatted == self.description_formatted
|
|
|
|
|
assert playlist.is_for_from == self.is_for_from
|
|
|
|
|
assert playlist.regions == self.regions
|
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
|
def test_de_json_none(self, client):
|
|
|
|
|
assert Playlist.de_json({}, client) is None
|
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
|
def test_de_list_none(self, client):
|
|
|
|
|
assert Playlist.de_list({}, client) == []
|
|
|
|
|
|
2019-11-24 08:23:24 +09:00
|
|
|
|
def test_de_json_required(self, client, user, cover, made_for, play_counter, playlist_absence):
|
2020-06-06 18:37:03 +09:00
|
|
|
|
json_dict = {'owner': user.to_dict(), 'cover': cover.to_dict(), 'made_for': made_for.to_dict(),
|
2019-11-24 08:23:24 +09:00
|
|
|
|
'play_counter': play_counter.to_dict(), 'playlist_absence': playlist_absence.to_dict()}
|
2019-11-08 02:09:39 +09:00
|
|
|
|
playlist = Playlist.de_json(json_dict, client)
|
|
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.owner == user
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.cover == cover
|
|
|
|
|
assert playlist.made_for == made_for
|
|
|
|
|
assert playlist.play_counter == play_counter
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.playlist_absence == playlist_absence
|
2019-11-08 02:09:39 +09:00
|
|
|
|
|
2020-06-06 18:37:03 +09:00
|
|
|
|
def test_de_json_all(self, client, user, cover, made_for, track_short, play_counter, playlist_absence,
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
playlist_without_nested_playlists, artist):
|
2019-11-10 03:11:43 +09:00
|
|
|
|
json_dict = {'owner': user.to_dict(), 'uid': self.uid, 'kind': self.kind, 'title': self.title,
|
|
|
|
|
'track_count': self.track_count, 'cover': cover.to_dict(), 'made_for': made_for.to_dict(),
|
2019-11-24 08:23:24 +09:00
|
|
|
|
'play_counter': play_counter.to_dict(), 'playlist_absence': playlist_absence.to_dict(),
|
|
|
|
|
'tags': self.tags, 'revision': self.revision, 'snapshot': self.snapshot,
|
|
|
|
|
'visibility': self.visibility, 'collective': self.collective, 'created': self.created,
|
|
|
|
|
'modified': self.modified, 'available': self.available, 'is_banner': self.is_banner,
|
|
|
|
|
'is_premiere': self.is_premiere, 'duration_ms': self.duration_ms, 'og_image': self.og_image,
|
|
|
|
|
'tracks': [track_short.to_dict()], 'prerolls': self.prerolls, 'likes_count': self.likes_count,
|
2020-06-06 18:37:03 +09:00
|
|
|
|
'generated_playlist_type': self.generated_playlist_type, 'url_part': self.url_part,
|
2019-11-08 02:09:39 +09:00
|
|
|
|
'animated_cover_uri': self.animated_cover_uri, 'ever_played': self.ever_played,
|
2019-11-10 03:11:43 +09:00
|
|
|
|
'description': self.description, 'description_formatted': self.description_formatted,
|
2020-06-06 18:37:03 +09:00
|
|
|
|
'is_for_from': self.is_for_from, 'regions': self.regions, 'og_title': self.og_title,
|
|
|
|
|
'image': self.image, 'id_for_from': self.id_for_from, 'background_color': self.background_color,
|
|
|
|
|
'text_color': self.text_color, 'cover_without_text': cover.to_dict(),
|
|
|
|
|
'similar_playlists': [playlist_without_nested_playlists.to_dict()],
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
'last_owner_playlists': [playlist_without_nested_playlists.to_dict()],
|
|
|
|
|
'og_description': self.og_description, 'top_artist': [artist.to_dict()]}
|
2019-11-08 02:09:39 +09:00
|
|
|
|
playlist = Playlist.de_json(json_dict, client)
|
|
|
|
|
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.owner == user
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.uid == self.uid
|
|
|
|
|
assert playlist.kind == self.kind
|
|
|
|
|
assert playlist.title == self.title
|
|
|
|
|
assert playlist.track_count == self.track_count
|
|
|
|
|
assert playlist.cover == cover
|
|
|
|
|
assert playlist.made_for == made_for
|
|
|
|
|
assert playlist.play_counter == play_counter
|
2019-11-24 08:23:24 +09:00
|
|
|
|
assert playlist.playlist_absence == playlist_absence
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.tags == self.tags
|
|
|
|
|
assert playlist.revision == self.revision
|
|
|
|
|
assert playlist.snapshot == self.snapshot
|
|
|
|
|
assert playlist.visibility == self.visibility
|
|
|
|
|
assert playlist.collective == self.collective
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.url_part == self.url_part
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.created == self.created
|
|
|
|
|
assert playlist.modified == self.modified
|
|
|
|
|
assert playlist.available == self.available
|
|
|
|
|
assert playlist.is_banner == self.is_banner
|
|
|
|
|
assert playlist.is_premiere == self.is_premiere
|
|
|
|
|
assert playlist.duration_ms == self.duration_ms
|
|
|
|
|
assert playlist.og_image == self.og_image
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.og_title == self.og_title
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
assert playlist.og_description == self.og_description
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.image == self.image
|
|
|
|
|
assert playlist.cover_without_text == cover
|
|
|
|
|
assert playlist.background_color == self.background_color
|
|
|
|
|
assert playlist.text_color == self.text_color
|
|
|
|
|
assert playlist.id_for_from == self.id_for_from
|
Добавлен новый класс LicenceTextPart.
Поля cheapest, title, family_sub, fb_image, fb_name, family, intro_period_duration, intro_price, start_period_duration, start_price, licence_text_parts для Product.
Поля storage_dir, duplicates для Album.
Поле subscribed для ArtistEvent.
Поле description для GeneratedPlaylist.
Поле genre для Event.
Поле show_in_regions для Genre.
Поле cover_uri для MixLink.
Поля og_description, top_artist для Playlist.
Поля full_image_url, mts_full_image_url для Station.
Документация и тесты к новым поля. #339
2020-06-07 05:48:32 +09:00
|
|
|
|
assert playlist.top_artist == [artist]
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.tracks == [track_short]
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.prerolls == self.prerolls
|
|
|
|
|
assert playlist.likes_count == self.likes_count
|
2020-06-06 18:37:03 +09:00
|
|
|
|
assert playlist.similar_playlists == [playlist_without_nested_playlists]
|
|
|
|
|
assert playlist.last_owner_playlists == [playlist_without_nested_playlists]
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.generated_playlist_type == self.generated_playlist_type
|
|
|
|
|
assert playlist.animated_cover_uri == self.animated_cover_uri
|
|
|
|
|
assert playlist.ever_played == self.ever_played
|
2019-11-10 03:11:43 +09:00
|
|
|
|
assert playlist.description == self.description
|
2019-11-08 02:09:39 +09:00
|
|
|
|
assert playlist.description_formatted == self.description_formatted
|
|
|
|
|
assert playlist.is_for_from == self.is_for_from
|
|
|
|
|
assert playlist.regions == self.regions
|
|
|
|
|
|
2019-11-24 08:23:24 +09:00
|
|
|
|
def test_equality(self, user, cover, made_for, play_counter, playlist_absence):
|
|
|
|
|
a = Playlist(user, cover, made_for, play_counter, playlist_absence)
|
|
|
|
|
b = Playlist(user, cover, made_for, play_counter, None)
|
|
|
|
|
c = Playlist(user, None, made_for, play_counter, playlist_absence)
|
|
|
|
|
d = Playlist(user, cover, made_for, play_counter, playlist_absence)
|
2019-11-10 03:11:43 +09:00
|
|
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
|
|
assert a == d
|