conftest.py 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336
  1. import pytest
  2. from yandex_music import (
  3. R128,
  4. Account,
  5. AdParams,
  6. Album,
  7. AlbumEvent,
  8. Alert,
  9. AlertButton,
  10. Artist,
  11. ArtistEvent,
  12. AutoRenewable,
  13. Best,
  14. Block,
  15. BlockEntity,
  16. Brand,
  17. CaseForms,
  18. Chart,
  19. ChartInfo,
  20. ChartInfoMenu,
  21. ChartInfoMenuItem,
  22. ChartItem,
  23. Client,
  24. Contest,
  25. Context,
  26. Counts,
  27. Cover,
  28. CustomWave,
  29. Day,
  30. Deactivation,
  31. Deprecation,
  32. Description,
  33. DiscreteScale,
  34. Enum,
  35. Event,
  36. GeneratedPlaylist,
  37. Icon,
  38. Id,
  39. Images,
  40. InvocationInfo,
  41. Label,
  42. LicenceTextPart,
  43. Link,
  44. Lyrics,
  45. LyricsInfo,
  46. LyricsMajor,
  47. MadeFor,
  48. Major,
  49. MetaData,
  50. MixLink,
  51. NonAutoRenewable,
  52. Normalization,
  53. OpenGraphData,
  54. Operator,
  55. Pager,
  56. PassportPhone,
  57. Permissions,
  58. PersonalPlaylistsData,
  59. PlayContext,
  60. PlayContextsData,
  61. PlayCounter,
  62. Playlist,
  63. PlaylistAbsence,
  64. PlaylistId,
  65. Plus,
  66. PoetryLoverMatch,
  67. Price,
  68. Product,
  69. Promotion,
  70. Ratings,
  71. RenewableRemainder,
  72. Restrictions,
  73. RotorSettings,
  74. SearchResult,
  75. Sequence,
  76. Settings,
  77. Shot,
  78. ShotData,
  79. ShotType,
  80. Station,
  81. StationData,
  82. StationResult,
  83. Stats,
  84. Status,
  85. Subscription,
  86. Tag,
  87. Title,
  88. Track,
  89. TrackId,
  90. TrackLyrics,
  91. TrackPosition,
  92. TrackShort,
  93. TrackShortOld,
  94. TrackWithAds,
  95. User,
  96. Value,
  97. Video,
  98. VideoSupplement,
  99. Vinyl,
  100. )
  101. from . import (
  102. TestAccount,
  103. TestAdParams,
  104. TestAlbum,
  105. TestAlert,
  106. TestAlertButton,
  107. TestArtist,
  108. TestArtistEvent,
  109. TestAutoRenewable,
  110. TestBest,
  111. TestBlock,
  112. TestBlockEntity,
  113. TestBrand,
  114. TestCaseForms,
  115. TestChart,
  116. TestChartInfo,
  117. TestChartInfoMenuItem,
  118. TestContest,
  119. TestContext,
  120. TestCounts,
  121. TestCover,
  122. TestCustomWave,
  123. TestDay,
  124. TestDeactivation,
  125. TestDeprecation,
  126. TestDescription,
  127. TestDiscreteScale,
  128. TestEnum,
  129. TestEvent,
  130. TestGeneratedPlaylist,
  131. TestIcon,
  132. TestId,
  133. TestImages,
  134. TestInvocationInfo,
  135. TestLabel,
  136. TestLicenceTextPart,
  137. TestLink,
  138. TestLyrics,
  139. TestLyricsInfo,
  140. TestLyricsMajor,
  141. TestMajor,
  142. TestMetaData,
  143. TestMixLink,
  144. TestNonAutoRenewable,
  145. TestNormalization,
  146. TestOpenGraphData,
  147. TestOperator,
  148. TestPager,
  149. TestPassportPhone,
  150. TestPermissions,
  151. TestPersonalPlaylistsData,
  152. TestPlayContext,
  153. TestPlayCounter,
  154. TestPlaylist,
  155. TestPlaylistAbsence,
  156. TestPlaylistId,
  157. TestPlus,
  158. TestPoetryLoverMatch,
  159. TestPrice,
  160. TestProduct,
  161. TestPromotion,
  162. TestR128,
  163. TestRatings,
  164. TestRenewableRemainder,
  165. TestRotorSettings,
  166. TestSearchResult,
  167. TestSequence,
  168. TestSettings,
  169. TestShot,
  170. TestShotData,
  171. TestShotType,
  172. TestStation,
  173. TestStationData,
  174. TestStationResult,
  175. TestStats,
  176. TestStatus,
  177. TestSubscription,
  178. TestTag,
  179. TestTitle,
  180. TestTrack,
  181. TestTrackId,
  182. TestTrackLyrics,
  183. TestTrackPosition,
  184. TestTrackShort,
  185. TestTrackShortOld,
  186. TestTrackWithAds,
  187. TestUser,
  188. TestValue,
  189. TestVideo,
  190. TestVideoSupplement,
  191. TestVinyl,
  192. )
  193. @pytest.fixture(scope='session')
  194. def artist_factory(cover, counts, ratings, link, description):
  195. class ArtistFactory:
  196. def get(self, popular_tracks, decomposed=None):
  197. return Artist(
  198. TestArtist.id,
  199. TestArtist.error,
  200. TestArtist.reason,
  201. TestArtist.name,
  202. cover,
  203. TestArtist.various,
  204. TestArtist.composer,
  205. TestArtist.genres,
  206. TestArtist.og_image,
  207. TestArtist.op_image,
  208. TestArtist.no_pictures_from_search,
  209. counts,
  210. TestArtist.available,
  211. ratings,
  212. [link],
  213. TestArtist.tickets_available,
  214. TestArtist.likes_count,
  215. popular_tracks,
  216. TestArtist.regions,
  217. decomposed,
  218. TestArtist.full_names,
  219. TestArtist.hand_made_description,
  220. description,
  221. TestArtist.countries,
  222. TestArtist.en_wikipedia_link,
  223. TestArtist.db_aliases,
  224. TestArtist.aliases,
  225. TestArtist.init_date,
  226. TestArtist.end_date,
  227. TestArtist.ya_money_id,
  228. )
  229. return ArtistFactory()
  230. @pytest.fixture(scope='session')
  231. def artist(artist_factory, track_without_artists_and_albums, artist_decomposed):
  232. return artist_factory.get([track_without_artists_and_albums], artist_decomposed)
  233. @pytest.fixture(scope='session')
  234. def artist_without_nested_artist(artist_factory, track_without_artists_and_albums):
  235. return artist_factory.get([track_without_artists_and_albums])
  236. @pytest.fixture(scope='session')
  237. def artist_without_tracks(artist_factory):
  238. return artist_factory.get([])
  239. @pytest.fixture(scope='session')
  240. def artist_decomposed(artist_without_nested_artist):
  241. return [' & ', artist_without_nested_artist]
  242. @pytest.fixture(scope='session')
  243. def track_factory(major, normalization, user, meta_data, poetry_lover_match, r_128, lyrics_info):
  244. class TrackFactory:
  245. def get(self, artists, albums, track_without_nested_tracks=None):
  246. return Track(
  247. TestTrack.id,
  248. TestTrack.title,
  249. TestTrack.available,
  250. artists,
  251. albums,
  252. TestTrack.available_for_premium_users,
  253. TestTrack.lyrics_available,
  254. [poetry_lover_match],
  255. TestTrack.best,
  256. TestTrack.real_id,
  257. TestTrack.og_image,
  258. TestTrack.type,
  259. TestTrack.cover_uri,
  260. major,
  261. TestTrack.duration_ms,
  262. TestTrack.storage_dir,
  263. TestTrack.file_size,
  264. track_without_nested_tracks,
  265. track_without_nested_tracks,
  266. normalization,
  267. TestTrack.error,
  268. TestTrack.can_publish,
  269. TestTrack.state,
  270. TestTrack.desired_visibility,
  271. TestTrack.filename,
  272. user,
  273. meta_data,
  274. TestTrack.regions,
  275. TestTrack.available_as_rbt,
  276. TestTrack.content_warning,
  277. TestTrack.explicit,
  278. TestTrack.preview_duration_ms,
  279. TestTrack.available_full_without_permission,
  280. TestTrack.version,
  281. TestTrack.remember_position,
  282. TestTrack.background_video_uri,
  283. TestTrack.short_description,
  284. TestTrack.is_suitable_for_children,
  285. TestTrack.track_source,
  286. TestTrack.available_for_options,
  287. r_128,
  288. lyrics_info,
  289. TestTrack.track_sharing_flag,
  290. )
  291. return TrackFactory()
  292. @pytest.fixture(scope='session')
  293. def track(track_factory, artist, album, track_without_nested_tracks):
  294. return track_factory.get([artist], [album], track_without_nested_tracks)
  295. @pytest.fixture(scope='session')
  296. def track_without_artists(track_factory, album):
  297. return track_factory.get([], [album])
  298. @pytest.fixture(scope='session')
  299. def track_without_albums(track_factory, artist):
  300. return track_factory.get([artist], [])
  301. @pytest.fixture(scope='session')
  302. def track_without_artists_and_albums(track_factory):
  303. return track_factory.get([], [])
  304. @pytest.fixture(scope='session')
  305. def track_without_nested_tracks(artist, album, track_factory):
  306. return track_factory.get([artist], [album])
  307. @pytest.fixture(scope='session')
  308. def lyrics_major():
  309. return LyricsMajor(
  310. TestLyricsMajor.id,
  311. TestLyricsMajor.name,
  312. TestLyricsMajor.pretty_name,
  313. )
  314. @pytest.fixture(scope='session')
  315. def track_lyrics(lyrics_major):
  316. return TrackLyrics(
  317. TestTrackLyrics.download_url,
  318. TestTrackLyrics.lyric_id,
  319. TestTrackLyrics.external_lyric_id,
  320. TestTrackLyrics.writer,
  321. lyrics_major,
  322. )
  323. @pytest.fixture(scope='session')
  324. def album_factory(label, track_position):
  325. class AlbumFactory:
  326. def get(self, artists, volumes, albums=None, deprecation=None):
  327. return Album(
  328. TestAlbum.id,
  329. TestAlbum.error,
  330. TestAlbum.title,
  331. TestAlbum.track_count,
  332. artists,
  333. [label],
  334. TestAlbum.available,
  335. TestAlbum.available_for_premium_users,
  336. TestAlbum.version,
  337. TestAlbum.cover_uri,
  338. TestAlbum.content_warning,
  339. TestAlbum.original_release_year,
  340. TestAlbum.genre,
  341. TestAlbum.text_color,
  342. TestAlbum.short_description,
  343. TestAlbum.description,
  344. TestAlbum.is_premiere,
  345. TestAlbum.is_banner,
  346. TestAlbum.meta_type,
  347. TestAlbum.storage_dir,
  348. TestAlbum.og_image,
  349. TestAlbum.buy,
  350. TestAlbum.recent,
  351. TestAlbum.very_important,
  352. TestAlbum.available_for_mobile,
  353. TestAlbum.available_partially,
  354. TestAlbum.bests,
  355. albums,
  356. TestAlbum.prerolls,
  357. volumes,
  358. TestAlbum.year,
  359. TestAlbum.release_date,
  360. TestAlbum.type,
  361. track_position,
  362. TestAlbum.regions,
  363. TestAlbum.available_as_rbt,
  364. TestAlbum.lyrics_available,
  365. TestAlbum.remember_position,
  366. albums,
  367. TestAlbum.duration_ms,
  368. TestAlbum.explicit,
  369. TestAlbum.start_date,
  370. TestAlbum.likes_count,
  371. deprecation,
  372. TestAlbum.available_regions,
  373. TestAlbum.available_for_options,
  374. )
  375. return AlbumFactory()
  376. @pytest.fixture(scope='session')
  377. def album(album_factory, artist_without_tracks, track_without_albums, album_without_nested_albums, deprecation):
  378. return album_factory.get(
  379. [artist_without_tracks], [[track_without_albums]], [album_without_nested_albums], deprecation
  380. )
  381. @pytest.fixture(scope='session')
  382. def album_without_tracks(album_factory, artist_without_tracks):
  383. return album_factory.get([artist_without_tracks], [])
  384. @pytest.fixture(scope='session')
  385. def album_without_nested_albums(album_factory, artist_without_tracks, track_without_albums):
  386. return album_factory.get([artist_without_tracks], [[track_without_albums]])
  387. @pytest.fixture(scope='session')
  388. def playlist_factory(
  389. user,
  390. cover,
  391. made_for,
  392. track_short,
  393. play_counter,
  394. playlist_absence,
  395. artist,
  396. track_id,
  397. contest,
  398. open_graph_data,
  399. brand,
  400. custom_wave,
  401. pager,
  402. ):
  403. class PlaylistFactory:
  404. def get(self, similar_playlists, last_owner_playlists):
  405. return Playlist(
  406. user,
  407. cover,
  408. made_for,
  409. play_counter,
  410. playlist_absence,
  411. TestPlaylist.uid,
  412. TestPlaylist.kind,
  413. TestPlaylist.title,
  414. TestPlaylist.track_count,
  415. TestPlaylist.tags,
  416. TestPlaylist.revision,
  417. TestPlaylist.snapshot,
  418. TestPlaylist.visibility,
  419. TestPlaylist.collective,
  420. TestPlaylist.url_part,
  421. TestPlaylist.created,
  422. TestPlaylist.modified,
  423. TestPlaylist.available,
  424. TestPlaylist.is_banner,
  425. TestPlaylist.is_premiere,
  426. TestPlaylist.duration_ms,
  427. TestPlaylist.og_image,
  428. TestPlaylist.og_title,
  429. TestPlaylist.og_description,
  430. TestPlaylist.image,
  431. cover,
  432. contest,
  433. TestPlaylist.background_color,
  434. TestPlaylist.text_color,
  435. TestPlaylist.id_for_from,
  436. TestPlaylist.dummy_description,
  437. TestPlaylist.dummy_page_description,
  438. cover,
  439. cover,
  440. open_graph_data,
  441. brand,
  442. TestPlaylist.metrika_id,
  443. TestPlaylist.coauthors,
  444. [artist],
  445. [track_id],
  446. [track_short],
  447. TestPlaylist.prerolls,
  448. TestPlaylist.likes_count,
  449. similar_playlists,
  450. last_owner_playlists,
  451. TestPlaylist.generated_playlist_type,
  452. TestPlaylist.animated_cover_uri,
  453. TestPlaylist.ever_played,
  454. TestPlaylist.description,
  455. TestPlaylist.description_formatted,
  456. TestPlaylist.playlist_uuid,
  457. TestPlaylist.type,
  458. TestPlaylist.ready,
  459. TestPlaylist.is_for_from,
  460. TestPlaylist.regions,
  461. custom_wave,
  462. pager,
  463. )
  464. return PlaylistFactory()
  465. @pytest.fixture(scope='session')
  466. def playlist(playlist_factory, playlist_without_nested_playlists):
  467. return playlist_factory.get([playlist_without_nested_playlists], [playlist_without_nested_playlists])
  468. @pytest.fixture(scope='session')
  469. def playlist_without_nested_playlists(playlist_factory):
  470. return playlist_factory.get([], [])
  471. @pytest.fixture(scope='session')
  472. def generated_playlist(playlist):
  473. return GeneratedPlaylist(
  474. TestGeneratedPlaylist.type,
  475. TestGeneratedPlaylist.ready,
  476. TestGeneratedPlaylist.notify,
  477. playlist,
  478. TestGeneratedPlaylist.description,
  479. TestGeneratedPlaylist.preview_description,
  480. )
  481. @pytest.fixture(scope='session')
  482. def client():
  483. return Client()
  484. @pytest.fixture(scope='session')
  485. def tag():
  486. return Tag(TestTag.id_, TestTag.value, TestTag.name, TestTag.og_description, TestTag.og_image)
  487. @pytest.fixture(scope='session')
  488. def brand():
  489. return Brand(
  490. TestBrand.image,
  491. TestBrand.background,
  492. TestBrand.reference,
  493. TestBrand.pixels,
  494. TestBrand.theme,
  495. TestBrand.playlist_theme,
  496. TestBrand.button,
  497. )
  498. @pytest.fixture(scope='session')
  499. def track_with_ads(track):
  500. return TrackWithAds(TestTrackWithAds.type, track)
  501. @pytest.fixture(scope='session')
  502. def day(event, track_with_ads, track):
  503. return Day(TestDay.day, [event], [track_with_ads], [track])
  504. @pytest.fixture(scope='session')
  505. def track_short():
  506. return TrackShort(TestTrackShort.id, TestTrackShort.timestamp, TestTrackShort.album_id)
  507. @pytest.fixture(scope='session')
  508. def track_short_old(track_id):
  509. return TrackShortOld(track_id, TestTrackShortOld.timestamp)
  510. @pytest.fixture(scope='session')
  511. def video():
  512. return Video(
  513. TestVideo.title,
  514. TestVideo.cover,
  515. TestVideo.embed_url,
  516. TestVideo.provider,
  517. TestVideo.provider_video_id,
  518. TestVideo.youtube_url,
  519. TestVideo.thumbnail_url,
  520. TestVideo.duration,
  521. TestVideo.text,
  522. TestVideo.html_auto_play_video_player,
  523. TestVideo.regions,
  524. )
  525. @pytest.fixture(scope='session')
  526. def vinyl():
  527. return Vinyl(
  528. TestVinyl.url,
  529. TestVinyl.title,
  530. TestVinyl.year,
  531. TestVinyl.price,
  532. TestVinyl.media,
  533. TestVinyl.offer_id,
  534. TestVinyl.artist_ids,
  535. TestVinyl.picture,
  536. )
  537. @pytest.fixture(scope='session')
  538. def play_context(track_short_old):
  539. return PlayContext(
  540. TestPlayContext.client_, TestPlayContext.context, TestPlayContext.context_item, [track_short_old]
  541. )
  542. @pytest.fixture(scope='session')
  543. def play_contexts_data(track_short_old):
  544. return PlayContextsData([track_short_old])
  545. @pytest.fixture(scope='session')
  546. def enum(value):
  547. return Enum(TestEnum.type, TestEnum.name, [value])
  548. @pytest.fixture(scope='session')
  549. def icon():
  550. return Icon(TestIcon.background_color, TestIcon.image_url)
  551. @pytest.fixture(scope='session')
  552. def cover():
  553. return Cover(
  554. TestCover.type,
  555. TestCover.uri,
  556. TestCover.items_uri,
  557. TestCover.dir,
  558. TestCover.version,
  559. TestCover.custom,
  560. TestCover.is_custom,
  561. TestCover.copyright_name,
  562. TestCover.copyright_cline,
  563. TestCover.prefix,
  564. TestCover.error,
  565. )
  566. @pytest.fixture(scope='session')
  567. def open_graph_data(cover):
  568. return OpenGraphData(TestOpenGraphData.title, TestOpenGraphData.description, cover)
  569. @pytest.fixture(scope='session')
  570. def meta_data():
  571. return MetaData(
  572. TestMetaData.album,
  573. TestMetaData.volume,
  574. TestMetaData.year,
  575. TestMetaData.number,
  576. TestMetaData.genre,
  577. TestMetaData.lyricist,
  578. TestMetaData.version,
  579. TestMetaData.composer,
  580. )
  581. @pytest.fixture(scope='session')
  582. def licence_text_part():
  583. return LicenceTextPart(TestLicenceTextPart.text, TestLicenceTextPart.url)
  584. @pytest.fixture(scope='session')
  585. def link():
  586. return Link(TestLink.title, TestLink.href, TestLink.type, TestLink.social_network)
  587. @pytest.fixture(scope='session')
  588. def invocation_info():
  589. return InvocationInfo(
  590. TestInvocationInfo.hostname, TestInvocationInfo.req_id, TestInvocationInfo.exec_duration_millis
  591. )
  592. @pytest.fixture(scope='session')
  593. def settings(product, price):
  594. return Settings([product], [product], TestSettings.web_payment_url, TestSettings.promo_codes_enabled, price)
  595. @pytest.fixture(scope='session')
  596. def counts():
  597. return Counts(TestCounts.tracks, TestCounts.direct_albums, TestCounts.also_albums, TestCounts.also_tracks)
  598. @pytest.fixture(scope='session')
  599. def description():
  600. return Description(TestDescription.text, TestDescription.uri)
  601. @pytest.fixture(scope='session')
  602. def deprecation():
  603. return Deprecation(TestDeprecation.target_album_id, TestDeprecation.status, TestDeprecation.done)
  604. @pytest.fixture(scope='session')
  605. def pager():
  606. return Pager(TestPager.total, TestPager.page, TestPager.per_page)
  607. @pytest.fixture(scope='session')
  608. def artist_event(artist, track):
  609. return ArtistEvent(artist, [track], [artist], TestArtistEvent.subscribed)
  610. @pytest.fixture(scope='session')
  611. def album_event(album, track):
  612. return AlbumEvent(album, [track])
  613. @pytest.fixture(scope='session')
  614. def video_supplement():
  615. return VideoSupplement(
  616. TestVideoSupplement.cover,
  617. TestVideoSupplement.provider,
  618. TestVideoSupplement.title,
  619. TestVideoSupplement.provider_video_id,
  620. TestVideoSupplement.url,
  621. TestVideoSupplement.embed_url,
  622. TestVideoSupplement.embed,
  623. )
  624. @pytest.fixture(scope='session')
  625. def ratings():
  626. return Ratings(TestRatings.month, TestRatings.week, TestRatings.day)
  627. @pytest.fixture(scope='session')
  628. def made_for(user, case_forms):
  629. return MadeFor(user, case_forms)
  630. @pytest.fixture(scope='session')
  631. def play_counter():
  632. return PlayCounter(TestPlayCounter.value, TestPlayCounter.description, TestPlayCounter.updated)
  633. @pytest.fixture(scope='session')
  634. def playlist_absence():
  635. return PlaylistAbsence(TestPlaylistAbsence.kind, TestPlaylistAbsence.reason)
  636. @pytest.fixture(scope='session')
  637. def context():
  638. return Context(TestContext.type_, TestContext.id_, TestContext.description)
  639. @pytest.fixture(scope='session')
  640. def case_forms():
  641. return CaseForms(
  642. TestCaseForms.nominative,
  643. TestCaseForms.genitive,
  644. TestCaseForms.dative,
  645. TestCaseForms.accusative,
  646. TestCaseForms.instrumental,
  647. TestCaseForms.prepositional,
  648. )
  649. @pytest.fixture(scope='session')
  650. def lyrics():
  651. return Lyrics(
  652. TestLyrics.id,
  653. TestLyrics.lyrics,
  654. TestLyrics.full_lyrics,
  655. TestLyrics.has_rights,
  656. TestLyrics.show_translation,
  657. TestLyrics.text_language,
  658. TestLyrics.url,
  659. )
  660. @pytest.fixture(scope='session')
  661. def poetry_lover_match():
  662. return PoetryLoverMatch(TestPoetryLoverMatch.begin, TestPoetryLoverMatch.end, TestPoetryLoverMatch.line)
  663. @pytest.fixture(scope='session')
  664. def images():
  665. return Images(TestImages._208x208, TestImages._300x300)
  666. @pytest.fixture(scope='session')
  667. def normalization():
  668. return Normalization(TestNormalization.gain, TestNormalization.peak)
  669. @pytest.fixture(scope='session')
  670. def mix_link():
  671. return MixLink(
  672. TestMixLink.title,
  673. TestMixLink.url,
  674. TestMixLink.url_scheme,
  675. TestMixLink.text_color,
  676. TestMixLink.background_color,
  677. TestMixLink.background_image_uri,
  678. TestMixLink.cover_white,
  679. TestMixLink.cover_uri,
  680. )
  681. @pytest.fixture(scope='session')
  682. def title():
  683. return Title(TestTitle.title, TestTitle.full_title)
  684. @pytest.fixture(scope='session')
  685. def personal_playlists_data():
  686. return PersonalPlaylistsData(TestPersonalPlaylistsData.is_wizard_passed)
  687. @pytest.fixture(scope='session')
  688. def promotion():
  689. return Promotion(
  690. TestPromotion.promo_id,
  691. TestPromotion.title,
  692. TestPromotion.subtitle,
  693. TestPromotion.heading,
  694. TestPromotion.url,
  695. TestPromotion.url_scheme,
  696. TestPromotion.text_color,
  697. TestPromotion.gradient,
  698. TestPromotion.image,
  699. )
  700. @pytest.fixture(scope='session')
  701. def discrete_scale(value):
  702. return DiscreteScale(TestDiscreteScale.type, TestDiscreteScale.name, value, value)
  703. @pytest.fixture(scope='session')
  704. def major():
  705. return Major(TestMajor.id, TestMajor.name)
  706. @pytest.fixture(scope='session')
  707. def permissions():
  708. return Permissions(TestPermissions.until, TestPermissions.values, TestPermissions.default)
  709. @pytest.fixture(scope='session')
  710. def auto_renewable(product, user):
  711. return AutoRenewable(
  712. TestAutoRenewable.expires,
  713. TestAutoRenewable.vendor,
  714. TestAutoRenewable.vendor_help_url,
  715. product,
  716. TestAutoRenewable.finished,
  717. user,
  718. TestAutoRenewable.product_id,
  719. TestAutoRenewable.order_id,
  720. )
  721. @pytest.fixture(scope='session')
  722. def passport_phone():
  723. return PassportPhone(TestPassportPhone.phone)
  724. @pytest.fixture(scope='session')
  725. def renewable_remainder():
  726. return RenewableRemainder(TestRenewableRemainder.days)
  727. @pytest.fixture(scope='session')
  728. def user():
  729. return User(
  730. TestUser.uid,
  731. TestUser.login,
  732. TestUser.name,
  733. TestUser.display_name,
  734. TestUser.full_name,
  735. TestUser.sex,
  736. TestUser.verified,
  737. TestUser.regions,
  738. )
  739. @pytest.fixture(scope='session')
  740. def account(passport_phone):
  741. return Account(
  742. TestAccount.now,
  743. TestAccount.service_available,
  744. TestAccount.region,
  745. TestAccount.uid,
  746. TestAccount.login,
  747. TestAccount.full_name,
  748. TestAccount.second_name,
  749. TestAccount.first_name,
  750. TestAccount.display_name,
  751. TestAccount.hosted_user,
  752. TestAccount.birthday,
  753. [passport_phone],
  754. TestAccount.registered_at,
  755. TestAccount.has_info_for_app_metrica,
  756. TestAccount.child,
  757. )
  758. @pytest.fixture(scope='session')
  759. def plus():
  760. return Plus(TestPlus.has_plus, TestPlus.is_tutorial_completed)
  761. @pytest.fixture(scope='session')
  762. def price():
  763. return Price(TestPrice.amount, TestPrice.currency)
  764. @pytest.fixture(scope='session')
  765. def subscription(renewable_remainder, auto_renewable, operator, non_auto_renewable):
  766. return Subscription(
  767. renewable_remainder,
  768. [auto_renewable],
  769. [auto_renewable],
  770. TestSubscription.had_any_subscription,
  771. [operator],
  772. non_auto_renewable,
  773. TestSubscription.can_start_trial,
  774. TestSubscription.mcdonalds,
  775. TestSubscription.end,
  776. )
  777. @pytest.fixture(scope='session')
  778. def non_auto_renewable():
  779. return NonAutoRenewable(TestNonAutoRenewable.start, TestNonAutoRenewable.end)
  780. @pytest.fixture(scope='session')
  781. def deactivation():
  782. return Deactivation(TestDeactivation.method, TestDeactivation.instructions)
  783. @pytest.fixture(scope='session')
  784. def operator(deactivation):
  785. return Operator(
  786. TestOperator.product_id,
  787. TestOperator.phone,
  788. TestOperator.payment_regularity,
  789. [deactivation],
  790. TestOperator.title,
  791. TestOperator.suspended,
  792. )
  793. @pytest.fixture(scope='session')
  794. def rotor_settings():
  795. return RotorSettings(
  796. TestRotorSettings.language,
  797. TestRotorSettings.diversity,
  798. TestRotorSettings.mood,
  799. TestRotorSettings.energy,
  800. TestRotorSettings.mood_energy,
  801. )
  802. @pytest.fixture(scope='session')
  803. def product(price, licence_text_part):
  804. return Product(
  805. TestProduct.product_id,
  806. TestProduct.type,
  807. TestProduct.duration,
  808. TestProduct.trial_duration,
  809. TestProduct.feature,
  810. TestProduct.debug,
  811. TestProduct.plus,
  812. price,
  813. TestProduct.common_period_duration,
  814. TestProduct.cheapest,
  815. TestProduct.title,
  816. TestProduct.family_sub,
  817. TestProduct.fb_image,
  818. TestProduct.fb_name,
  819. TestProduct.family,
  820. TestProduct.features,
  821. TestProduct.description,
  822. TestProduct.available,
  823. TestProduct.trial_available,
  824. TestProduct.trial_period_duration,
  825. TestProduct.intro_period_duration,
  826. price,
  827. TestProduct.start_period_duration,
  828. price,
  829. [licence_text_part],
  830. TestProduct.vendor_trial_available,
  831. TestProduct.button_text,
  832. TestProduct.button_additional_text,
  833. TestProduct.payment_method_types,
  834. )
  835. @pytest.fixture(scope='session')
  836. def playlist_id():
  837. return PlaylistId(TestPlaylistId.uid, TestPlaylistId.kind)
  838. @pytest.fixture(scope='session')
  839. def contest():
  840. return Contest(
  841. TestContest.contest_id, TestContest.status, TestContest.can_edit, TestContest.sent, TestContest.withdrawn
  842. )
  843. @pytest.fixture(scope='session', params=[True, False])
  844. def label(request):
  845. if request.param:
  846. return Label(TestLabel.id, TestLabel.name)
  847. return TestLabel.another_representation_of_label
  848. @pytest.fixture(scope='session')
  849. def track_position():
  850. return TrackPosition(TestTrackPosition.volume, TestTrackPosition.index)
  851. @pytest.fixture(scope='session')
  852. def status(account, permissions, subscription, plus, station_data, alert):
  853. return Status(
  854. account,
  855. permissions,
  856. TestStatus.advertisement,
  857. subscription,
  858. TestStatus.cache_limit,
  859. TestStatus.subeditor,
  860. TestStatus.subeditor_level,
  861. plus,
  862. TestStatus.default_email,
  863. TestStatus.skips_per_hour,
  864. TestStatus.station_exists,
  865. station_data,
  866. alert,
  867. TestStatus.premium_region,
  868. TestStatus.experiment,
  869. TestStatus.pretrial_active,
  870. TestStatus.userhash,
  871. )
  872. @pytest.fixture(scope='session')
  873. def station_data():
  874. return StationData(TestStationData.name)
  875. @pytest.fixture(scope='session')
  876. def alert_button():
  877. return AlertButton(TestAlertButton.text, TestAlertButton.bg_color, TestAlertButton.text_color, TestAlertButton.uri)
  878. @pytest.fixture(scope='session')
  879. def alert(alert_button):
  880. return Alert(
  881. TestAlert.alert_id,
  882. TestAlert.text,
  883. TestAlert.bg_color,
  884. TestAlert.text_color,
  885. TestAlert.alert_type,
  886. alert_button,
  887. TestAlert.close_button,
  888. )
  889. @pytest.fixture(scope='session')
  890. def chart(track_id):
  891. return Chart(
  892. TestChart.position, TestChart.progress, TestChart.listeners, TestChart.shift, TestChart.bg_color, track_id
  893. )
  894. @pytest.fixture(scope='session')
  895. def event(track, artist_event, album_event):
  896. return Event(
  897. TestEvent.id,
  898. TestEvent.type,
  899. TestEvent.type_for_from,
  900. TestEvent.title,
  901. [track],
  902. [artist_event],
  903. [album_event],
  904. TestEvent.message,
  905. TestEvent.device,
  906. TestEvent.tracks_count,
  907. TestEvent.genre,
  908. )
  909. @pytest.fixture(scope='session')
  910. def chart_info_menu_item():
  911. return ChartInfoMenuItem(TestChartInfoMenuItem.title, TestChartInfoMenuItem.url, TestChartInfoMenuItem.selected)
  912. @pytest.fixture(scope='session')
  913. def chart_info_menu(chart_info_menu_item):
  914. return ChartInfoMenu([chart_info_menu_item])
  915. @pytest.fixture(scope='session')
  916. def chart_info(playlist, chart_info_menu):
  917. return ChartInfo(
  918. TestChartInfo.id,
  919. TestChartInfo.type,
  920. TestChartInfo.type_for_from,
  921. TestChartInfo.title,
  922. chart_info_menu,
  923. playlist,
  924. TestChartInfo.chart_description,
  925. )
  926. @pytest.fixture(scope='session')
  927. def track_id():
  928. return TrackId(TestTrackId.id, TestTrackId.track_id, TestTrackId.album_id, TestTrackId.from_)
  929. @pytest.fixture(scope='session')
  930. def value():
  931. return Value(TestValue.value, TestValue.name)
  932. @pytest.fixture(scope='session')
  933. def id_():
  934. return Id(TestId.type, TestId.tag)
  935. @pytest.fixture(scope='session')
  936. def sequence(track):
  937. return Sequence(TestSequence.type, track, TestSequence.liked)
  938. @pytest.fixture(scope='session')
  939. def station(id_, icon, restrictions):
  940. return Station(
  941. id_,
  942. TestStation.name,
  943. icon,
  944. icon,
  945. icon,
  946. TestStation.id_for_from,
  947. restrictions,
  948. restrictions,
  949. TestStation.full_image_url,
  950. TestStation.mts_full_image_url,
  951. id_,
  952. )
  953. @pytest.fixture(scope='session')
  954. def shot_type():
  955. return ShotType(TestShotType.id, TestShotType.title)
  956. @pytest.fixture(scope='session')
  957. def shot_data(shot_type):
  958. return ShotData(TestShotData.cover_uri, TestShotData.mds_url, TestShotData.shot_text, shot_type)
  959. @pytest.fixture(scope='session')
  960. def shot(shot_data):
  961. return Shot(TestShot.order, TestShot.played, shot_data, TestShot.shot_id, TestShot.status)
  962. @pytest.fixture(scope='session')
  963. def chart_item(track, chart):
  964. return ChartItem(track, chart)
  965. @pytest.fixture(scope='session')
  966. def station_result(station, rotor_settings, ad_params):
  967. return StationResult(
  968. station,
  969. rotor_settings,
  970. rotor_settings,
  971. ad_params,
  972. TestStationResult.explanation,
  973. TestStationResult.prerolls,
  974. TestStationResult.rup_title,
  975. TestStationResult.rup_description,
  976. TestStationResult.custom_name,
  977. )
  978. @pytest.fixture(scope='session')
  979. def ad_params():
  980. return AdParams(
  981. TestAdParams.partner_id,
  982. TestAdParams.category_id,
  983. TestAdParams.page_ref,
  984. TestAdParams.target_ref,
  985. TestAdParams.other_params,
  986. TestAdParams.ad_volume,
  987. TestAdParams.genre_id,
  988. TestAdParams.genre_name,
  989. )
  990. @pytest.fixture(scope='session')
  991. def restrictions(enum, discrete_scale):
  992. return Restrictions(enum, enum, discrete_scale, discrete_scale, enum)
  993. @pytest.fixture(scope='session')
  994. def results(
  995. track,
  996. artist,
  997. album,
  998. playlist,
  999. video,
  1000. generated_playlist,
  1001. promotion,
  1002. chart_item,
  1003. play_context,
  1004. mix_link,
  1005. personal_playlists_data,
  1006. play_contexts_data,
  1007. user,
  1008. ):
  1009. return {
  1010. 1: track,
  1011. 2: artist,
  1012. 3: album,
  1013. 4: playlist,
  1014. 5: video,
  1015. 6: generated_playlist,
  1016. 7: promotion,
  1017. 8: chart_item,
  1018. 9: play_context,
  1019. 10: mix_link,
  1020. 11: personal_playlists_data,
  1021. 12: play_contexts_data,
  1022. 13: user,
  1023. 14: album,
  1024. 15: track,
  1025. }
  1026. @pytest.fixture(scope='session')
  1027. def types():
  1028. return {
  1029. 1: 'track',
  1030. 2: 'artist',
  1031. 3: 'album',
  1032. 4: 'playlist',
  1033. 5: 'video',
  1034. 6: 'personal-playlist',
  1035. 7: 'promotion',
  1036. 8: 'chart-item',
  1037. 9: 'play-context',
  1038. 10: 'mix-link',
  1039. 11: 'personal-playlists',
  1040. 12: 'play-contexts',
  1041. 13: 'user',
  1042. 14: 'podcast',
  1043. 15: 'podcast_episode',
  1044. }
  1045. @pytest.fixture(scope='session', params=[1, 2, 3, 4, 5, 13, 14, 15])
  1046. def result_with_type(request, results, types):
  1047. return results[request.param], types[request.param]
  1048. @pytest.fixture(scope='session', params=[1, 2, 3, 4, 5, 13, 14, 15])
  1049. def best(request, results, types):
  1050. return Best(types[request.param], results[request.param], TestBest.text)
  1051. @pytest.fixture(scope='session', params=[1, 2, 3, 4, 5, 13, 14, 15])
  1052. def best_with_result(request, results, types):
  1053. return Best(types[request.param], results[request.param], TestBest.text), results[request.param]
  1054. @pytest.fixture(scope='session', params=[3, 4, 6, 7, 8, 9, 10])
  1055. def block_entity(request, results, types):
  1056. return BlockEntity(TestBlockEntity.id, types[request.param], results[request.param])
  1057. @pytest.fixture(scope='session')
  1058. def block(block_entity, data_with_type):
  1059. data, type_ = data_with_type
  1060. return Block(
  1061. TestBlock.id, type_, TestBlock.type_for_from, TestBlock.title, [block_entity], TestBlock.description, data
  1062. )
  1063. @pytest.fixture(scope='session', params=[11, 12])
  1064. def data(request, results):
  1065. return results[request.param]
  1066. @pytest.fixture(scope='session', params=[11, 12])
  1067. def data_with_type(request, results, types):
  1068. return results[request.param], types[request.param]
  1069. @pytest.fixture(scope='session', params=[1, 2, 3, 4, 5])
  1070. def search_result_with_results_and_type(request, types, results):
  1071. return (
  1072. SearchResult(
  1073. types[request.param],
  1074. TestSearchResult.total,
  1075. TestSearchResult.per_page,
  1076. TestSearchResult.order,
  1077. [results[request.param]],
  1078. ),
  1079. [results[request.param]],
  1080. types[request.param],
  1081. )
  1082. @pytest.fixture(scope='session')
  1083. def custom_wave():
  1084. return CustomWave(TestCustomWave.title, TestCustomWave.animation_url, TestCustomWave.position)
  1085. @pytest.fixture(scope='session')
  1086. def r_128():
  1087. return R128(TestR128.i, TestR128.tp)
  1088. @pytest.fixture(scope='session')
  1089. def lyrics_info():
  1090. return LyricsInfo(TestLyricsInfo.has_available_sync_lyrics, TestLyricsInfo.has_available_text_lyrics)
  1091. @pytest.fixture(scope='session')
  1092. def stats():
  1093. return Stats(TestStats.last_month_listeners, TestStats.last_month_listeners_delta)