Обновлены тесты

このコミットが含まれているのは:
Il`ya 2019-12-01 14:35:02 +03:00
コミット f1f49b4c94
5個のファイルの変更16行の追加26行の削除

ファイルの表示

@ -22,7 +22,7 @@ from . import TestCounts, TestTrackId, TestCaseForms, TestRatings, TestIcon, Tes
def artist_factory(cover, counts, ratings, link, description):
class ArtistFactory:
def get(self, popular_tracks):
return Artist(TestArtist.id, TestArtist.name, TestArtist.various, TestArtist.composer, cover,
return Artist(TestArtist.id, TestArtist.name, cover, TestArtist.various, TestArtist.composer,
TestArtist.genres, TestArtist.op_image, TestArtist.no_pictures_from_search, counts,
TestArtist.available, ratings, [link], TestArtist.tickets_available, TestArtist.likes_count,
popular_tracks, TestArtist.regions, TestArtist.decomposed, TestArtist.full_names, description,
@ -46,10 +46,10 @@ def artist_without_tracks(artist_factory):
def track_factory(major, normalization):
class TrackFactory:
def get(self, artists, albums):
return Track(TestTrack.id, TestTrack.title, TestTrack.available, TestTrack.available_for_premium_users,
artists, albums, TestTrack.lyrics_available, TestTrack.real_id, TestTrack.og_image,
TestTrack.type, TestTrack.cover_uri, major, TestTrack.duration_ms, TestTrack.storage_dir,
TestTrack.file_size, normalization, TestTrack.error, TestTrack.regions,
return Track(TestTrack.id, TestTrack.title, TestTrack.available, artists, albums,
TestTrack.available_for_premium_users, TestTrack.lyrics_available, TestTrack.real_id,
TestTrack.og_image, TestTrack.type, TestTrack.cover_uri, major, TestTrack.duration_ms,
TestTrack.storage_dir, TestTrack.file_size, normalization, TestTrack.error, TestTrack.regions,
TestTrack.available_as_rbt, TestTrack.content_warning, TestTrack.explicit,
TestTrack.preview_duration_ms, TestTrack.available_full_without_permission)

ファイルの表示

@ -50,14 +50,11 @@ class TestArtist:
assert artist.end_date == self.end_date
def test_de_json_required(self, client, cover):
json_dict = {'id': self.id, 'name': self.name, 'various': self.various, 'composer': self.composer,
'cover': cover.to_dict()}
json_dict = {'id': self.id, 'name': self.name, 'cover': cover.to_dict()}
artist = Artist.de_json(json_dict, client)
assert artist.id == self.id
assert artist.name == self.name
assert artist.various == self.various
assert artist.composer == self.composer
assert artist.cover == cover
def test_de_json_all(self, client, cover, counts, ratings, link, track_without_artists, description):
@ -100,9 +97,9 @@ class TestArtist:
assert artist.end_date == self.end_date
def test_equality(self, cover):
a = Artist(self.id, self.name, self.various, self.composer, cover)
b = Artist(self.id, '', self.various, self.composer, None)
c = Artist(self.id, self.name, self.various, self.composer, cover)
a = Artist(self.id, self.name, cover)
b = Artist(self.id, '', None)
c = Artist(self.id, self.name, cover)
assert a != b
assert hash(a) != hash(b)

ファイルの表示

@ -49,18 +49,14 @@ class TestTrack:
def test_de_json_required(self, client, artist, album):
json_dict = {'id': self.id, 'title': self.title, 'available': self.available,
'available_for_premium_users': self.available_for_premium_users,
'artists': [artist.to_dict()], 'albums': [album.to_dict()],
'lyrics_available': self.lyrics_available}
'artists': [artist.to_dict()], 'albums': [album.to_dict()]}
track = Track.de_json(json_dict, client)
assert track.id == self.id
assert track.title == self.title
assert track.available == self.available
assert track.available_for_premium_users == self.available_for_premium_users
assert track.artists == [artist]
assert track.albums == [album]
assert track.lyrics_available == self.lyrics_available
def test_de_json_all(self, client, artist, album, major, normalization):
json_dict = {'id': self.id, 'title': self.title, 'available': self.available,
@ -101,11 +97,9 @@ class TestTrack:
assert track.available_full_without_permission == self.available_full_without_permission
def test_equality(self, artist, album):
a = Track(self.id, self.title, self.available, self.available_for_premium_users, [artist], [album],
self.lyrics_available)
b = Track(self.id, '', self.available, self.available_for_premium_users, [artist], [album], False)
c = Track(self.id, self.title, self.available, self.available_for_premium_users, [artist], [album],
self.lyrics_available)
a = Track(self.id, self.title, self.available, [artist], [album])
b = Track(self.id, '', self.available, [artist], [None])
c = Track(self.id, self.title, self.available, [artist], [album])
assert a != b
assert hash(a) != hash(b)

ファイルの表示

@ -55,12 +55,12 @@ class Artist(YandexMusicObject):
self.db_aliases = db_aliases
self.aliases = aliases
# Оставлено строкой потому что может прийти конкретная дата или просто год
# Может прийти конкретная дата или просто год
self.init_date = init_date
self.end_date = end_date
self.client = client
self._id_attrs = (self.id, self.name, self.various, self.composer, self.cover)
self._id_attrs = (self.id, self.name, self.cover)
def download_op_image(self, filename, size='200x200'):
"""Загрузка обложки.

ファイルの表示

@ -56,8 +56,7 @@ class Track(YandexMusicObject):
self.download_info = None
self.client = client
self._id_attrs = (self.id, self.title, self.available, self.available_for_premium_users,
self.artists, self.albums, self.lyrics_available)
self._id_attrs = (self.id, self.title, self.available, self.artists, self.albums)
def get_download_info(self, get_direct_links=False):
self.download_info = self.client.tracks_download_info(self.track_id, get_direct_links)