test: remove summoner by-name tests

pull/73/head
Mingwei Samuel 2024-04-23 22:55:16 -07:00
parent c7ce017b54
commit 666786d0c7
6 changed files with 36 additions and 123 deletions

View File

@ -1,25 +0,0 @@
mod testutils;
use riven::consts::*;
use testutils::*;
const ROUTE: PlatformRoute = PlatformRoute::RU;
#[riven_test]
async fn summoner_leagues() -> Result<(), String> {
let sum = riot_api()
.summoner_v4()
.get_by_summoner_name(ROUTE, "d3atomiz3d");
let sum = sum
.await
.map_err(|e| format!("Error getting summoner: {}", e))?
.ok_or_else(|| "Failed to find summoner".to_owned())?;
let p = riot_api()
.league_v4()
.get_league_entries_for_summoner(ROUTE, &sum.id);
let s = p
.await
.map_err(|e| format!("Error getting league entries: {}", e))?;
let _ = s;
Ok(())
}

View File

@ -30,6 +30,15 @@ async fn account_v1_getbyriotid_getbypuuid() -> Result<(), String> {
Ok(()) Ok(())
} }
#[riven_test]
async fn account_v1_getbyriotid_none() -> Result<(), String> {
let p = riot_api()
.account_v1()
.get_by_riot_id(ROUTE, "this account does not exist", "NA1");
rassert!(p.await.map_err(|e| e.to_string())?.is_none());
Ok(())
}
/// Tournament stub test. /// Tournament stub test.
#[riven_test] #[riven_test]
async fn tournamentstub() -> Result<(), String> { async fn tournamentstub() -> Result<(), String> {

View File

@ -20,31 +20,6 @@ static MATCHES: &[&str] = &[
"JP1_419115017", "JP1_419115017",
]; ];
/// Summoner tests.
#[riven_test]
async fn summoner_get_kanjikana() -> Result<(), String> {
let p = riot_api()
.summoner_v4()
.get_by_summoner_name(ROUTE, "私の 頭が かたい");
let s = p
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| "Failed to get myheadhard".to_owned())?;
rassert!(0 < s.puuid.len());
Ok(())
}
// Failure cases.
// /// Make sure get_raw_response(...) with invalid path fails as expected.
// #[riven_test]
// async fn raw_response_invalid -> Result<(), String> {
// let p = riot_api().get_raw_response("summoner-v4.getBySummonerName", Region::JP.into(), "INVALID/PATH".to_owned(), None);
// let r = p.await;
// rassert!(r.is_err());
// Ok(())
// }
/// summoner_v4().get_by_summoner_name(...) normally returns an option. /// summoner_v4().get_by_summoner_name(...) normally returns an option.
/// If we use `get` (instead of `get_optional`) make sure it errors. /// If we use `get` (instead of `get_optional`) make sure it errors.
#[riven_test] #[riven_test]

View File

@ -8,45 +8,49 @@ const ROUTE: PlatformRoute = PlatformRoute::EUW1;
#[riven_test] #[riven_test]
async fn championmastery_getscore_ma5tery() -> Result<(), String> { async fn championmastery_getscore_ma5tery() -> Result<(), String> {
let sum = riot_api() let account = riot_api()
.summoner_v4() .account_v1()
.get_by_summoner_name(ROUTE, "ma5tery"); .get_by_riot_id(RegionalRoute::AMERICAS, "ma5tery", "EUW");
let sum = sum let account = account
.await .await
.map_err(|e| format!("Error getting summoner: {}", e))? .map_err(|e| format!("Error getting summoner: {}", e))?
.ok_or_else(|| "Failed to find summoner".to_owned())?; .ok_or_else(|| "Failed to find summoner".to_owned())?;
let p = riot_api() let masteries = riot_api()
.champion_mastery_v4() .champion_mastery_v4()
.get_champion_mastery_score_by_puuid(ROUTE, &sum.puuid); .get_champion_mastery_score_by_puuid(ROUTE, &account.puuid);
let s = p let masteries = masteries
.await .await
.map_err(|e| format!("Error getting champion mastery score: {}", e))?; .map_err(|e| format!("Error getting champion mastery score: {}", e))?;
rassert!( rassert!(
(969..=1000).contains(&s), (969..=1000).contains(&masteries),
"Unexpected ma5tery score: {}.", "Unexpected ma5tery score: {}.",
s masteries
); );
Ok(()) Ok(())
} }
#[riven_test] #[riven_test]
async fn championmastery_getall_ma5tery() -> Result<(), String> { async fn championmastery_getall_ma5tery() -> Result<(), String> {
let sum = riot_api() let account = riot_api()
.summoner_v4() .account_v1()
.get_by_summoner_name(ROUTE, "ma5tery"); .get_by_riot_id(RegionalRoute::AMERICAS, "ma5tery", "EUW");
let sum = sum let account = account
.await .await
.map_err(|e| format!("Error getting summoner: {}", e))? .map_err(|e| format!("Error getting summoner: {}", e))?
.ok_or_else(|| "Failed to find summoner".to_owned())?; .ok_or_else(|| "Failed to find summoner".to_owned())?;
let p = riot_api() let masteries = riot_api()
.champion_mastery_v4() .champion_mastery_v4()
.get_all_champion_masteries_by_puuid(ROUTE, &sum.puuid); .get_all_champion_masteries_by_puuid(ROUTE, &account.puuid);
let s = p let masteries = masteries
.await .await
.map_err(|e| format!("Error getting all champion masteries: {}", e))?; .map_err(|e| format!("Error getting all champion masteries: {}", e))?;
rassert!(s.len() >= 142, "Expected masteries: {}.", s.len()); rassert!(
masteries.len() >= 142,
"Expected masteries: {}.",
masteries.len()
);
Ok(()) Ok(())
} }

View File

@ -51,27 +51,6 @@ async fn tftmatchv1_getmatch() -> Result<(), String> {
Ok(()) Ok(())
} }
#[riven_test]
async fn tftsummonerv1_getbyname() -> Result<(), String> {
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(())
}
#[riven_test]
async fn tftsummonerv1_getbyname_none() -> Result<(), String> {
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. /// Get top rated player, get some of their matches.
#[riven_test] #[riven_test]
async fn tft_combo() -> Result<(), String> { async fn tft_combo() -> Result<(), String> {

View File

@ -1,39 +1,9 @@
mod testutils; mod testutils;
use riven::consts::*; use riven::consts::*;
use riven::models::summoner_v4::*;
use testutils::*; use testutils::*;
fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
rassert_eq!(s1.puuid, s2.puuid, "PUUIDs didn't match.");
rassert_eq!(s1.id, s2.id, "Summoner IDs didn't match.");
rassert_eq!(s1.account_id, s2.account_id, "Account IDs didn't match.");
Ok(())
}
const ROUTE: PlatformRoute = PlatformRoute::NA1; const ROUTE: PlatformRoute = PlatformRoute::NA1;
// Summoner tests.
#[riven_test]
async fn summoner_double() -> Result<(), String> {
let l1p = riot_api()
.summoner_v4()
.get_by_summoner_name(ROUTE, "lug nuts k");
let l2p = riot_api()
.summoner_v4()
.get_by_summoner_name(ROUTE, "lugnuts k");
let l1 = l1p
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| "'lug nuts k' not found!".to_owned())?;
let l2 = l2p
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| "'lugnuts k' not found!".to_owned())?;
validate_summoners(l1, l2)?;
Ok(())
}
#[riven_test] #[riven_test]
async fn champion_getrotation() -> Result<(), String> { async fn champion_getrotation() -> Result<(), String> {
let p = riot_api().champion_v3().get_champion_info(ROUTE); let p = riot_api().champion_v3().get_champion_info(ROUTE);
@ -65,16 +35,17 @@ async fn leagueexp_get() -> Result<(), String> {
#[riven_test] #[riven_test]
async fn championmasteryv4_lugnutsk() -> Result<(), String> { async fn championmasteryv4_lugnutsk() -> Result<(), String> {
let summoner = riot_api() let account =
.summoner_v4() riot_api()
.get_by_summoner_name(ROUTE, "LugnutsK"); .account_v1()
let summoner = summoner .get_by_riot_id(RegionalRoute::AMERICAS, "LugnutsK", "000");
let account = account
.await .await
.map_err(|e| e.to_string())? .map_err(|e| e.to_string())?
.ok_or_else(|| "'LugnutsK' not found!".to_owned())?; .ok_or_else(|| "'LugnutsK' not found!".to_owned())?;
let masteries = riot_api() let masteries = riot_api()
.champion_mastery_v4() .champion_mastery_v4()
.get_all_champion_masteries_by_puuid(ROUTE, &summoner.puuid); .get_all_champion_masteries_by_puuid(ROUTE, &account.puuid);
let masteries = masteries.await.map_err(|e| e.to_string())?; let masteries = masteries.await.map_err(|e| e.to_string())?;
rassert!(74 <= masteries.len()); rassert!(74 <= masteries.len());
Ok(()) Ok(())