Regen, add rest of tests for `lol-challenges-v1`

Also adds Bel'Veth.
users/mingwei/unknown-variant-messy
Mingwei Samuel 2022-05-25 18:27:48 -07:00
parent f0f4af13af
commit 8e6073aa63
5 changed files with 85 additions and 16 deletions

View File

@ -28,6 +28,7 @@ newtype_enum! {
/// `AURELION_SOL` | "Aurelion Sol" | "AurelionSol" | 136 /// `AURELION_SOL` | "Aurelion Sol" | "AurelionSol" | 136
/// `AZIR` | "Azir" | "Azir" | 268 /// `AZIR` | "Azir" | "Azir" | 268
/// `BARD` | "Bard" | "Bard" | 432 /// `BARD` | "Bard" | "Bard" | 432
/// `BEL_VETH` | "Bel'Veth" | "Belveth" | 200
/// `BLITZCRANK` | "Blitzcrank" | "Blitzcrank" | 53 /// `BLITZCRANK` | "Blitzcrank" | "Blitzcrank" | 53
/// `BRAND` | "Brand" | "Brand" | 63 /// `BRAND` | "Brand" | "Brand" | 63
/// `BRAUM` | "Braum" | "Braum" | 201 /// `BRAUM` | "Braum" | "Braum" | 201
@ -203,6 +204,8 @@ newtype_enum! {
AZIR = 268, AZIR = 268,
/// `432`. /// `432`.
BARD = 432, BARD = 432,
/// `200`.
BEL_VETH = 200,
/// `53`. /// `53`.
BLITZCRANK = 53, BLITZCRANK = 53,
/// `63`. /// `63`.
@ -515,6 +518,7 @@ impl Champion {
Self::AURELION_SOL => Some("Aurelion Sol"), Self::AURELION_SOL => Some("Aurelion Sol"),
Self::AZIR => Some("Azir"), Self::AZIR => Some("Azir"),
Self::BARD => Some("Bard"), Self::BARD => Some("Bard"),
Self::BEL_VETH => Some("Bel'Veth"),
Self::BLITZCRANK => Some("Blitzcrank"), Self::BLITZCRANK => Some("Blitzcrank"),
Self::BRAND => Some("Brand"), Self::BRAND => Some("Brand"),
Self::BRAUM => Some("Braum"), Self::BRAUM => Some("Braum"),
@ -673,6 +677,7 @@ impl Champion {
/// ///
/// Field | Name | Identifier | Id /// Field | Name | Identifier | Id
/// ---|---|---|--- /// ---|---|---|---
/// `BEL_VETH` | "Bel'Veth" | "Belveth" | 200
/// `CHO_GATH` | "Cho'Gath" | "Chogath" | 31 /// `CHO_GATH` | "Cho'Gath" | "Chogath" | 31
/// `FIDDLESTICKS` | "Fiddlesticks" | "FiddleSticks" | 9 /// `FIDDLESTICKS` | "Fiddlesticks" | "FiddleSticks" | 9
/// `KAI_SA` | "Kai'Sa" | "Kaisa" | 145 /// `KAI_SA` | "Kai'Sa" | "Kaisa" | 145
@ -697,6 +702,7 @@ impl Champion {
Self::AURELION_SOL => Some("AurelionSol"), Self::AURELION_SOL => Some("AurelionSol"),
Self::AZIR => Some("Azir"), Self::AZIR => Some("Azir"),
Self::BARD => Some("Bard"), Self::BARD => Some("Bard"),
Self::BEL_VETH => Some("Belveth"),
Self::BLITZCRANK => Some("Blitzcrank"), Self::BLITZCRANK => Some("Blitzcrank"),
Self::BRAND => Some("Brand"), Self::BRAND => Some("Brand"),
Self::BRAUM => Some("Braum"), Self::BRAUM => Some("Braum"),
@ -910,6 +916,8 @@ impl std::str::FromStr for Champion {
/* AURE */ [ 'A', 'U', 'R', 'E'] => Ok(Champion::AURELION_SOL), /* AURE */ [ 'A', 'U', 'R', 'E'] => Ok(Champion::AURELION_SOL),
/* AZIR */ [ 'A', 'Z', 'I', 'R'] => Ok(Champion::AZIR), /* AZIR */ [ 'A', 'Z', 'I', 'R'] => Ok(Champion::AZIR),
/* BARD */ [ 'B', 'A', 'R', 'D'] => Ok(Champion::BARD), /* BARD */ [ 'B', 'A', 'R', 'D'] => Ok(Champion::BARD),
/* BELV */ [ 'B', 'E', 'L', 'V'] => Ok(Champion::BEL_VETH),
/* BEL */ [ 'B', 'E', 'L', '\0'] => Ok(Champion::BEL_VETH),
/* BLIT */ [ 'B', 'L', 'I', 'T'] => Ok(Champion::BLITZCRANK), /* BLIT */ [ 'B', 'L', 'I', 'T'] => Ok(Champion::BLITZCRANK),
/* BRAN */ [ 'B', 'R', 'A', 'N'] => Ok(Champion::BRAND), /* BRAN */ [ 'B', 'R', 'A', 'N'] => Ok(Champion::BRAND),
/* BRAU */ [ 'B', 'R', 'A', 'U'] => Ok(Champion::BRAUM), /* BRAU */ [ 'B', 'R', 'A', 'U'] => Ok(Champion::BRAUM),

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 4969d1e8bcccde31f0dfc173cfb49652bea2b35c // Version 8afe7b8e927da46a6f41108e6dc7e1a8c71d89b9
//! 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)]
@ -801,7 +801,7 @@ impl<'a> LolChallengesV1<'a> {
/// <a href="https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getChallengeLeaderboards" target="_blank">`lol-challenges-v1.getChallengeLeaderboards`</a> /// <a href="https://developer.riotgames.com/api-methods/#lol-challenges-v1/GET_getChallengeLeaderboards" target="_blank">`lol-challenges-v1.getChallengeLeaderboards`</a>
/// ///
/// Note: this method is automatically generated. /// Note: this method is automatically generated.
pub fn get_challenge_leaderboards(&self, route: PlatformRoute, challenge_id: i64, level: &str, limit: Option<i32>) pub fn get_challenge_leaderboards(&self, route: PlatformRoute, challenge_id: i64, level: crate::consts::Tier, limit: Option<i32>)
-> impl Future<Output = Result<Option<Vec<lol_challenges_v1::ApexPlayerInfo>>>> + 'a -> impl Future<Output = Result<Option<Vec<lol_challenges_v1::ApexPlayerInfo>>>> + 'a
{ {
let route_str = route.into(); let route_str = route.into();

View File

@ -7,7 +7,7 @@
/////////////////////////////////////////////// ///////////////////////////////////////////////
// http://www.mingweisamuel.com/riotapi-schema/tool/ // http://www.mingweisamuel.com/riotapi-schema/tool/
// Version 4969d1e8bcccde31f0dfc173cfb49652bea2b35c // Version 8afe7b8e927da46a6f41108e6dc7e1a8c71d89b9
//! 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 4969d1e8bcccde31f0dfc173cfb49652bea2b35c // Version 8afe7b8e927da46a6f41108e6dc7e1a8c71d89b9
#![allow(missing_docs)] #![allow(missing_docs)]
@ -468,34 +468,56 @@ pub mod lol_challenges_v1 {
pub category_points: std::collections::HashMap<String, ChallengePoints>, pub category_points: std::collections::HashMap<String, ChallengePoints>,
} }
/// ChallengeInfo data object. /// ChallengeInfo data object.
/// # Description
/// UNKNOWN TYPE.
///
/// Note: This struct is automatically generated
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
pub struct ChallengeInfo { pub struct ChallengeInfo {
#[serde(rename = "challengeId")]
pub challenge_id: i64,
#[serde(rename = "percentile")]
pub percentile: f64,
#[serde(rename = "level")]
pub level: crate::consts::Tier,
#[serde(rename = "value")]
pub value: f64,
#[serde(rename = "achievedTime")]
pub achieved_time: i64,
#[serde(rename = "position")]
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<i64>,
#[serde(rename = "playersInLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub players_in_level: Option<i64>,
} }
/// PlayerClientPreferences data object. /// PlayerClientPreferences data object.
/// # Description
/// UNKNOWN TYPE.
///
/// Note: This struct is automatically generated
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
pub struct PlayerClientPreferences { pub struct PlayerClientPreferences {
#[serde(rename = "bannerAccent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub banner_accent: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "challengeIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub challenge_ids: Option<std::vec::Vec<i64>>,
} }
/// ChallengePoints data object. /// ChallengePoints data object.
/// # Description
/// UNKNOWN TYPE.
///
/// Note: This struct is automatically generated
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
#[derive(serde::Serialize, serde::Deserialize)] #[derive(serde::Serialize, serde::Deserialize)]
#[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))] #[cfg_attr(feature = "deny-unknown-fields", serde(deny_unknown_fields))]
pub struct ChallengePoints { pub struct ChallengePoints {
#[serde(rename = "level")]
pub level: crate::consts::Tier,
#[serde(rename = "current")]
pub current: i64,
#[serde(rename = "max")]
pub max: i64,
#[serde(rename = "percentile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub percentile: Option<f64>,
} }
} }

View File

@ -11,8 +11,44 @@ use riven::consts::*;
const ROUTE: PlatformRoute = PlatformRoute::LA1; const ROUTE: PlatformRoute = PlatformRoute::LA1;
/// en_US description: "As a laner, get kills before 10 minutes outside your lane (anyone but your lane opponent)"
const CHALLENGE_ID__ARAM_1K_DPM: i64 = 101101;
async_tests! { async_tests! {
my_runner { my_runner {
// /lol/challenges/v1/challenges/{challengeId}/leaderboards/by-level/{level}
// /lol/challenges/v1/player-data/{puuid}
lol_challenges_v1_leaderboards_playerdata: async {
let challenge_id = CHALLENGE_ID__ARAM_1K_DPM;
let leaderboard = RIOT_API.lol_challenges_v1()
.get_challenge_leaderboards(ROUTE, challenge_id, Tier::GRANDMASTER, None)
.await.map_err(|e| e.to_string())?
.ok_or_else(|| format!("Challenge leaderboard with id {} returned 404", challenge_id))?;
{
rassert!(!leaderboard.is_empty());
let start = leaderboard[0].position;
// Commented out: leaderboard is not monotonic for some reason.
// let mut val = leaderboard[0].value;
for (n, entry) in leaderboard.iter().enumerate() {
rassert_eq!(start + (n as i32), entry.position);
// rassert!(entry.val <= val);
// val = etnry.val;
}
}
// Spot check 10% for `player-data`.
for entry in leaderboard.iter().step_by(10)
{
let player_data = RIOT_API.lol_challenges_v1().get_player_data(ROUTE, &*entry.puuid)
.await.map_err(|e| format!("Failed to get player data PUUID {}: {}", entry.puuid, e))?;
}
Ok(())
},
// /lol/challenges/v1/challenges/config
// /lol/challenges/v1/challenges/{challengeId}/config
lol_challenges_v1_check_configs: async { lol_challenges_v1_check_configs: async {
let challenges = RIOT_API.lol_challenges_v1().get_all_challenge_configs(ROUTE) let challenges = RIOT_API.lol_challenges_v1().get_all_challenge_configs(ROUTE)
.await.map_err(|e| e.to_string())?; .await.map_err(|e| e.to_string())?;
@ -32,6 +68,9 @@ async_tests! {
Ok(()) Ok(())
}, },
// /lol/challenges/v1/challenges/percentiles
// /lol/challenges/v1/challenges/{challengeId}/percentiles
lol_challenges_v1_check_percentiles: async { lol_challenges_v1_check_percentiles: async {
// Check all percentiles. // Check all percentiles.
let percentiles = RIOT_API.lol_challenges_v1().get_all_challenge_percentiles(ROUTE) let percentiles = RIOT_API.lol_challenges_v1().get_all_challenge_percentiles(ROUTE)