tests: fix tests
This commit is contained in:
parent
745ee01067
commit
c879dcf934
4 changed files with 37 additions and 34 deletions
|
|
@ -79,9 +79,11 @@ pub(crate) struct MusicCardShelf {
|
||||||
|
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
|
#[allow(clippy::enum_variant_names)]
|
||||||
pub(crate) enum MusicResponseItem {
|
pub(crate) enum MusicResponseItem {
|
||||||
MusicResponsiveListItemRenderer(ListMusicItem),
|
MusicResponsiveListItemRenderer(ListMusicItem),
|
||||||
MusicTwoRowItemRenderer(CoverMusicItem),
|
MusicTwoRowItemRenderer(CoverMusicItem),
|
||||||
|
MessageRenderer(serde::de::IgnoredAny),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[serde_as]
|
#[serde_as]
|
||||||
|
|
@ -910,6 +912,7 @@ impl MusicListMapper {
|
||||||
None => Err("could not determine item type".to_owned()),
|
None => Err("could not determine item type".to_owned()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MusicResponseItem::MessageRenderer(_) => Ok(None),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "g0iRiJ_ck48",
|
id: "g0iRiJ_ck48",
|
||||||
name: "Aulë und Yavanna",
|
name: "Aulë und Yavanna",
|
||||||
duration: Some(216),
|
duration: Some(217),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -43,7 +43,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "rREEBXp0y9s",
|
id: "rREEBXp0y9s",
|
||||||
name: "Numenor",
|
name: "Numenor",
|
||||||
duration: Some(224),
|
duration: Some(225),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -64,7 +64,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "zvU5Y8Q19hU",
|
id: "zvU5Y8Q19hU",
|
||||||
name: "Das Mädchen und die Liebe (feat. Santiano)",
|
name: "Das Mädchen und die Liebe (feat. Santiano)",
|
||||||
duration: Some(176),
|
duration: Some(177),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -85,7 +85,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "ARKLrzzTQA0",
|
id: "ARKLrzzTQA0",
|
||||||
name: "Niënna",
|
name: "Niënna",
|
||||||
duration: Some(215),
|
duration: Some(216),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -106,7 +106,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "tstLgN8A_Ng",
|
id: "tstLgN8A_Ng",
|
||||||
name: "Der fahle Mond",
|
name: "Der fahle Mond",
|
||||||
duration: Some(268),
|
duration: Some(269),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -127,7 +127,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "k2DjgQOY3Ts",
|
id: "k2DjgQOY3Ts",
|
||||||
name: "Weise den Weg",
|
name: "Weise den Weg",
|
||||||
duration: Some(202),
|
duration: Some(203),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -148,7 +148,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "azHwhecxEsI",
|
id: "azHwhecxEsI",
|
||||||
name: "Zeit der Sommernächte",
|
name: "Zeit der Sommernächte",
|
||||||
duration: Some(185),
|
duration: Some(186),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -169,7 +169,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "_FcsdYIQ2co",
|
id: "_FcsdYIQ2co",
|
||||||
name: "Märchen enden gut",
|
name: "Märchen enden gut",
|
||||||
duration: Some(226),
|
duration: Some(227),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -190,7 +190,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "27bOWEbshyE",
|
id: "27bOWEbshyE",
|
||||||
name: "Das Mädchen und der Tod",
|
name: "Das Mädchen und der Tod",
|
||||||
duration: Some(207),
|
duration: Some(208),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -211,7 +211,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "riD_3oZwt8w",
|
id: "riD_3oZwt8w",
|
||||||
name: "Wir sehn uns wieder",
|
name: "Wir sehn uns wieder",
|
||||||
duration: Some(211),
|
duration: Some(212),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -232,7 +232,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "8GNvjF3no9s",
|
id: "8GNvjF3no9s",
|
||||||
name: "Tanz mit mir",
|
name: "Tanz mit mir",
|
||||||
duration: Some(179),
|
duration: Some(180),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -253,7 +253,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "YHMFzf1uN2U",
|
id: "YHMFzf1uN2U",
|
||||||
name: "Nachtigall",
|
name: "Nachtigall",
|
||||||
duration: Some(218),
|
duration: Some(219),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -274,7 +274,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "jvV-z5F3oAo",
|
id: "jvV-z5F3oAo",
|
||||||
name: "Gayatri Mantra",
|
name: "Gayatri Mantra",
|
||||||
duration: Some(277),
|
duration: Some(278),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -295,7 +295,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "u8_9cxlrh8k",
|
id: "u8_9cxlrh8k",
|
||||||
name: "Sing mir deine Lieder",
|
name: "Sing mir deine Lieder",
|
||||||
duration: Some(204),
|
duration: Some(205),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -316,7 +316,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "gSvKcvM1Wk0",
|
id: "gSvKcvM1Wk0",
|
||||||
name: "Laurië lantar",
|
name: "Laurië lantar",
|
||||||
duration: Some(202),
|
duration: Some(203),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -337,7 +337,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "wQHgKRJ0pDQ",
|
id: "wQHgKRJ0pDQ",
|
||||||
name: "Wächter vor dem Tor",
|
name: "Wächter vor dem Tor",
|
||||||
duration: Some(222),
|
duration: Some(223),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -358,7 +358,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "Ckz5i6-hzf0",
|
id: "Ckz5i6-hzf0",
|
||||||
name: "Stroh zu Gold",
|
name: "Stroh zu Gold",
|
||||||
duration: Some(177),
|
duration: Some(178),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
@ -379,7 +379,7 @@ MusicAlbum(
|
||||||
TrackItem(
|
TrackItem(
|
||||||
id: "y5zuUgyFqrc",
|
id: "y5zuUgyFqrc",
|
||||||
name: "Sonnenwendnacht",
|
name: "Sonnenwendnacht",
|
||||||
duration: Some(220),
|
duration: Some(221),
|
||||||
cover: [],
|
cover: [],
|
||||||
artists: [
|
artists: [
|
||||||
ArtistId(
|
ArtistId(
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ MusicArtist(
|
||||||
id: "UC7cl4MmM6ZZ2TcFyMk_b4pg",
|
id: "UC7cl4MmM6ZZ2TcFyMk_b4pg",
|
||||||
name: "Unheilig",
|
name: "Unheilig",
|
||||||
header_image: "[header_image]",
|
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"),
|
wikipedia_url: Some("https://en.wikipedia.org/wiki/Unheilig"),
|
||||||
subscriber_count: "[subscriber_count]",
|
subscriber_count: "[subscriber_count]",
|
||||||
tracks: "[tracks]",
|
tracks: "[tracks]",
|
||||||
|
|
|
||||||
|
|
@ -178,13 +178,13 @@ fn check_video_stream(s: impl YtStream) {
|
||||||
false
|
false
|
||||||
)]
|
)]
|
||||||
#[case::live(
|
#[case::live(
|
||||||
"86YLFOog4GM",
|
"jfKfPfyJRdk",
|
||||||
"🌎 Earth From Space Live Stream : Live Views from the ISS",
|
"lofi hip hop radio 📚 - beats to relax/study to",
|
||||||
"The station is crewed by NASA astronauts as well as Russian Cosmonauts",
|
"Listen on Spotify, Apple music and more",
|
||||||
0,
|
0,
|
||||||
"UCakgsb0w7QB0VHdnCc-OVEA",
|
"UCSJ4gkVC6NrvII8umztf0Ow",
|
||||||
"Space Videos",
|
"Lofi Girl",
|
||||||
10,
|
100,
|
||||||
true,
|
true,
|
||||||
true
|
true
|
||||||
)]
|
)]
|
||||||
|
|
@ -661,23 +661,23 @@ fn get_video_details_chapters(rp: RustyPipe) {
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn get_video_details_live(rp: RustyPipe) {
|
fn get_video_details_live(rp: RustyPipe) {
|
||||||
let details = tokio_test::block_on(rp.query().video_details("86YLFOog4GM")).unwrap();
|
let details = tokio_test::block_on(rp.query().video_details("jfKfPfyJRdk")).unwrap();
|
||||||
|
|
||||||
// dbg!(&details);
|
// dbg!(&details);
|
||||||
|
|
||||||
assert_eq!(details.id, "86YLFOog4GM");
|
assert_eq!(details.id, "jfKfPfyJRdk");
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
details.name,
|
details.name,
|
||||||
"🌎 Earth From Space Live Stream : Live Views from the ISS"
|
"lofi hip hop radio 📚 - beats to relax/study to"
|
||||||
);
|
);
|
||||||
let desc = details.description.to_plaintext();
|
let desc = details.description.to_plaintext();
|
||||||
assert!(
|
assert!(
|
||||||
desc.contains("The station is crewed by NASA astronauts as well as Russian Cosmonauts"),
|
desc.contains("Listen on Spotify, Apple music and more"),
|
||||||
"bad description: {desc}"
|
"bad description: {desc}"
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_eq!(details.channel.id, "UCakgsb0w7QB0VHdnCc-OVEA");
|
assert_eq!(details.channel.id, "UCSJ4gkVC6NrvII8umztf0Ow");
|
||||||
assert_eq!(details.channel.name, "Space Videos");
|
assert_eq!(details.channel.name, "Lofi Girl");
|
||||||
assert!(!details.channel.avatar.is_empty(), "no channel avatars");
|
assert!(!details.channel.avatar.is_empty(), "no channel avatars");
|
||||||
assert_eq!(details.channel.verification, Verification::Verified);
|
assert_eq!(details.channel.verification, Verification::Verified);
|
||||||
assert_gte(
|
assert_gte(
|
||||||
|
|
@ -685,11 +685,11 @@ fn get_video_details_live(rp: RustyPipe) {
|
||||||
5_500_000,
|
5_500_000,
|
||||||
"subscribers",
|
"subscribers",
|
||||||
);
|
);
|
||||||
assert_gte(details.view_count, 10, "views");
|
assert_gte(details.view_count, 100, "views");
|
||||||
assert_gte(details.like_count.unwrap(), 872_290, "likes");
|
assert_gte(details.like_count.unwrap(), 1_800_000, "likes");
|
||||||
|
|
||||||
let date = details.publish_date.unwrap();
|
let date = details.publish_date.unwrap();
|
||||||
assert_eq!(date.date(), date!(2021 - 9 - 23));
|
assert_eq!(date.date(), date!(2022 - 7 - 12));
|
||||||
|
|
||||||
assert!(details.is_live);
|
assert!(details.is_live);
|
||||||
assert!(!details.is_ccommons);
|
assert!(!details.is_ccommons);
|
||||||
|
|
|
||||||
Reference in a new issue