2019-11-08 02:09:39 +09:00
|
|
|
from yandex_music import Link
|
|
|
|
|
|
|
|
|
|
|
|
class TestLink:
|
2019-11-08 06:37:53 +09:00
|
|
|
title = 'emmure'
|
|
|
|
href = 'https://www.facebook.com/emmure'
|
|
|
|
type = 'social'
|
|
|
|
social_network = 'facebook'
|
2019-11-08 02:09:39 +09:00
|
|
|
|
|
|
|
def test_expected_values(self, link):
|
|
|
|
assert link.title == self.title
|
|
|
|
assert link.href == self.href
|
|
|
|
assert link.type == self.type
|
|
|
|
assert link.social_network == self.social_network
|
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Link.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Link.de_list({}, client) == []
|
|
|
|
|
2019-11-08 02:09:39 +09:00
|
|
|
def test_de_json_required(self, client):
|
2021-09-19 22:47:19 +09:00
|
|
|
json_dict = {'title': self.title, 'href': self.href, 'type': self.type}
|
2019-11-08 02:09:39 +09:00
|
|
|
link = Link.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert link.title == self.title
|
|
|
|
assert link.href == self.href
|
|
|
|
assert link.type == self.type
|
|
|
|
|
|
|
|
def test_de_json_all(self, client):
|
2021-09-19 22:47:19 +09:00
|
|
|
json_dict = {'title': self.title, 'href': self.href, 'type': self.type, 'social_network': self.social_network}
|
2019-11-08 02:09:39 +09:00
|
|
|
link = Link.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert link.title == self.title
|
|
|
|
assert link.href == self.href
|
|
|
|
assert link.type == self.type
|
|
|
|
assert link.social_network == self.social_network
|
|
|
|
|
|
|
|
def test_equality(self):
|
2019-11-08 06:37:53 +09:00
|
|
|
a = Link(self.title, self.href, self.type, self.social_network)
|
|
|
|
b = Link(self.title, '', self.type, self.social_network)
|
|
|
|
c = Link(self.title, self.href, '', self.social_network)
|
|
|
|
d = Link(self.title, self.href, self.type, self.social_network)
|
|
|
|
|
|
|
|
assert a != b != c
|
|
|
|
assert hash(a) != hash(b) != hash(c)
|
|
|
|
assert a is not b is not c
|
|
|
|
|
|
|
|
assert a == d
|