forked from mirror/Riven
1
0
Fork 0

Update for optional fields in match-v5 timeline DTOs, adding more test matches

users/mingwei/unknown-variant-messy
Mingwei Samuel 2021-11-09 19:07:31 -08:00
parent b981adbffc
commit 7e5bccd039
5 changed files with 47 additions and 16 deletions

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 309704e3979855858e36430b178e507e48702059 // Version f7d7b8c90243fcb043ffe81c5b08b0925be83bdf
//! Automatically generated endpoint handles. //! Automatically generated endpoint handles.
#![allow(clippy::let_and_return, clippy::too_many_arguments)] #![allow(clippy::let_and_return, clippy::too_many_arguments)]

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 309704e3979855858e36430b178e507e48702059 // Version f7d7b8c90243fcb043ffe81c5b08b0925be83bdf
//! Metadata about the Riot API and Riven. //! Metadata about the Riot API and Riven.
//! //!

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 309704e3979855858e36430b178e507e48702059 // Version f7d7b8c90243fcb043ffe81c5b08b0925be83bdf
//! Data transfer structs. //! Data transfer structs.
//! //!
@ -1236,7 +1236,8 @@ pub mod match_v5 {
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
pub struct MatchTimelineInfoFrameParticipantFrameChampionStats { pub struct MatchTimelineInfoFrameParticipantFrameChampionStats {
#[serde(rename = "abilityHaste")] #[serde(rename = "abilityHaste")]
pub ability_haste: i32, #[serde(skip_serializing_if = "Option::is_none")]
pub ability_haste: Option<i32>,
#[serde(rename = "abilityPower")] #[serde(rename = "abilityPower")]
pub ability_power: i32, pub ability_power: i32,
#[serde(rename = "armor")] #[serde(rename = "armor")]
@ -1274,9 +1275,11 @@ pub mod match_v5 {
#[serde(rename = "movementSpeed")] #[serde(rename = "movementSpeed")]
pub movement_speed: i32, pub movement_speed: i32,
#[serde(rename = "omnivamp")] #[serde(rename = "omnivamp")]
pub omnivamp: i32, #[serde(skip_serializing_if = "Option::is_none")]
pub omnivamp: Option<i32>,
#[serde(rename = "physicalVamp")] #[serde(rename = "physicalVamp")]
pub physical_vamp: i32, #[serde(skip_serializing_if = "Option::is_none")]
pub physical_vamp: Option<i32>,
#[serde(rename = "power")] #[serde(rename = "power")]
pub power: i32, pub power: i32,
#[serde(rename = "powerMax")] #[serde(rename = "powerMax")]
@ -1430,9 +1433,11 @@ pub mod match_v5 {
#[serde(rename = "frames")] #[serde(rename = "frames")]
pub frames: std::vec::Vec<MatchTimelineInfoFrame>, pub frames: std::vec::Vec<MatchTimelineInfoFrame>,
#[serde(rename = "gameId")] #[serde(rename = "gameId")]
pub game_id: i64, #[serde(skip_serializing_if = "Option::is_none")]
pub game_id: Option<i64>,
#[serde(rename = "participants")] #[serde(rename = "participants")]
pub participants: std::vec::Vec<MatchTimelineInfoParticipant>, #[serde(skip_serializing_if = "Option::is_none")]
pub participants: Option<std::vec::Vec<MatchTimelineInfoParticipant>>,
} }
} }

View File

@ -12,7 +12,13 @@ use riven::models::tournament_stub_v4::*;
const ROUTE: RegionalRoute = RegionalRoute::AMERICAS; const ROUTE: RegionalRoute = RegionalRoute::AMERICAS;
static MATCHES: [&str; 4] = [ "NA1_3923487226", "NA1_4049206905", "NA1_4052515784", "NA1_4062578191" ]; static MATCHES: [&str; 5] = [
"NA1_3923487226",
"NA1_4049206905",
"NA1_4052515784",
"NA1_4062578191",
"NA1_4097036960",
];
async_tests!{ async_tests!{
my_runner { my_runner {
@ -65,7 +71,7 @@ async_tests!{
match_v5_get: async { match_v5_get: async {
for matche in MATCHES { for matche in MATCHES {
let p = RIOT_API.match_v5().get_match(ROUTE, matche); let p = RIOT_API.match_v5().get_match(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match {} not found.", matche))?; let m = p.await.map_err(|e| format!("Failed to get match {}: {:?}", matche, e))?.ok_or(format!("Match {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id); rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants."); rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert!(!m.info.teams.is_empty(), "Match should have teams."); rassert!(!m.info.teams.is_empty(), "Match should have teams.");
@ -75,10 +81,12 @@ async_tests!{
match_v5_get_timeline: async { match_v5_get_timeline: async {
for matche in MATCHES { for matche in MATCHES {
let p = RIOT_API.match_v5().get_timeline(ROUTE, matche); let p = RIOT_API.match_v5().get_timeline(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match timeline {} not found.", matche))?; let m = p.await.map_err(|e| format!("Failed to get match {}: {:?}", matche, e))?.ok_or(format!("Match {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id); rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants."); rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", m.info.game_id), "Match number ID should match."); if let Some(game_id) = m.info.game_id {
rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", game_id), "Match number ID should match.");
}
rassert!(!m.info.frames.is_empty(), "Match timleine should have frames."); rassert!(!m.info.frames.is_empty(), "Match timleine should have frames.");
} }
Ok(()) Ok(())

View File

@ -11,14 +11,30 @@ use riven::consts::*;
const ROUTE: RegionalRoute = RegionalRoute::ASIA; const ROUTE: RegionalRoute = RegionalRoute::ASIA;
static MATCHES: [&str; 1] = [ "KR_5495121707" ]; static MATCHES: [&str; 11] = [
// Regular game:
"KR_5495121707",
// `teamPosition` empty:
// AFK:
"JP1_312062554",
"JP1_326464722",
"JP1_289504387",
"JP1_285434511",
"JP1_307559381",
"JP1_292569767",
"JP1_310138781",
"JP1_300507433",
"JP1_283568774",
// `individualPosition` is set but `teamPosition` is empty due to AFK slightly after beginning:
"JP1_285797147",
];
async_tests!{ async_tests!{
my_runner { my_runner {
match_v5_get: async { match_v5_get: async {
for matche in MATCHES { for matche in MATCHES {
let p = RIOT_API.match_v5().get_match(ROUTE, matche); let p = RIOT_API.match_v5().get_match(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match {} not found.", matche))?; let m = p.await.map_err(|e| format!("Failed to get match {}: {:?}", matche, e))?.ok_or(format!("Match {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id); rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants."); rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert!(!m.info.teams.is_empty(), "Match should have teams."); rassert!(!m.info.teams.is_empty(), "Match should have teams.");
@ -28,10 +44,12 @@ async_tests!{
match_v5_get_timeline: async { match_v5_get_timeline: async {
for matche in MATCHES { for matche in MATCHES {
let p = RIOT_API.match_v5().get_timeline(ROUTE, matche); let p = RIOT_API.match_v5().get_timeline(ROUTE, matche);
let m = p.await.map_err(|e| e.to_string())?.ok_or(format!("Match timeline {} not found.", matche))?; let m = p.await.map_err(|e| format!("Failed to get match {}: {:?}", matche, e))?.ok_or(format!("Match {} not found.", matche))?;
rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id); rassert_eq!(matche, m.metadata.match_id, "Bad match id? Sent {}, received {}.", matche, m.metadata.match_id);
rassert!(!m.metadata.participants.is_empty(), "Match should have participants."); rassert!(!m.metadata.participants.is_empty(), "Match should have participants.");
rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", m.info.game_id), "Match number ID should match."); if let Some(game_id) = m.info.game_id {
rassert_eq!(matche[(matche.find('_').unwrap() + 1)..], format!("{}", game_id), "Match number ID should match.");
}
rassert!(!m.info.frames.is_empty(), "Match timleine should have frames."); rassert!(!m.info.frames.is_empty(), "Match timleine should have frames.");
} }
Ok(()) Ok(())