From 27b1cd1aa70ccb5f57d4a4f3068621d5bf787369 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sun, 16 Jun 2024 00:21:25 +0200 Subject: [PATCH] test: fix tests --- notes/AB_Tests.md | 7 ++-- .../youtube__music_artist_basic.snap | 32 +++++++++---------- .../youtube__music_artist_basic_intl.snap | 30 ++++++++--------- tests/youtube.rs | 19 +++++++++-- 4 files changed, 51 insertions(+), 37 deletions(-) diff --git a/notes/AB_Tests.md b/notes/AB_Tests.md index 8d26b91..a7c8504 100644 --- a/notes/AB_Tests.md +++ b/notes/AB_Tests.md @@ -26,6 +26,7 @@ to the new feature. **Status:** +- Discontinued (0%) - Experimental (<3%) - Common (>3%) - Frequent (>40%) @@ -488,7 +489,7 @@ looks needlessly complex but contains the same parsing-relevant data as the old - **Encountered on:** 29.01.2024 - **Impact:** 🟢 Low - **Endpoint:** browse -- **Status:** Experimental (<1%) +- **Status:** Frequent (55%) YouTube introduced a new data model for channel headers, based on a `"pageHeaderRenderer"`. The new model comes with more needless complexity that needs to @@ -597,7 +598,7 @@ be accomodated. There are also no mobile/TV header images available any more. - **Encountered on:** 29.02.2024 - **Impact:** 🟢 Low - **Endpoint:** browse -- **Status:** Common (6%) +- **Status:** Discontinued (0%) ![A/B test 13 screenshot](./_img/ab_13.png) @@ -609,7 +610,7 @@ cover on the left side of the playlist content. - **Encountered on:** 31.01.2024 - **Impact:** 🟢 Low - **Endpoint:** next -- **Status:** Common (50%) +- **Status:** Frequent (98%) YouTube changed the data model for YouTube comments, now putting the content into a seperate framework update object diff --git a/tests/snapshots/youtube__music_artist_basic.snap b/tests/snapshots/youtube__music_artist_basic.snap index 27a6839..c88198a 100644 --- a/tests/snapshots/youtube__music_artist_basic.snap +++ b/tests/snapshots/youtube__music_artist_basic.snap @@ -6,7 +6,7 @@ MusicArtist( id: "UC7cl4MmM6ZZ2TcFyMk_b4pg", name: "Unheilig", header_image: "[header_image]", - description: Some("Unheilig was a German band that featured a variety of influences, including various pop and electronic styles as well as harder, nihilistic hard rock. The band was founded in 1999 and principally consisted of singer Bernd Heinrich \"Der Graf\" along with various musical partners. He was accompanied for live shows with musicians Christoph \"Licky\" Termühlen, Henning Verlage, and Martin \"Potti\" Potthoff. The group\'s debut, Phosphor, came out in 2000.\n\nFrom Wikipedia (https://en.wikipedia.org/wiki/Unheilig) under Creative Commons Attribution CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/legalcode)"), + description: Some("Unheilig is a German band that draws from a variety of influences, including various pop and electronic styles as well as heavier, nihilistic hard rock. The band was founded in Aachen in 1999 and principally consisted of singer Bernd Heinrich \"Der Graf\" along with various musical partners. He was accompanied for live shows with musicians Christoph \"Licky\" Termühlen, Henning Verlage, and Martin \"Potti\" Potthoff. The group\'s debut, Phosphor, came out in 2000.\n\nFrom Wikipedia (https://en.wikipedia.org/wiki/Unheilig) under Creative Commons Attribution CC-BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/legalcode)"), wikipedia_url: Some("https://en.wikipedia.org/wiki/Unheilig"), subscriber_count: "[subscriber_count]", tracks: "[tracks]", @@ -56,21 +56,6 @@ MusicArtist( year: Some(2008), by_va: false, ), - AlbumItem( - id: "MPREb_88p7e6nBtgz", - name: "Lichter der Stadt", - cover: "[cover]", - artists: [ - ArtistId( - id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), - name: "Unheilig", - ), - ], - artist_id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), - album_type: Single, - year: Some(2012), - by_va: false, - ), AlbumItem( id: "MPREb_Md2aZrjaqHX", name: "Stille Winternacht", @@ -101,6 +86,21 @@ MusicArtist( year: Some(2018), by_va: false, ), + AlbumItem( + id: "MPREb_QEClJsuO9xM", + name: "So wie Du warst", + cover: "[cover]", + artists: [ + ArtistId( + id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), + name: "Unheilig", + ), + ], + artist_id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), + album_type: Single, + year: Some(2012), + by_va: false, + ), AlbumItem( id: "MPREb_QyGCcLWExXj", name: "Als wär\'s das erste Mal (Exklusive Piano Version)", diff --git a/tests/snapshots/youtube__music_artist_basic_intl.snap b/tests/snapshots/youtube__music_artist_basic_intl.snap index 056a221..8a3d210 100644 --- a/tests/snapshots/youtube__music_artist_basic_intl.snap +++ b/tests/snapshots/youtube__music_artist_basic_intl.snap @@ -56,21 +56,6 @@ MusicArtist( year: Some(2008), by_va: false, ), - AlbumItem( - id: "MPREb_88p7e6nBtgz", - name: "[name]", - cover: "[cover]", - artists: [ - ArtistId( - id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), - name: "[name]", - ), - ], - artist_id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), - album_type: Single, - year: Some(2012), - by_va: false, - ), AlbumItem( id: "MPREb_Md2aZrjaqHX", name: "[name]", @@ -101,6 +86,21 @@ MusicArtist( year: Some(2018), by_va: false, ), + AlbumItem( + id: "MPREb_QEClJsuO9xM", + name: "[name]", + cover: "[cover]", + artists: [ + ArtistId( + id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), + name: "[name]", + ), + ], + artist_id: Some("UC7cl4MmM6ZZ2TcFyMk_b4pg"), + album_type: Single, + year: Some(2012), + by_va: false, + ), AlbumItem( id: "MPREb_QyGCcLWExXj", name: "[name]", diff --git a/tests/youtube.rs b/tests/youtube.rs index 086dc52..6f0451e 100644 --- a/tests/youtube.rs +++ b/tests/youtube.rs @@ -14,7 +14,7 @@ use rustypipe::model::{ richtext::ToPlaintext, traits::{FromYtItem, YtStream}, AlbumType, AudioCodec, AudioFormat, AudioTrackType, Channel, Frameset, MusicGenre, MusicItem, - UrlTarget, Verification, VideoCodec, VideoFormat, YouTubeItem, + UrlTarget, Verification, VideoCodec, VideoFormat, VideoId, YouTubeItem, }; use rustypipe::param::{ search_filter::{self, SearchFilter}, @@ -418,6 +418,8 @@ async fn playlist_cont(rp: RustyPipe) { .extend_pages(rp.query(), usize::MAX) .await .unwrap(); + + check_duplicates(&playlist.videos.items); assert_gte(playlist.videos.items.len(), 101, "video items"); assert_gteo(playlist.videos.count, 101, "video count"); } @@ -432,6 +434,7 @@ async fn playlist_cont2(rp: RustyPipe) { .unwrap(); playlist.videos.extend_limit(rp.query(), 101).await.unwrap(); + check_duplicates(&playlist.videos.items); assert_gte(playlist.videos.items.len(), 101, "video items"); assert_gteo(playlist.videos.count, 101, "video count"); } @@ -1527,6 +1530,8 @@ async fn music_playlist_cont(#[case] id: &str, rp: RustyPipe) { playlist.tracks.extend_pages(rp.query(), 5).await.unwrap(); + check_duplicates(&playlist.tracks.items); + let track_count = playlist.track_count.unwrap(); assert_gte(track_count, 100, "tracks"); @@ -1626,8 +1631,7 @@ async fn music_album_not_found(rp: RustyPipe) { #[rstest] #[case::basic_all("basic_all", "UCFKUUtHjT4iq3p0JJA13SOA", true, 15, 1)] -// TODO: wait for A/B test 6 to stabilize -// #[case::basic("basic", "UC7cl4MmM6ZZ2TcFyMk_b4pg", false, 15, 2)] +#[case::basic("basic", "UC7cl4MmM6ZZ2TcFyMk_b4pg", false, 15, 2)] #[case::no_more_albums("no_more_albums", "UCOR4_bSVIXPsGa4BbCSt60Q", true, 15, 0)] #[case::only_singles("only_singles", "UCfwCE5VhPMGxNPFxtVv7lRw", false, 13, 0)] #[case::no_artist("no_artist", "UCh8gHdtzO2tXd593_bjErWg", false, 0, 0)] @@ -2779,3 +2783,12 @@ fn assert_frameset(frameset: &Frameset) { let n = frameset.urls().count() as u32; assert_eq!(n, frameset.page_count); } + +#[track_caller] +fn check_duplicates>(items: &[T]) { + let ids = items + .iter() + .map(|itm| itm.clone().into().id) + .collect::>(); + assert_eq!(ids.len(), items.len(), "duplicate items"); +}