2019-11-07 20:45:13 +00:00
|
|
|
#![cfg_attr(feature = "nightly", feature(custom_test_frameworks))]
|
|
|
|
#![cfg_attr(feature = "nightly", test_runner(my_runner))]
|
2019-10-30 20:24:07 +00:00
|
|
|
|
|
|
|
mod async_tests;
|
2019-10-31 05:52:00 +00:00
|
|
|
mod testutils;
|
|
|
|
use testutils::*;
|
2019-10-30 20:24:07 +00:00
|
|
|
|
|
|
|
use colored::*;
|
|
|
|
|
|
|
|
use riven::consts::*;
|
2019-11-03 18:48:45 +00:00
|
|
|
use riven::models::summoner_v4::*;
|
2019-10-30 20:24:07 +00:00
|
|
|
|
2020-04-19 20:08:11 +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 {}.", "");
|
|
|
|
rassert_eq!(s1.account_id, s2.account_id, "AccountId didn't match {}.", "");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async_tests!{
|
|
|
|
my_runner {
|
|
|
|
// Summoner tests.
|
|
|
|
summoner_double: async {
|
|
|
|
let l1p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lug nuts k");
|
|
|
|
let l2p = RIOT_API.summoner_v4().get_by_summoner_name(Region::NA, "lugnuts k");
|
|
|
|
let l1 = l1p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l1".to_owned())?;
|
|
|
|
let l2 = l2p.await.map_err(|e| e.to_string())?.ok_or("Failed to get l2".to_owned())?;
|
2020-04-19 20:08:11 +00:00
|
|
|
validate_summoners(l1, l2)?;
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
champion_getrotation: async {
|
|
|
|
let p = RIOT_API.champion_v3().get_champion_info(Region::NA);
|
2019-11-08 00:06:01 +00:00
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
2019-10-30 20:24:07 +00:00
|
|
|
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(())
|
|
|
|
},
|
2019-10-31 05:52:00 +00:00
|
|
|
leagueexp_get: async {
|
2019-10-31 08:09:20 +00:00
|
|
|
let p = RIOT_API.league_exp_v4().get_league_entries(Region::NA, QueueType::RANKED_SOLO_5x5, Tier::CHALLENGER, Division::I, None);
|
2019-11-08 00:06:01 +00:00
|
|
|
let d = p.await.map_err(|e| e.to_string())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!d.is_empty(), "Challenger shouldn't be empty.");
|
|
|
|
Ok(())
|
|
|
|
},
|
2019-10-30 20:24:07 +00:00
|
|
|
match_get: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 3190191338);
|
2019-11-08 00:06:01 +00:00
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
2020-05-30 20:33:49 +00:00
|
|
|
},
|
2020-07-26 23:33:03 +00:00
|
|
|
match_get_bots: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 3251803350);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match not found.".to_owned())?;
|
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
|
|
|
Ok(())
|
|
|
|
},
|
2020-05-30 20:33:49 +00:00
|
|
|
match_gettimeline: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match_timeline(Region::NA, 3190191338);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Match timeline not found.".to_owned())?;
|
|
|
|
rassert!(!m.frames.is_empty(), "Match timeline should have frames.");
|
|
|
|
Ok(())
|
2019-10-30 20:24:07 +00:00
|
|
|
},
|
|
|
|
// match_get_old: async {
|
|
|
|
// let p = RIOT_API.match_v4().get_match(Region::NA, 2632789562);
|
|
|
|
// let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
|
|
|
// Ok(())
|
|
|
|
// },
|
|
|
|
match_get_aram: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 2961635718);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
match_get_urf900: async {
|
|
|
|
let p = RIOT_API.match_v4().get_match(Region::NA, 2963663381);
|
|
|
|
let m = p.await.map_err(|e| e.to_string())?.ok_or("Failed to get match.".to_owned())?;
|
2019-10-31 05:52:00 +00:00
|
|
|
rassert!(!m.participants.is_empty(), "Match should have participants.");
|
2019-10-30 20:24:07 +00:00
|
|
|
Ok(())
|
|
|
|
},
|
2020-03-31 18:50:21 +00:00
|
|
|
// Commented out, requires special API key.
|
|
|
|
// // LOR
|
|
|
|
// lor_ranked_get_leaderboards: async {
|
|
|
|
// let future = RIOT_API.lor_ranked_v1().get_leaderboards(Region::AMERICAS);
|
|
|
|
// let _leaderboard = future.await.map_err(|e| e.to_string())?;
|
|
|
|
// Ok(())
|
|
|
|
// },
|
2020-03-31 19:07:22 +00:00
|
|
|
// CLASH
|
|
|
|
clash_get_tournaments: async {
|
|
|
|
let p = RIOT_API.clash_v1().get_tournaments(Region::NA);
|
|
|
|
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(Region::NA, tour0.id);
|
|
|
|
let tour1 = p.await.map_err(|e| e.to_string())?;
|
|
|
|
assert_eq!(Some(tour0.id), tour1.map(|t| t.id));
|
|
|
|
}
|
|
|
|
Ok(())
|
|
|
|
},
|
|
|
|
clash_get_team_by_id: async {
|
|
|
|
let p = RIOT_API.clash_v1().get_team_by_id(Region::NA, "00000000-0000-0000-0000-000000000000");
|
|
|
|
let team = p.await.map_err(|e| e.to_string())?;
|
|
|
|
assert!(team.is_none());
|
|
|
|
Ok(())
|
|
|
|
},
|
2019-10-30 20:24:07 +00:00
|
|
|
}
|
|
|
|
}
|