2021-06-30 23:34:34 +00:00
|
|
|
mod testutils;
|
|
|
|
use riven::consts::*;
|
|
|
|
use riven::models::summoner_v4::*;
|
2024-01-21 03:41:46 +00:00
|
|
|
use testutils::*;
|
2021-06-30 23:34:34 +00:00
|
|
|
|
|
|
|
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 {}.", "");
|
2023-05-10 18:20:15 +00:00
|
|
|
rassert_eq!(
|
|
|
|
s1.account_id,
|
|
|
|
s2.account_id,
|
|
|
|
"AccountId didn't match {}.",
|
|
|
|
""
|
|
|
|
);
|
2021-06-30 23:34:34 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
const ROUTE: PlatformRoute = PlatformRoute::NA1;
|
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
// Summoner tests.
|
|
|
|
|
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn summoner_double() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let l1p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.summoner_v4()
|
|
|
|
.get_by_summoner_name(ROUTE, "lug nuts k");
|
2024-02-24 17:46:11 +00:00
|
|
|
let l2p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.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(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn champion_getrotation() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api().champion_v3().get_champion_info(ROUTE);
|
2024-02-24 17:28:33 +00:00
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
|
|
|
let new_len = d.free_champion_ids_for_new_players.len();
|
|
|
|
let free_len = d.free_champion_ids.len();
|
|
|
|
let level = d.max_new_player_level;
|
|
|
|
rassert!(new_len >= 10, "New len: {}", new_len);
|
|
|
|
rassert!(free_len >= 15, "Free len: {}", free_len);
|
|
|
|
rassert_eq!(10, level, "New player level: {}", level);
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-06-22 08:22:49 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn leagueexp_get() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api().league_exp_v4().get_league_entries(
|
2024-02-24 17:28:33 +00:00
|
|
|
ROUTE,
|
|
|
|
QueueType::RANKED_SOLO_5x5,
|
|
|
|
Tier::CHALLENGER,
|
|
|
|
Division::I,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
|
|
|
if d.is_empty() {
|
|
|
|
eprintln!("Off-season, challenger league is empty.");
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
}
|
2021-06-30 23:34:34 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn champion_mastery_v4() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let summoner = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.summoner_v4()
|
|
|
|
.get_by_summoner_name(ROUTE, "LugnutsK");
|
|
|
|
let summoner = summoner
|
|
|
|
.await
|
|
|
|
.map_err(|e| e.to_string())?
|
|
|
|
.ok_or_else(|| "'LugnutsK' not found!".to_owned())?;
|
2024-02-24 17:46:11 +00:00
|
|
|
let masteries = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.champion_mastery_v4()
|
|
|
|
.get_all_champion_masteries_by_puuid(ROUTE, &summoner.puuid);
|
|
|
|
let masteries = masteries.await.map_err(|e| e.to_string())?;
|
|
|
|
rassert!(74 <= masteries.len());
|
|
|
|
Ok(())
|
|
|
|
}
|
2021-09-28 01:59:07 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
// Commented out, requires special API key.
|
|
|
|
// /// LOR
|
|
|
|
// #[tokio_shared_rt::test]
|
|
|
|
// async fn async fn lor_ranked_get_leaderboards() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
// let future = riot_api().lor_ranked_v1().get_leaderboards(Region::AMERICAS);
|
2024-02-24 17:28:33 +00:00
|
|
|
// let _leaderboard = future.await.map_err(|e| e.to_string())?;
|
|
|
|
// Ok(())
|
|
|
|
// }
|
2021-06-30 23:34:34 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
// CLASH
|
2022-09-21 08:42:39 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn clash_get_tournaments() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api().clash_v1().get_tournaments(ROUTE);
|
2024-02-24 17:28:33 +00:00
|
|
|
let tours = p.await.map_err(|e| e.to_string())?;
|
|
|
|
if let Some(tour0) = tours.first() {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api().clash_v1().get_tournament_by_id(ROUTE, tour0.id);
|
2024-02-24 17:28:33 +00:00
|
|
|
let tour1 = p.await.map_err(|e| e.to_string())?;
|
|
|
|
assert_eq!(Some(tour0.id), tour1.map(|t| t.id));
|
2021-06-30 23:34:34 +00:00
|
|
|
}
|
2024-02-24 17:28:33 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn clash_get_team_by_id_invalid() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.clash_v1()
|
|
|
|
.get_team_by_id(ROUTE, "00000000-0000-0000-0000-000000000000");
|
|
|
|
let team = p.await.map_err(|e| e.to_string())?;
|
|
|
|
assert!(team.is_none());
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio_shared_rt::test]
|
|
|
|
async fn status() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api().lol_status_v4().get_platform_data(ROUTE);
|
2024-02-24 17:28:33 +00:00
|
|
|
let status = p.await.map_err(|e| e.to_string())?;
|
|
|
|
println!("{:?}", status);
|
|
|
|
Ok(())
|
2021-06-30 23:34:34 +00:00
|
|
|
}
|