test_album.py 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. from yandex_music import Album
  2. class TestAlbum:
  3. id = 5239478
  4. error = 'not-found'
  5. title = 'In the End'
  6. version = 'feat. Mark Van Hoen & Mike Harding'
  7. cover_uri = 'avatars.yandex.net/get-music-content/95061/89c14a7d.a.5239478-1/%%'
  8. track_count = 3
  9. available = True
  10. available_for_premium_users = True
  11. content_warning = None
  12. original_release_year = None
  13. genre = 'alternative'
  14. text_color = '#000000'
  15. short_description = ''
  16. description = (
  17. 'В начале 2015 года вокалист Asking Alexandria Дэнни Уорсноп объявил об уходе из группы — музыкант'
  18. ' стал строить сольную карьеру и заниматься другими проектами. Однако через неполных два года '
  19. 'Уорсноп вернулся в группу, и в конце 2017-го музыканты представили пятую пластинку в прежнем '
  20. 'составе. «Было здорово вернуться к ребятам. Думаю, нам всем нужно было время, чтобы отпустить '
  21. 'то, что произошло между нами. Хорошо быть снова вместе», — говорит Денни Уорсноп.'
  22. )
  23. is_premiere = False
  24. is_banner = False
  25. meta_type = 'music'
  26. storage_dir = '4beeac1e.a.1155208'
  27. og_image = 'avatars.yandex.net/get-music-content/95061/89c14a7d.a.5239478-1/%%'
  28. buy = []
  29. recent = False
  30. very_important = False
  31. available_for_mobile = True
  32. available_partially = False
  33. bests = [51241318]
  34. prerolls = None
  35. year = 2019
  36. release_date = '2019-03-22T00:00:00+03:00'
  37. type = 'single'
  38. regions = None
  39. available_as_rbt = False
  40. lyrics_available = True
  41. remember_position = False
  42. duration_ms = 200440
  43. explicit = False
  44. start_date = '2020-06-30'
  45. likes_count = 2
  46. available_regions = ['kg', 'tm', 'by', 'kz', 'md', 'ru', 'am', 'ge', 'uz', 'tj', 'il', 'az', 'ua']
  47. available_for_options = ['bookmate']
  48. def test_expected_values(
  49. self,
  50. album,
  51. artist_without_tracks,
  52. label,
  53. track_position,
  54. track_without_albums,
  55. album_without_nested_albums,
  56. deprecation,
  57. ):
  58. assert album.id == self.id
  59. assert album.error == self.error
  60. assert album.title == self.title
  61. assert album.version == self.version
  62. assert album.cover_uri == self.cover_uri
  63. assert album.track_count == self.track_count
  64. assert album.artists == [artist_without_tracks]
  65. assert album.labels == [label]
  66. assert album.available == self.available
  67. assert album.available_for_premium_users == self.available_for_premium_users
  68. assert album.content_warning == self.content_warning
  69. assert album.original_release_year == self.original_release_year
  70. assert album.genre == self.genre
  71. assert album.text_color == self.text_color
  72. assert album.short_description == self.short_description
  73. assert album.description == self.description
  74. assert album.is_premiere == self.is_premiere
  75. assert album.is_banner == self.is_banner
  76. assert album.meta_type == self.meta_type
  77. assert album.storage_dir == self.storage_dir
  78. assert album.og_image == self.og_image
  79. assert album.buy == self.buy
  80. assert album.recent == self.recent
  81. assert album.very_important == self.very_important
  82. assert album.available_for_mobile == self.available_for_mobile
  83. assert album.available_partially == self.available_partially
  84. assert album.bests == self.bests
  85. assert album.duplicates == [album_without_nested_albums]
  86. assert album.prerolls == self.prerolls
  87. assert album.volumes == [[track_without_albums]]
  88. assert album.year == self.year
  89. assert album.release_date == self.release_date
  90. assert album.type == self.type
  91. assert album.track_position == track_position
  92. assert album.regions == self.regions
  93. assert album.available_as_rbt == self.available_as_rbt
  94. assert album.lyrics_available == self.lyrics_available
  95. assert album.remember_position == self.remember_position
  96. assert album.duration_ms == self.duration_ms
  97. assert album.explicit == self.explicit
  98. assert album.start_date == self.start_date
  99. assert album.likes_count == self.likes_count
  100. assert album.deprecation == deprecation
  101. assert album.available_regions == self.available_regions
  102. assert album.available_for_options == self.available_for_options
  103. def test_de_json_none(self, client):
  104. assert Album.de_json({}, client) is None
  105. def test_de_list_none(self, client):
  106. assert Album.de_list([], client) == []
  107. def test_de_json_required(self, client):
  108. json_dict = {'id': self.id}
  109. Album.de_json(json_dict, client)
  110. def test_de_json_all(self, client, artist, label, track_position, track, album_without_nested_albums, deprecation):
  111. labels = [label] if isinstance(label, str) else [label.to_dict()]
  112. json_dict = {
  113. 'id': self.id,
  114. 'error': self.error,
  115. 'title': self.title,
  116. 'cover_uri': self.cover_uri,
  117. 'track_count': self.track_count,
  118. 'artists': [artist.to_dict()],
  119. 'labels': labels,
  120. 'available': self.available,
  121. 'available_for_premium_users': self.available_for_premium_users,
  122. 'version': self.version,
  123. 'content_warning': self.content_warning,
  124. 'regions': self.regions,
  125. 'original_release_year': self.original_release_year,
  126. 'genre': self.genre,
  127. 'buy': self.buy,
  128. 'og_image': self.og_image,
  129. 'recent': self.recent,
  130. 'very_important': self.very_important,
  131. 'available_for_mobile': self.available_for_mobile,
  132. 'available_partially': self.available_partially,
  133. 'bests': self.bests,
  134. 'prerolls': self.prerolls,
  135. 'volumes': [[track.to_dict()]],
  136. 'year': self.year,
  137. 'release_date': self.release_date,
  138. 'type': self.type,
  139. 'track_position': track_position.to_dict(),
  140. 'meta_type': self.meta_type,
  141. 'storage_dir': self.storage_dir,
  142. 'is_banner': self.is_banner,
  143. 'duplicates': [album_without_nested_albums.to_dict()],
  144. 'is_premiere': self.is_premiere,
  145. 'short_description': self.short_description,
  146. 'description': self.description,
  147. 'text_color': self.text_color,
  148. 'available_as_rbt': self.available_as_rbt,
  149. 'lyrics_available': self.lyrics_available,
  150. 'remember_position': self.remember_position,
  151. 'albums': [album_without_nested_albums.to_dict()],
  152. 'duration_ms': self.duration_ms,
  153. 'explicit': self.explicit,
  154. 'start_date': self.start_date,
  155. 'likes_count': self.likes_count,
  156. 'deprecation': deprecation.to_dict(),
  157. 'available_regions': self.available_regions,
  158. 'available_for_options': self.available_for_options,
  159. }
  160. album = Album.de_json(json_dict, client)
  161. assert album.id == self.id
  162. assert album.error == self.error
  163. assert album.title == self.title
  164. assert album.version == self.version
  165. assert album.cover_uri == self.cover_uri
  166. assert album.track_count == self.track_count
  167. assert album.artists == [artist]
  168. assert album.labels == [label]
  169. assert album.available == self.available
  170. assert album.available_for_premium_users == self.available_for_premium_users
  171. assert album.content_warning == self.content_warning
  172. assert album.original_release_year == self.original_release_year
  173. assert album.genre == self.genre
  174. assert album.text_color == self.text_color
  175. assert album.short_description == self.short_description
  176. assert album.description == self.description
  177. assert album.is_premiere == self.is_premiere
  178. assert album.is_banner == self.is_banner
  179. assert album.meta_type == self.meta_type
  180. assert album.storage_dir == self.storage_dir
  181. assert album.og_image == self.og_image
  182. assert album.buy == self.buy
  183. assert album.recent == self.recent
  184. assert album.very_important == self.very_important
  185. assert album.available_for_mobile == self.available_for_mobile
  186. assert album.available_partially == self.available_partially
  187. assert album.bests == self.bests
  188. assert album.duplicates == [album_without_nested_albums]
  189. assert album.prerolls == self.prerolls
  190. assert album.volumes == [[track]]
  191. assert album.year == self.year
  192. assert album.release_date == self.release_date
  193. assert album.type == self.type
  194. assert album.track_position == track_position
  195. assert album.regions == self.regions
  196. assert album.available_as_rbt == self.available_as_rbt
  197. assert album.lyrics_available == self.lyrics_available
  198. assert album.remember_position == self.remember_position
  199. assert album.duration_ms == self.duration_ms
  200. assert album.explicit == self.explicit
  201. assert album.start_date == self.start_date
  202. assert album.likes_count == self.likes_count
  203. assert album.deprecation == deprecation
  204. assert album.available_regions == self.available_regions
  205. assert album.available_for_options == self.available_for_options
  206. def test_equality(self, artist, label):
  207. a = Album(self.id)
  208. b = Album(10)
  209. c = Album(self.id)
  210. assert a != b
  211. assert hash(a) != hash(b)
  212. assert a is not b
  213. assert a == c