Добавлены поля offer_id и artist_ids классу Vinyl
このコミットが含まれているのは:
コミット
d0d9969503
|
@ -166,7 +166,8 @@ def video():
|
|||
|
||||
@pytest.fixture(scope='session')
|
||||
def vinyl():
|
||||
return Vinyl(TestVinyl.url, TestVinyl.title, TestVinyl.year, TestVinyl.price, TestVinyl.media, TestVinyl.picture)
|
||||
return Vinyl(TestVinyl.url, TestVinyl.title, TestVinyl.year, TestVinyl.price, TestVinyl.media, TestVinyl.offer_id,
|
||||
TestVinyl.artist_ids, TestVinyl.picture)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
|
|
|
@ -8,6 +8,8 @@ class TestVinyl:
|
|||
year = 2005
|
||||
media = '2 Грампластинка (LP)'
|
||||
price = 4483
|
||||
offer_id = 28640019
|
||||
artist_ids = [4, 24326, 618511, 2643503]
|
||||
|
||||
def test_expected_values(self, vinyl):
|
||||
assert vinyl.url == self.url
|
||||
|
@ -16,6 +18,8 @@ class TestVinyl:
|
|||
assert vinyl.year == self.year
|
||||
assert vinyl.price == self.price
|
||||
assert vinyl.media == self.media
|
||||
assert vinyl.offer_id == self.offer_id
|
||||
assert vinyl.artist_ids == self.artist_ids
|
||||
|
||||
def test_de_json_none(self, client):
|
||||
assert Vinyl.de_json({}, client) is None
|
||||
|
@ -24,7 +28,8 @@ class TestVinyl:
|
|||
assert Vinyl.de_list({}, client) == []
|
||||
|
||||
def test_de_json_required(self, client):
|
||||
json_dict = {'url': self.url, 'title': self.title, 'year': self.year, 'price': self.price, 'media': self.media}
|
||||
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}
|
||||
vinyl = Vinyl.de_json(json_dict, client)
|
||||
|
||||
assert vinyl.url == self.url
|
||||
|
@ -32,10 +37,12 @@ class TestVinyl:
|
|||
assert vinyl.year == self.year
|
||||
assert vinyl.price == self.price
|
||||
assert vinyl.media == self.media
|
||||
assert vinyl.offer_id == self.offer_id
|
||||
assert vinyl.artist_ids == self.artist_ids
|
||||
|
||||
def test_de_json_all(self, client):
|
||||
json_dict = {'url': self.url, 'picture': self.picture, 'title': self.title, 'year': self.year,
|
||||
'price': self.price, 'media': self.media}
|
||||
'price': self.price, 'media': self.media, 'offer_id': self.offer_id, 'artist_ids': self.artist_ids}
|
||||
vinyl = Vinyl.de_json(json_dict, client)
|
||||
|
||||
assert vinyl.url == self.url
|
||||
|
@ -44,11 +51,13 @@ class TestVinyl:
|
|||
assert vinyl.year == self.year
|
||||
assert vinyl.price == self.price
|
||||
assert vinyl.media == self.media
|
||||
assert vinyl.offer_id == self.offer_id
|
||||
assert vinyl.artist_ids == self.artist_ids
|
||||
|
||||
def test_equality(self):
|
||||
a = Vinyl(self.url, self.title, 2020, 200, self.media, self.picture)
|
||||
b = Vinyl(self.url, self.title, self.year, self.price, self.media, self.picture)
|
||||
c = Vinyl(self.url, self.title, self.year, self.price, self.media, self.picture)
|
||||
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)
|
||||
|
||||
assert a != b
|
||||
assert hash(a) != hash(b)
|
||||
|
|
|
@ -15,6 +15,8 @@ class Vinyl(YandexMusicObject):
|
|||
year (:obj:`int`): Год выпуска.
|
||||
price (:obj:`int`): Цена.
|
||||
media (:obj:`str`): Средство распространения.
|
||||
offer_id (:obj:`int`): Уникальный идентификатор предложения.
|
||||
artist_ids (:obj:`list` из :obj:`int`): Перечень уникальный идентификаторов исполнителей.
|
||||
picture (:obj:`str`): Ссылка на обложку.
|
||||
client (:obj:`yandex_music.Client`): Клиент Yandex Music.
|
||||
|
||||
|
@ -24,6 +26,8 @@ class Vinyl(YandexMusicObject):
|
|||
year (:obj:`int`): Год выпуска.
|
||||
price (:obj:`int`): Цена.
|
||||
media (:obj:`str`): Средство распространения.
|
||||
offer_id (:obj:`int`): Уникальный идентификатор предложения.
|
||||
artist_ids (:obj:`list` из :obj:`int`): Перечень уникальный идентификаторов исполнителей.
|
||||
picture (:obj:`str`, optional): Ссылка на обложку.
|
||||
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
||||
**kwargs: Произвольные ключевые аргументы полученные от API.
|
||||
|
@ -35,6 +39,8 @@ class Vinyl(YandexMusicObject):
|
|||
year: int,
|
||||
price: int,
|
||||
media: str,
|
||||
offer_id: int,
|
||||
artist_ids: List[int],
|
||||
picture: Optional[str] = None,
|
||||
client: Optional['Client'] = None,
|
||||
**kwargs) -> None:
|
||||
|
@ -46,9 +52,12 @@ class Vinyl(YandexMusicObject):
|
|||
self.year = year
|
||||
self.price = price
|
||||
self.media = media
|
||||
self.offer_id = offer_id
|
||||
self.artist_ids = artist_ids
|
||||
|
||||
self.client = client
|
||||
self._id_attrs = (self.title, self.price, self.year, self.url, self.price, self.media)
|
||||
self._id_attrs = (self.title, self.price, self.year, self.url, self.price,
|
||||
self.media, self.offer_id, self.artist_ids)
|
||||
|
||||
@classmethod
|
||||
def de_json(cls, data: dict, client: 'Client') -> Optional['Vinyl']:
|
||||
|
|
読み込み中…
新しいイシューから参照