2020-02-04 21:34:11 +09:00
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
from yandex_music import Like
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='class', params=[2, 3, 4])
|
|
|
|
|
def like_with_param(request, results, types):
|
2021-02-03 21:28:10 +09:00
|
|
|
|
return (
|
|
|
|
|
Like(
|
|
|
|
|
types[request.param],
|
|
|
|
|
TestLike.id,
|
|
|
|
|
TestLike.timestamp,
|
|
|
|
|
short_description=TestLike.short_description,
|
|
|
|
|
description=TestLike.description,
|
|
|
|
|
is_premiere=TestLike.is_premiere,
|
|
|
|
|
is_banner=TestLike.is_banner,
|
|
|
|
|
**{types[request.param]: results[request.param]},
|
|
|
|
|
),
|
|
|
|
|
request.param,
|
|
|
|
|
)
|
2020-02-04 21:34:11 +09:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class TestLike:
|
|
|
|
|
id = 5246018
|
|
|
|
|
timestamp = '2019-09-03T19:59:56+00:00'
|
Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
short_description = 'Учим английский нескучно'
|
2021-02-03 21:28:10 +09:00
|
|
|
|
description = (
|
|
|
|
|
'Английский по песням – это аудио- и видеоподкаст радио Unistar о том, как учить английский язык '
|
|
|
|
|
'по песням – хитам 90-х и 2000-х, которые звучат на Unistar. Никакого занудства, грамматических '
|
|
|
|
|
'правил и зубрежки. Только нескучный английский! Вы узнаете, о чем поют в любимых песнях, и как '
|
|
|
|
|
'это может помочь вам в общении во время путешествий.'
|
|
|
|
|
)
|
Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
is_premiere = False
|
|
|
|
|
is_banner = True
|
2020-02-04 21:34:11 +09:00
|
|
|
|
|
|
|
|
|
def test_expected_values(self, results, types, like_with_param):
|
|
|
|
|
like, param = like_with_param
|
|
|
|
|
|
|
|
|
|
assert like.type == types[param]
|
|
|
|
|
assert like.id == self.id
|
|
|
|
|
assert like.timestamp == self.timestamp
|
Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
assert like.short_description == self.short_description
|
|
|
|
|
assert like.description == self.description
|
|
|
|
|
assert like.is_premiere == self.is_premiere
|
|
|
|
|
assert like.is_banner == self.is_banner
|
2020-02-04 21:34:11 +09:00
|
|
|
|
assert getattr(like, like.type) == results[param]
|
|
|
|
|
|
|
|
|
|
def test_de_json_none(self, client):
|
|
|
|
|
assert Like.de_json({}, client) is None
|
|
|
|
|
|
|
|
|
|
def test_de_list_none(self, client):
|
|
|
|
|
assert Like.de_list({}, client) == []
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('param', [2, 3, 4])
|
|
|
|
|
def test_de_json_all(self, results, types, client, param):
|
|
|
|
|
result, type_ = results[param], types[param]
|
|
|
|
|
|
2021-02-03 21:28:10 +09:00
|
|
|
|
json_dict = {
|
|
|
|
|
'timestamp': self.timestamp,
|
2021-09-19 22:47:19 +09:00
|
|
|
|
'id': self.id,
|
2021-02-03 21:28:10 +09:00
|
|
|
|
type_: result.to_dict(),
|
|
|
|
|
'short_description': self.short_description,
|
|
|
|
|
'description': self.description,
|
|
|
|
|
'is_premiere': self.is_premiere,
|
|
|
|
|
'is_banner': self.is_banner,
|
|
|
|
|
}
|
2020-02-04 21:34:11 +09:00
|
|
|
|
like = Like.de_json(json_dict, client, type_)
|
|
|
|
|
|
|
|
|
|
assert like.type == type_
|
|
|
|
|
assert like.id == self.id
|
|
|
|
|
assert like.timestamp == self.timestamp
|
Метод de_list в TrackId.
Поля coauthors и recent_tracks в Playlist.
Поле regions в User.
Поля users, podcasts, podcast_episodes, type_, page, per_page в Search.
Поддержка новых типов поиска: подкасты, выпуски, пользователи.
Поля short_description, description, is_premiere, is_banner в Like.
Документация и тесты к новым поля. #339
2020-06-07 18:55:30 +09:00
|
|
|
|
assert like.short_description == self.short_description
|
|
|
|
|
assert like.description == self.description
|
|
|
|
|
assert like.is_premiere == self.is_premiere
|
|
|
|
|
assert like.is_banner == self.is_banner
|
2020-02-04 21:34:11 +09:00
|
|
|
|
assert getattr(like, type_) == result
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize('param', [2, 3, 4])
|
|
|
|
|
def test_equality(self, results, types, param):
|
|
|
|
|
result, type_ = results[param], types[param]
|
|
|
|
|
|
|
|
|
|
a = Like(type_, self.id, self.timestamp, **{type_: result})
|
|
|
|
|
b = Like(type_, '', self.timestamp, **{type_: result})
|
|
|
|
|
c = Like(type_, self.id, '', **{type_: result})
|
|
|
|
|
d = Like(type_, self.id, self.timestamp, **{type_: result})
|
|
|
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
|
|
assert a == d
|