forked from mirror/Riven
Consolidate EUW TFT tests, failing
Add test for https://github.com/MingweiSamuel/Riven/issues/50
This commit is contained in:
parent
563f9e84a7
commit
7f0b63bf92
3 changed files with 110 additions and 59 deletions
|
@ -52,58 +52,5 @@ async_tests!{
|
|||
// }
|
||||
// Ok(())
|
||||
// },
|
||||
|
||||
// TFT tests.
|
||||
// // Don't have acecess to tft-status-v1.
|
||||
// tftstatusv1_getplatformdata: async {
|
||||
// let p = RIOT_API.tft_status_v1().get_platform_data(ROUTE);
|
||||
// let _s = p.await.map_err(|e| e.to_string())?;
|
||||
// Ok(())
|
||||
// },
|
||||
tftleaguev1_getchallengerleague: async {
|
||||
let p = RIOT_API.tft_league_v1().get_challenger_league(ROUTE);
|
||||
let l = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(l.entries.len() > 10, "Expected a few challenger players, got: {}.", l.entries.len());
|
||||
Ok(())
|
||||
},
|
||||
tftmatchv1_getmatch: async {
|
||||
let p = RIOT_API.tft_match_v1().get_match(ROUTE.to_regional(), "EUW1_4568680990");
|
||||
let _m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT match.".to_owned())?;
|
||||
Ok(())
|
||||
},
|
||||
tftsummonerv1_getbyname: async {
|
||||
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "相当猥琐");
|
||||
let _s = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT summoner.".to_owned())?;
|
||||
Ok(())
|
||||
},
|
||||
tftsummonerv1_getbyname_none: async {
|
||||
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "this summoner does not exist");
|
||||
rassert!(p.await.map_err(|e| e.to_string())?.is_none());
|
||||
Ok(())
|
||||
},
|
||||
// Get top rated player, get some of their matches.
|
||||
tft_combo: async {
|
||||
let top_players = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
||||
let top_players = top_players.await.map_err(|e| e.to_string())?;
|
||||
rassert!(0 < top_players.len());
|
||||
let top_player_entry = &top_players[0];
|
||||
let top_player = RIOT_API.tft_summoner_v1().get_by_summoner_id(ROUTE, &*top_player_entry.summoner_id);
|
||||
let top_player = top_player.await.map_err(|e| e.to_string())?;
|
||||
println!("Top player is {} with `puuid` {}.", top_player.name, top_player.puuid);
|
||||
let match_ids = RIOT_API.tft_match_v1().get_match_ids_by_puuid(
|
||||
ROUTE.to_regional(), &*top_player.puuid, Some(10), None, None, None);
|
||||
let match_ids = match_ids.await.map_err(|e| e.to_string())?;
|
||||
let match_futures = match_ids.iter().map(|match_id| async move {
|
||||
let result = RIOT_API.tft_match_v1().get_match(ROUTE.to_regional(), &**match_id).await;
|
||||
result.map_err(|e| (match_id.clone(), e))
|
||||
});
|
||||
let matches = futures::future::try_join_all(match_futures).await.map_err(|(match_id, e)| format!("{}: {}", match_id, e))?;
|
||||
for match_opt in matches.iter() {
|
||||
rassert!(match_opt.is_some());
|
||||
let mmatch = match_opt.as_ref().unwrap();
|
||||
rassert!(0 < mmatch.info.participants.len());
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
68
riven/tests/tests_euw_tft.rs
Normal file
68
riven/tests/tests_euw_tft.rs
Normal file
|
@ -0,0 +1,68 @@
|
|||
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
||||
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
||||
|
||||
mod async_tests;
|
||||
mod testutils;
|
||||
use testutils::*;
|
||||
|
||||
use colored::*;
|
||||
|
||||
use riven::consts::*;
|
||||
|
||||
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
||||
|
||||
static TFT_MATCHES: &[&str] = &[
|
||||
"EUW1_6307427444", // https://github.com/MingweiSamuel/Riven/issues/50
|
||||
"EUW1_6307262798",
|
||||
];
|
||||
|
||||
async_tests! {
|
||||
my_runner {
|
||||
tftmatchv1_get_list: async {
|
||||
tft_match_v1_get(ROUTE.to_regional(), TFT_MATCHES).await
|
||||
},
|
||||
|
||||
// // Don't have acecess to tft-status-v1.
|
||||
// tftstatusv1_getplatformdata: async {
|
||||
// let p = RIOT_API.tft_status_v1().get_platform_data(ROUTE);
|
||||
// let _s = p.await.map_err(|e| e.to_string())?;
|
||||
// Ok(())
|
||||
// },
|
||||
tftleaguev1_getchallengerleague: async {
|
||||
let p = RIOT_API.tft_league_v1().get_challenger_league(ROUTE);
|
||||
let l = p.await.map_err(|e| e.to_string())?;
|
||||
rassert!(l.entries.len() > 10, "Expected a few challenger players, got: {}.", l.entries.len());
|
||||
Ok(())
|
||||
},
|
||||
tftmatchv1_getmatch: async {
|
||||
let p = RIOT_API.tft_match_v1().get_match(ROUTE.to_regional(), "EUW1_4568680990");
|
||||
let _m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT match.".to_owned())?;
|
||||
Ok(())
|
||||
},
|
||||
tftsummonerv1_getbyname: async {
|
||||
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "相当猥琐");
|
||||
let _s = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get TFT summoner.".to_owned())?;
|
||||
Ok(())
|
||||
},
|
||||
tftsummonerv1_getbyname_none: async {
|
||||
let p = RIOT_API.tft_summoner_v1().get_by_summoner_name(ROUTE, "this summoner does not exist");
|
||||
rassert!(p.await.map_err(|e| e.to_string())?.is_none());
|
||||
Ok(())
|
||||
},
|
||||
// Get top rated player, get some of their matches.
|
||||
tft_combo: async {
|
||||
let top_players = RIOT_API.tft_league_v1().get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
||||
let top_players = top_players.await.map_err(|e| e.to_string())?;
|
||||
rassert!(0 < top_players.len());
|
||||
let top_player_entry = &top_players[0];
|
||||
let top_player = RIOT_API.tft_summoner_v1().get_by_summoner_id(ROUTE, &*top_player_entry.summoner_id);
|
||||
let top_player = top_player.await.map_err(|e| e.to_string())?;
|
||||
println!("Top player is {} with `puuid` {}.", top_player.name, top_player.puuid);
|
||||
let match_ids = RIOT_API.tft_match_v1().get_match_ids_by_puuid(
|
||||
ROUTE.to_regional(), &*top_player.puuid, Some(10), None, None, None);
|
||||
let match_ids = match_ids.await.map_err(|e| e.to_string())?;
|
||||
tft_match_v1_get(ROUTE.to_regional(), &*match_ids).await?;
|
||||
Ok(())
|
||||
},
|
||||
}
|
||||
}
|
|
@ -23,8 +23,39 @@ pub mod ids {
|
|||
pub const ACCOUNT_ID_LUGNUTSK: &str = "iheZF2uJ50S84Hfq6Ob8GNlJAUmBmac-EsEEWBJjD01q1jQ";
|
||||
}
|
||||
|
||||
pub async fn match_v5_get(route: RegionalRoute, matches: &[&'static str]) -> Result<(), String> {
|
||||
for &matche in matches {
|
||||
pub async fn tft_match_v1_get(route: RegionalRoute, matches: &[impl AsRef<str>]) -> Result<(), String> {
|
||||
let futures = matches.iter().map(|matche| async move {
|
||||
let matche = matche.as_ref();
|
||||
let p = RIOT_API.tft_match_v1().get_match(route, matche);
|
||||
let m = p
|
||||
.await
|
||||
.map_err(|e| format!("Failed to get match {}: {:?}", matche, e))?
|
||||
.ok_or(format!("Match {} not found.", matche))?;
|
||||
|
||||
if matche != &*m.metadata.match_id {
|
||||
return Err(format!(
|
||||
"Bad match id? Sent {}, received {}.",
|
||||
matche, m.metadata.match_id
|
||||
));
|
||||
}
|
||||
if m.metadata.participants.is_empty() {
|
||||
return Err("Match should have participants (metadata).".to_owned());
|
||||
}
|
||||
if m.metadata.participants.len() != m.info.participants.len() {
|
||||
return Err("Match participants do not line up with participant UUIDs.".to_owned());
|
||||
}
|
||||
if m.info.participants.is_empty() {
|
||||
return Err("Match should have participants (info).".to_owned());
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
futures::future::try_join_all(futures).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn match_v5_get(route: RegionalRoute, matches: &[impl AsRef<str>]) -> Result<(), String> {
|
||||
let futures = matches.iter().map(|matche| async move {
|
||||
let matche = matche.as_ref();
|
||||
let p = RIOT_API.match_v5().get_match(route, matche);
|
||||
let m = p
|
||||
.await
|
||||
|
@ -49,15 +80,18 @@ pub async fn match_v5_get(route: RegionalRoute, matches: &[&'static str]) -> Res
|
|||
if m.info.teams.is_empty() {
|
||||
return Err("Match should have teams.".to_owned());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
futures::future::try_join_all(futures).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn match_v5_get_timeline(
|
||||
route: RegionalRoute,
|
||||
matches: &[&'static str],
|
||||
matches: &[impl AsRef<str>],
|
||||
) -> Result<(), String> {
|
||||
for &matche in matches {
|
||||
let futures = matches.iter().map(|matche| async move {
|
||||
let matche = matche.as_ref();
|
||||
let p = RIOT_API.match_v5().get_timeline(route, matche);
|
||||
let m = p
|
||||
.await
|
||||
|
@ -80,6 +114,8 @@ pub async fn match_v5_get_timeline(
|
|||
if m.info.frames.is_empty() {
|
||||
return Err("Match timleine should have frames.".to_owned());
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
});
|
||||
futures::future::try_join_all(futures).await?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue