2023-03-08 21:49:53 +00:00
|
|
|
mod testutils;
|
|
|
|
use riven::consts::*;
|
2024-01-21 03:41:46 +00:00
|
|
|
use testutils::*;
|
2023-03-08 21:49:53 +00:00
|
|
|
|
|
|
|
const ROUTE: PlatformRoute = PlatformRoute::EUW1;
|
|
|
|
|
|
|
|
static TFT_MATCHES: &[&str] = &[
|
2024-01-28 01:22:19 +00:00
|
|
|
// https://github.com/MingweiSamuel/Riven/pull/62
|
|
|
|
// https://github.com/MingweiSamuel/riotapi-schema/pull/43
|
|
|
|
"EUW1_6786745342",
|
2024-02-16 23:57:44 +00:00
|
|
|
// 2024-02-16
|
|
|
|
"EUW1_6807630149",
|
2023-03-08 21:49:53 +00:00
|
|
|
];
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tftmatchv1_get_list() -> Result<(), String> {
|
|
|
|
tft_match_v1_get(ROUTE.to_regional(), TFT_MATCHES).await
|
|
|
|
}
|
|
|
|
|
|
|
|
// /// Don't have acecess to tft-status-v1.
|
2024-02-25 04:50:00 +00:00
|
|
|
// #[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
// async fn tftstatusv1_getplatformdata() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
// let p = riot_api().tft_status_v1().get_platform_data(ROUTE);
|
2024-02-24 17:28:33 +00:00
|
|
|
// let _s = p.await.map_err(|e| e.to_string())?;
|
|
|
|
// Ok(())
|
|
|
|
// }
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tftleaguev1_gettopratedladder() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.tft_league_v1()
|
|
|
|
.get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
|
|
|
let l = p.await.map_err(|e| e.to_string())?;
|
|
|
|
rassert!(
|
|
|
|
l.len() > 10,
|
|
|
|
"Expected a few ranked players, got: {}.",
|
|
|
|
l.len()
|
|
|
|
);
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tftmatchv1_getmatch() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.tft_match_v1()
|
|
|
|
.get_match(ROUTE.to_regional(), "EUW1_6455483163");
|
|
|
|
let _m = p
|
|
|
|
.await
|
|
|
|
.map_err(|e| e.to_string())?
|
|
|
|
.ok_or("Failed to get TFT match.".to_owned())?;
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tftsummonerv1_getbyname() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.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(())
|
|
|
|
}
|
|
|
|
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tftsummonerv1_getbyname_none() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let p = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.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(())
|
|
|
|
}
|
2023-03-08 21:49:53 +00:00
|
|
|
|
2024-02-24 17:28:33 +00:00
|
|
|
/// Get top rated player, get some of their matches.
|
2024-02-25 04:50:00 +00:00
|
|
|
#[riven_test]
|
2024-02-24 17:28:33 +00:00
|
|
|
async fn tft_combo() -> Result<(), String> {
|
2024-02-24 17:46:11 +00:00
|
|
|
let top_players = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.tft_league_v1()
|
|
|
|
.get_top_rated_ladder(ROUTE, QueueType::RANKED_TFT_TURBO);
|
|
|
|
let top_players = top_players.await.map_err(|e| e.to_string())?;
|
|
|
|
rassert!(!top_players.is_empty());
|
|
|
|
let top_player_entry = &top_players[0];
|
2024-02-24 17:46:11 +00:00
|
|
|
let top_player = riot_api()
|
2024-02-24 17:28:33 +00:00
|
|
|
.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
|
|
|
|
);
|
2024-02-24 17:46:11 +00:00
|
|
|
let match_ids = riot_api().tft_match_v1().get_match_ids_by_puuid(
|
2024-02-24 17:28:33 +00:00
|
|
|
ROUTE.to_regional(),
|
|
|
|
&top_player.puuid,
|
|
|
|
Some(10),
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
None,
|
|
|
|
);
|
|
|
|
let match_ids = match_ids.await.map_err(|e| e.to_string())?;
|
|
|
|
tft_match_v1_get(ROUTE.to_regional(), &*match_ids).await?;
|
|
|
|
Ok(())
|
2023-03-08 21:49:53 +00:00
|
|
|
}
|