Добавлены основные тесты для следующий классов: Account, CaseForms, Cover, DownloadInfo, Enum, InvocationInfo, Lyrics, MadeFor, Permissions, PersonalPlaylistsData, PlayContextsData, Promotion, RotorSettings, Subsription,
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Починен conftest.py
2019-11-08 09:30:15 +09:00
|
|
|
import pytest
|
|
|
|
|
|
|
|
from yandex_music import Genre
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='class')
|
|
|
|
def genre(title, images, icon, genre_without_sub_genre):
|
|
|
|
return Genre(TestGenre.id, TestGenre.weight, TestGenre.composer_top, TestGenre.title, {'uz': title}, images,
|
|
|
|
TestGenre.show_in_menu, TestGenre.full_title, TestGenre.url_part, TestGenre.color, icon,
|
|
|
|
[genre_without_sub_genre], TestGenre.hide_in_regions)
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='class')
|
|
|
|
def genre_without_sub_genre(title, images, icon):
|
|
|
|
return Genre(TestGenre.id, TestGenre.weight, TestGenre.composer_top, TestGenre.title, {'uz': title}, images,
|
|
|
|
TestGenre.show_in_menu)
|
|
|
|
|
|
|
|
|
|
|
|
class TestGenre:
|
|
|
|
id = 'all'
|
|
|
|
weight = 2
|
|
|
|
composer_top = False
|
|
|
|
title = None
|
|
|
|
show_in_menu = True
|
|
|
|
full_title = 'Музыка всех жанров'
|
|
|
|
url_part = None
|
|
|
|
color = None
|
|
|
|
hide_in_regions = None
|
|
|
|
|
|
|
|
def test_expected_values(self, genre, title, images, icon, genre_without_sub_genre):
|
|
|
|
assert genre.id == self.id
|
|
|
|
assert genre.weight == self.weight
|
|
|
|
assert genre.composer_top == self.composer_top
|
|
|
|
assert genre.title == self.title
|
|
|
|
assert genre.titles == {"uz": title}
|
|
|
|
assert genre.images == images
|
|
|
|
assert genre.show_in_menu == self.show_in_menu
|
|
|
|
assert genre.full_title == self.full_title
|
|
|
|
assert genre.url_part == self.url_part
|
|
|
|
assert genre.color == self.color
|
|
|
|
assert genre.radio_icon == icon
|
|
|
|
assert genre.sub_genres == [genre_without_sub_genre]
|
|
|
|
assert genre.hide_in_regions == self.hide_in_regions
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Genre.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Genre.de_list({}, client) == []
|
|
|
|
|
Добавлены основные тесты для следующий классов: Account, CaseForms, Cover, DownloadInfo, Enum, InvocationInfo, Lyrics, MadeFor, Permissions, PersonalPlaylistsData, PlayContextsData, Promotion, RotorSettings, Subsription,
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Починен conftest.py
2019-11-08 09:30:15 +09:00
|
|
|
def test_de_json_required(self, client, title, images):
|
2019-12-27 05:27:58 +09:00
|
|
|
json_dict = {'id_': self.id, 'weight': self.weight, 'composer_top': self.composer_top, 'title': self.title,
|
Добавлены основные тесты для следующий классов: Account, CaseForms, Cover, DownloadInfo, Enum, InvocationInfo, Lyrics, MadeFor, Permissions, PersonalPlaylistsData, PlayContextsData, Promotion, RotorSettings, Subsription,
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Починен conftest.py
2019-11-08 09:30:15 +09:00
|
|
|
'titles': {'uz': title.to_dict()}, 'images': images.to_dict(), 'show_in_menu': self.show_in_menu}
|
|
|
|
genre = Genre.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert genre.id == self.id
|
|
|
|
assert genre.weight == self.weight
|
|
|
|
assert genre.composer_top == self.composer_top
|
|
|
|
assert genre.title == self.title
|
|
|
|
assert genre.titles == {'uz': title}
|
|
|
|
assert genre.images == images
|
|
|
|
assert genre.show_in_menu == self.show_in_menu
|
|
|
|
|
|
|
|
def test_de_json_all(self, client, title, images, icon, genre_without_sub_genre):
|
2019-12-27 05:27:58 +09:00
|
|
|
json_dict = {'id_': self.id, 'weight': self.weight, 'composer_top': self.composer_top, 'title': self.title,
|
Добавлены основные тесты для следующий классов: Account, CaseForms, Cover, DownloadInfo, Enum, InvocationInfo, Lyrics, MadeFor, Permissions, PersonalPlaylistsData, PlayContextsData, Promotion, RotorSettings, Subsription,
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Починен conftest.py
2019-11-08 09:30:15 +09:00
|
|
|
'titles': {'uz': title.to_dict()}, 'images': images.to_dict(), 'show_in_menu': self.show_in_menu,
|
|
|
|
'full_title': self.full_title, 'url_part': self.url_part, 'color': self.color,
|
|
|
|
'radio_icon': icon.to_dict(), 'sub_genres': [genre_without_sub_genre.to_dict()],
|
|
|
|
'hide_in_regions': self.hide_in_regions}
|
|
|
|
genre = Genre.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert genre.id == self.id
|
|
|
|
assert genre.weight == self.weight
|
|
|
|
assert genre.composer_top == self.composer_top
|
|
|
|
assert genre.title == self.title
|
|
|
|
assert genre.titles == {'uz': title}
|
|
|
|
assert genre.images == images
|
|
|
|
assert genre.show_in_menu == self.show_in_menu
|
|
|
|
assert genre.full_title == self.full_title
|
|
|
|
assert genre.url_part == self.url_part
|
|
|
|
assert genre.color == self.color
|
|
|
|
assert genre.radio_icon == icon
|
|
|
|
assert genre.sub_genres == [genre_without_sub_genre]
|
|
|
|
assert genre.hide_in_regions == self.hide_in_regions
|
|
|
|
|
Добавлены основные тесты для следующих классов: Album, Artist, Chart, Counts, Genre, Label, PermissionAlerts, PromoCodeStatus, Restrictions, Settings, Station, StatuonResult, Status, Track.
Исправлены фикстуры и сравнения для вышеперечисленных классов.
Отрефакторен restrictions.py.
Исправлен баг в .to_dict() методе, связанный с десериализцией объектов списков и словарей.
2019-11-09 00:24:54 +09:00
|
|
|
def test_equality(self, title, images):
|
|
|
|
a = Genre(self.id, self.weight, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
|
|
|
|
b = Genre(self.id, self.weight, False, '', {'uz': title}, images, self.show_in_menu)
|
|
|
|
c = Genre(self.id, 30, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
|
|
|
|
d = Genre(self.id, self.weight, self.composer_top, self.title, {'uz': title}, images, self.show_in_menu)
|
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
assert a == d
|