mirror of https://github.com/MingweiSamuel/Riven
test: update tests and documentation for removal of summoner names
parent
ce439b881e
commit
d8b04b5c86
19
README.md
19
README.md
|
@ -35,18 +35,25 @@ rt.block_on(async {
|
|||
let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
|
||||
let riot_api = RiotApi::new(api_key);
|
||||
|
||||
// Get summoner data.
|
||||
let summoner = riot_api.summoner_v4()
|
||||
.get_by_summoner_name(PlatformRoute::NA1, "잘 못").await
|
||||
// The region.
|
||||
let platform = PlatformRoute::NA1;
|
||||
|
||||
// Get account data.
|
||||
let account = riot_api.account_v1()
|
||||
.get_by_riot_id(platform.to_regional(), "잘 못", "NA1").await
|
||||
.expect("Get summoner failed.")
|
||||
.expect("There is no summoner with that name.");
|
||||
|
||||
// Print summoner name.
|
||||
println!("{} Champion Masteries:", summoner.name);
|
||||
// Print account name#tag.
|
||||
println!(
|
||||
"{}#{} Champion Masteries:",
|
||||
account.game_name.unwrap_or_default(),
|
||||
account.tag_line.unwrap_or_default(),
|
||||
);
|
||||
|
||||
// Get champion mastery data.
|
||||
let masteries = riot_api.champion_mastery_v4()
|
||||
.get_all_champion_masteries_by_puuid(PlatformRoute::NA1, &summoner.puuid).await
|
||||
.get_all_champion_masteries_by_puuid(platform, &account.puuid).await
|
||||
.expect("Get champion masteries failed.");
|
||||
|
||||
// Print champion masteries.
|
||||
|
|
|
@ -47,18 +47,25 @@
|
|||
//! let api_key = std::env!("RGAPI_KEY"); // "RGAPI-01234567-89ab-cdef-0123-456789abcdef";
|
||||
//! let riot_api = RiotApi::new(api_key);
|
||||
//!
|
||||
//! // Get summoner data.
|
||||
//! let summoner = riot_api.summoner_v4()
|
||||
//! .get_by_summoner_name(PlatformRoute::NA1, "잘 못").await
|
||||
//! // The region.
|
||||
//! let platform = PlatformRoute::NA1;
|
||||
//!
|
||||
//! // Get account data.
|
||||
//! let account = riot_api.account_v1()
|
||||
//! .get_by_riot_id(platform.to_regional(), "잘 못", "NA1").await
|
||||
//! .expect("Get summoner failed.")
|
||||
//! .expect("There is no summoner with that name.");
|
||||
//!
|
||||
//! // Print summoner name.
|
||||
//! println!("{} Champion Masteries:", summoner.name);
|
||||
//! // Print account name#tag.
|
||||
//! println!(
|
||||
//! "{}#{} Champion Masteries:",
|
||||
//! account.game_name.unwrap_or_default(),
|
||||
//! account.tag_line.unwrap_or_default(),
|
||||
//! );
|
||||
//!
|
||||
//! // Get champion mastery data.
|
||||
//! let masteries = riot_api.champion_mastery_v4()
|
||||
//! .get_all_champion_masteries_by_puuid(PlatformRoute::NA1, &summoner.puuid).await
|
||||
//! .get_all_champion_masteries_by_puuid(platform, &account.puuid).await
|
||||
//! .expect("Get champion masteries failed.");
|
||||
//!
|
||||
//! // Print champion masteries.
|
||||
|
|
|
@ -30,7 +30,7 @@ async fn summoner_get_kanjikana() -> Result<(), String> {
|
|||
.await
|
||||
.map_err(|e| e.to_string())?
|
||||
.ok_or_else(|| "Failed to get myheadhard".to_owned())?;
|
||||
rassert_eq!("私の頭がかたい", s.name);
|
||||
rassert!(0 < s.puuid.len());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -85,10 +85,7 @@ async fn tft_combo() -> Result<(), String> {
|
|||
.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
|
||||
);
|
||||
println!("Top player has `puuid` {}.", top_player.puuid);
|
||||
let match_ids = riot_api().tft_match_v1().get_match_ids_by_puuid(
|
||||
ROUTE.to_regional(),
|
||||
&top_player.puuid,
|
||||
|
|
|
@ -4,14 +4,9 @@ use riven::models::summoner_v4::*;
|
|||
use testutils::*;
|
||||
|
||||
fn validate_summoners(s1: Summoner, s2: Summoner) -> Result<(), String> {
|
||||
rassert_eq!(s1.name, s2.name, "Names didn't match {}.", "");
|
||||
rassert_eq!(s1.id, s2.id, "SummonerId didn't match {}.", "");
|
||||
rassert_eq!(
|
||||
s1.account_id,
|
||||
s2.account_id,
|
||||
"AccountId didn't match {}.",
|
||||
""
|
||||
);
|
||||
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(())
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mod testutils;
|
||||
|
||||
use futures::future::join_all;
|
||||
use riven::consts::*;
|
||||
use riven::models::summoner_v4::Summoner;
|
||||
use testutils::*;
|
||||
|
||||
const ROUTE: PlatformRoute = PlatformRoute::TR1;
|
||||
|
@ -19,16 +19,29 @@ async fn league_summoner_bulk_test() -> Result<(), String> {
|
|||
league_list.entries.len()
|
||||
);
|
||||
|
||||
let summoner_vec = join_all(league_list.entries.iter().take(50).map(|entry| {
|
||||
riot_api()
|
||||
let summoner_vec = join_all(league_list.entries.iter().take(50).map(|entry| async move {
|
||||
let summoner = riot_api()
|
||||
.summoner_v4()
|
||||
.get_by_summoner_id(ROUTE, &entry.summoner_id)
|
||||
.await?;
|
||||
let account = riot_api()
|
||||
.account_v1()
|
||||
.get_by_puuid(ROUTE.to_regional(), &summoner.puuid)
|
||||
.await;
|
||||
Ok(account)
|
||||
}))
|
||||
.await;
|
||||
|
||||
for (i, s) in summoner_vec.into_iter().enumerate() {
|
||||
let summoner: Summoner = s.map_err(|e| e.to_string())?;
|
||||
println!("{}: {}", i + 1, summoner.name);
|
||||
let account = s
|
||||
.and_then(std::convert::identity)
|
||||
.map_err(|e| e.to_string())?;
|
||||
println!(
|
||||
"{}: {}#{}",
|
||||
i + 1,
|
||||
account.game_name.unwrap_or_default(),
|
||||
account.tag_line.unwrap_or_default(),
|
||||
);
|
||||
}
|
||||
|
||||
Ok(())
|
|
@ -292,7 +292,9 @@ pub async fn match_v5_get_timeline(
|
|||
|
||||
pub async fn spectator_v5_combo(route: PlatformRoute) -> Result<(), String> {
|
||||
let featured_p = riot_api().spectator_v5().get_featured_games(route);
|
||||
let featured = featured_p.await.map_err(|e| e.to_string())?;
|
||||
let featured = featured_p
|
||||
.await
|
||||
.map_err(|e| format!("Failed to fetch featured games: {}", e))?;
|
||||
|
||||
if featured.game_list.is_empty() {
|
||||
eprintln!("Featured game list is empty!");
|
||||
|
@ -303,8 +305,8 @@ pub async fn spectator_v5_combo(route: PlatformRoute) -> Result<(), String> {
|
|||
let participant = &featured_game.participants[0];
|
||||
let puuid = participant.puuid.as_ref().ok_or_else(|| {
|
||||
format!(
|
||||
"Summoner in spectator featured game {} missing summoner ID: {}",
|
||||
featured_game.game_id, &participant.summoner_name,
|
||||
"Summoner in spectator featured game {} missing summoner ID. PUUID: {:?}",
|
||||
featured_game.game_id, participant.puuid,
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -321,11 +323,11 @@ pub async fn spectator_v5_combo(route: PlatformRoute) -> Result<(), String> {
|
|||
let participant_match = livegame
|
||||
.participants
|
||||
.iter()
|
||||
.find(|p| p.summoner_name == participant.summoner_name);
|
||||
.find(|p| p.puuid == participant.puuid);
|
||||
rassert!(
|
||||
participant_match.is_some(),
|
||||
"Failed to find summoner in match: {}.",
|
||||
&participant.summoner_name
|
||||
"Failed to find summoner in match with PUUID: {:?}.",
|
||||
participant.puuid
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -344,8 +346,8 @@ pub async fn spectator_tft_v5_combo(route: PlatformRoute) -> Result<(), String>
|
|||
let participant = &featured_game.participants[0];
|
||||
let puuid = participant.puuid.as_ref().ok_or_else(|| {
|
||||
format!(
|
||||
"Summoner in spectator featured game {} missing summoner ID: {}",
|
||||
featured_game.game_id, &participant.summoner_name,
|
||||
"Summoner in spectator featured game {} missing summoner ID. PUUID: {:?}",
|
||||
featured_game.game_id, participant.puuid,
|
||||
)
|
||||
})?;
|
||||
|
||||
|
@ -362,11 +364,11 @@ pub async fn spectator_tft_v5_combo(route: PlatformRoute) -> Result<(), String>
|
|||
let participant_match = livegame
|
||||
.participants
|
||||
.iter()
|
||||
.find(|p| p.summoner_name == participant.summoner_name);
|
||||
.find(|p| p.puuid == participant.puuid);
|
||||
rassert!(
|
||||
participant_match.is_some(),
|
||||
"Failed to find summoner in match: {}.",
|
||||
&participant.summoner_name
|
||||
"Failed to find summoner in match with PUUID: {:?}.",
|
||||
participant.puuid
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
|
|
Loading…
Reference in New Issue