2019-11-08 04:52:26 +09:00
|
|
|
from yandex_music import Vinyl
|
|
|
|
|
|
|
|
|
|
|
|
class TestVinyl:
|
|
|
|
url = 'http://www.ozon.ru/context/detail/id/29504873/?partner=yandexmusic'
|
|
|
|
picture = 'avatars.yandex.net/get-music-misc/2413828/vinyl.29504873image/%%'
|
|
|
|
title = 'The Prodigy.Their Law The Singles 1990-2005 (2 LP)'
|
|
|
|
year = 2005
|
|
|
|
media = '2 Грампластинка (LP)'
|
|
|
|
price = 4483
|
2020-04-17 05:42:38 +09:00
|
|
|
offer_id = 28640019
|
|
|
|
artist_ids = [4, 24326, 618511, 2643503]
|
2019-11-08 04:52:26 +09:00
|
|
|
|
|
|
|
def test_expected_values(self, vinyl):
|
|
|
|
assert vinyl.url == self.url
|
|
|
|
assert vinyl.picture == self.picture
|
|
|
|
assert vinyl.title == self.title
|
|
|
|
assert vinyl.year == self.year
|
|
|
|
assert vinyl.price == self.price
|
|
|
|
assert vinyl.media == self.media
|
2020-04-17 05:42:38 +09:00
|
|
|
assert vinyl.offer_id == self.offer_id
|
|
|
|
assert vinyl.artist_ids == self.artist_ids
|
2019-11-08 04:52:26 +09:00
|
|
|
|
2019-12-29 16:38:24 +09:00
|
|
|
def test_de_json_none(self, client):
|
|
|
|
assert Vinyl.de_json({}, client) is None
|
|
|
|
|
2019-12-29 17:06:27 +09:00
|
|
|
def test_de_list_none(self, client):
|
|
|
|
assert Vinyl.de_list({}, client) == []
|
|
|
|
|
2019-11-08 04:52:26 +09:00
|
|
|
def test_de_json_required(self, client):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'url': self.url,
|
|
|
|
'title': self.title,
|
|
|
|
'year': self.year,
|
|
|
|
'price': self.price,
|
|
|
|
'media': self.media,
|
|
|
|
'offer_id': self.offer_id,
|
|
|
|
'artist_ids': self.artist_ids,
|
|
|
|
}
|
2019-11-08 04:52:26 +09:00
|
|
|
vinyl = Vinyl.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert vinyl.url == self.url
|
|
|
|
assert vinyl.title == self.title
|
|
|
|
assert vinyl.year == self.year
|
|
|
|
assert vinyl.price == self.price
|
|
|
|
assert vinyl.media == self.media
|
2020-04-17 05:42:38 +09:00
|
|
|
assert vinyl.offer_id == self.offer_id
|
|
|
|
assert vinyl.artist_ids == self.artist_ids
|
2019-11-08 04:52:26 +09:00
|
|
|
|
|
|
|
def test_de_json_all(self, client):
|
2021-02-03 21:28:10 +09:00
|
|
|
json_dict = {
|
|
|
|
'url': self.url,
|
|
|
|
'picture': self.picture,
|
|
|
|
'title': self.title,
|
|
|
|
'year': self.year,
|
|
|
|
'price': self.price,
|
|
|
|
'media': self.media,
|
|
|
|
'offer_id': self.offer_id,
|
|
|
|
'artist_ids': self.artist_ids,
|
|
|
|
}
|
2019-11-08 04:52:26 +09:00
|
|
|
vinyl = Vinyl.de_json(json_dict, client)
|
|
|
|
|
|
|
|
assert vinyl.url == self.url
|
|
|
|
assert vinyl.picture == self.picture
|
|
|
|
assert vinyl.title == self.title
|
|
|
|
assert vinyl.year == self.year
|
|
|
|
assert vinyl.price == self.price
|
|
|
|
assert vinyl.media == self.media
|
2020-04-17 05:42:38 +09:00
|
|
|
assert vinyl.offer_id == self.offer_id
|
|
|
|
assert vinyl.artist_ids == self.artist_ids
|
2019-11-08 04:52:26 +09:00
|
|
|
|
|
|
|
def test_equality(self):
|
2020-04-17 05:42:38 +09:00
|
|
|
a = Vinyl(self.url, self.title, 2020, 200, self.media, self.offer_id, [10])
|
|
|
|
b = Vinyl(self.url, self.title, self.year, self.price, self.media, self.offer_id, self.artist_ids)
|
|
|
|
c = Vinyl(self.url, self.title, self.year, self.price, self.media, self.offer_id, self.artist_ids)
|
2019-11-08 04:52:26 +09:00
|
|
|
|
|
|
|
assert a != b
|
|
|
|
assert hash(a) != hash(b)
|
|
|
|
assert a is not b
|
|
|
|
|
|
|
|
assert b == c
|