Riven/riven/tests/tests_na.rs

112 lines
3.4 KiB
Rust
Raw Normal View History

2021-06-30 23:34:34 +00:00
mod testutils;
use riven::consts::*;
2024-01-21 03:41:46 +00:00
use testutils::*;
2021-06-30 23:34:34 +00:00
const ROUTE: PlatformRoute = PlatformRoute::NA1;
2024-02-25 04:50:00 +00:00
#[riven_test]
async fn champion_getrotation() -> Result<(), String> {
let p = riot_api().champion_v3().get_champion_info(ROUTE);
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(())
}
2024-02-25 04:50:00 +00:00
#[riven_test]
async fn leagueexp_get() -> Result<(), String> {
let p = riot_api().league_exp_v4().get_league_entries(
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-25 04:50:00 +00:00
#[riven_test]
async fn championmasteryv4_lugnutsk() -> Result<(), String> {
2024-04-24 05:55:16 +00:00
let account =
riot_api()
.account_v1()
.get_by_riot_id(RegionalRoute::AMERICAS, "LugnutsK", "000");
let account = account
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| "'LugnutsK' not found!".to_owned())?;
let masteries = riot_api()
.champion_mastery_v4()
2024-04-24 05:55:16 +00:00
.get_all_champion_masteries_by_puuid(ROUTE, &account.puuid);
let masteries = masteries.await.map_err(|e| e.to_string())?;
rassert!(74 <= masteries.len());
Ok(())
}
#[riven_test]
async fn championmasteryv4_getall_iamchanese123() -> Result<(), String> {
let summoner =
riot_api()
.account_v1()
.get_by_riot_id(ROUTE.to_regional(), "iamchanese123", "NA1");
let summoner = summoner
.await
.map_err(|e| e.to_string())?
.ok_or_else(|| "'LugnutsK' not found!".to_owned())?;
let masteries = riot_api()
.champion_mastery_v4()
.get_all_champion_masteries_by_puuid(ROUTE, &summoner.puuid);
let masteries = masteries.await.map_err(|e| e.to_string())?;
rassert_eq!(59, masteries.len());
Ok(())
}
// Commented out, requires special API key.
// /// LOR
2024-02-25 04:50:00 +00:00
// #[riven_test]
// async fn async fn lor_ranked_get_leaderboards() -> Result<(), String> {
// let future = riot_api().lor_ranked_v1().get_leaderboards(Region::AMERICAS);
// let _leaderboard = future.await.map_err(|e| e.to_string())?;
// Ok(())
// }
2021-06-30 23:34:34 +00:00
// CLASH
2024-02-25 04:50:00 +00:00
#[riven_test]
async fn clash_get_tournaments() -> Result<(), String> {
let p = riot_api().clash_v1().get_tournaments(ROUTE);
let tours = p.await.map_err(|e| e.to_string())?;
if let Some(tour0) = tours.first() {
let p = riot_api().clash_v1().get_tournament_by_id(ROUTE, tour0.id);
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
}
Ok(())
}
2024-02-25 04:50:00 +00:00
#[riven_test]
async fn clash_get_team_by_id_invalid() -> Result<(), String> {
let p = riot_api()
.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(())
}
2024-02-25 04:50:00 +00:00
#[riven_test]
async fn status() -> Result<(), String> {
let p = riot_api().lol_status_v4().get_platform_data(ROUTE);
let status = p.await.map_err(|e| e.to_string())?;
let _ = status;
Ok(())
2021-06-30 23:34:34 +00:00
}