2019-11-08 06:37:53 +09:00
|
|
|
from yandex_music import Description
|
|
|
|
|
|
|
|
|
|
|
|
class TestDescription:
|
2021-02-03 21:28:10 +09:00
|
|
|
text = (
|
|
|
|
'Американский певец и актёр, один из самых коммерчески успешных исполнителей популярной музыки XX века. '
|
|
|
|
'Также известен как «король рок-н-ролла». Пресли популяризовал рок-н-ролл, хотя и не был первым '
|
|
|
|
'исполнителем этого жанра. '
|
|
|
|
)
|
2020-03-24 16:49:11 +09:00
|
|
|
uri = 'http://ru.wikipedia.org/wiki/Пресли, Элвис'
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
def test_expected_values(self, description):
|
|
|
|
assert description.text == self.text
|
2020-03-24 16:49:11 +09:00
|
|
|
assert description.uri == self.uri
|
2019-11-08 06:37:53 +09:00
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Description.de_json({}, client) is None
|
|
|
|
|
2019-11-08 06:37:53 +09:00
|
|
|
def test_de_json_required(self, client):
|
2020-03-24 16:49:11 +09:00
|
|
|
json_dict = {'text': self.text, 'uri': self.uri}
|
2019-11-08 06:37:53 +09:00
|
|
|
description = Description.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert description.text == self.text
|
2020-03-24 16:49:11 +09:00
|
|
|
assert description.uri == self.uri
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
def test_de_json_all(self, client):
|
2020-03-24 16:49:11 +09:00
|
|
|
json_dict = {'text': self.text, 'uri': self.uri}
|
2019-11-08 06:37:53 +09:00
|
|
|
description = Description.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert description.text == self.text
|
2020-03-24 16:49:11 +09:00
|
|
|
assert description.uri == self.uri
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
def test_equality(self):
|
2020-03-24 16:49:11 +09:00
|
|
|
a = Description(self.text, self.uri)
|
|
|
|
b = Description('', self.uri)
|
2019-11-08 06:37:53 +09:00
|
|
|
c = Description(self.text, '')
|
2020-03-24 16:49:11 +09:00
|
|
|
d = Description(self.text, self.uri)
|
2019-11-08 06:37:53 +09:00
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
assert a == d
|