cleanups, tests, clippy

This commit is contained in:
Robin Appelman 2023-11-16 16:54:43 +01:00
commit a9a3751067
16 changed files with 5932 additions and 117 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

19
tests/player.rs Normal file
View file

@ -0,0 +1,19 @@
use insta::assert_json_snapshot;
use std::fs::read_to_string;
use ugc_scraper::parser::{Parser, PlayerDetailsParser, PlayerParser};
#[test]
fn test_parse_player_html() {
let body = read_to_string("tests/data/player_76561198024494988.html").unwrap();
let parser = PlayerParser::new();
let parsed = parser.parse(&body).unwrap();
assert_json_snapshot!(parsed);
}
#[test]
fn test_parse_player_details_html() {
let body = read_to_string("tests/data/player_details_76561198024494988.html").unwrap();
let parser = PlayerDetailsParser::new();
let parsed = parser.parse(&body).unwrap();
assert_json_snapshot!(parsed);
}

View file

@ -0,0 +1,128 @@
---
source: tests/player.rs
expression: parsed
---
[
{
"format": "TF2 Highlander",
"team": {
"name": "Xenon",
"id": 7861
},
"division": "Euro Platinum",
"joined": [
2013,
221
],
"left": null
},
{
"format": "TF2 6vs6",
"team": {
"name": "UGC 6s",
"id": 6929
},
"division": "Europe",
"joined": [
2017,
52
],
"left": null
},
{
"format": "TF2 6vs6",
"team": {
"name": "sExy eSports",
"id": 17736
},
"division": "Euro Steel",
"joined": [
2015,
253
],
"left": [
2017,
22
]
},
{
"format": "TF2 6vs6",
"team": {
"name": "BigHorseDong",
"id": 16277
},
"division": "Euro Steel",
"joined": [
2015,
157
],
"left": [
2015,
253
]
},
{
"format": "TF2 6vs6",
"team": {
"name": "sExy eSports",
"id": 17736
},
"division": "Euro Steel",
"joined": [
2015,
153
],
"left": [
2015,
157
]
},
{
"format": "TF2 6vs6",
"team": {
"name": "BigHorseDong",
"id": 16277
},
"division": "Euro Steel",
"joined": [
2015,
32
],
"left": [
2015,
153
]
},
{
"format": "TF2 6vs6",
"team": {
"name": "Necronoms",
"id": 8622
},
"division": "Euro Steel",
"joined": [
2013,
250
],
"left": [
2014,
357
]
},
{
"format": "TF2 4vs4",
"team": {
"name": "sExy eSports",
"id": 17790
},
"division": "Silver Euro",
"joined": [
2015,
153
],
"left": [
2017,
227
]
}
]

View file

@ -0,0 +1,234 @@
---
source: tests/player.rs
expression: parsed
---
{
"name": "Icewind demostf",
"steam_id": 0,
"honors": [
{
"format": "TF2 Highlander",
"season": "Season 32 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 31 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 30 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 29 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 28 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 27 Premium EU",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 26 Premium EU",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 25 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 24 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 23 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 22 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 21 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 20 Euro Platinum",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 19 Euro Gold",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 18 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 17 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 16 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 15 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 14 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 13 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 12 Euro Silver",
"team": "Xenon"
},
{
"format": "TF2 Highlander",
"season": "Season 11 Euro Steel",
"team": "Xenon"
},
{
"format": "TF2 6vs6",
"season": "Season 35 Europe",
"team": "Controller Gamers"
},
{
"format": "TF2 6vs6",
"season": "Season 34 Europe",
"team": "Bye week"
},
{
"format": "TF2 6vs6",
"season": "Season 33 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 32 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 31 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 30 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 29 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 28 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 27 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 26 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 25 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 24 Europe",
"team": "meta.tf"
},
{
"format": "TF2 6vs6",
"season": "Season 23 Europe",
"team": "Giel and the 9wiels"
},
{
"format": "TF2 6vs6",
"season": "Season 19 Euro Platinum",
"team": "sExy eSports"
},
{
"format": "TF2 6vs6",
"season": "Season 18 Euro Steel",
"team": "BigHorseDong"
},
{
"format": "TF2 6vs6",
"season": "Season 13 Euro Steel",
"team": "Necronoms"
},
{
"format": "TF2 4vs4",
"season": "Season 6 Silver Euro",
"team": "sExy eSports"
},
{
"format": "TF2 4vs4",
"season": "Season 5 Silver Euro",
"team": "sExy eSports"
}
],
"teams": [
{
"team": {
"name": "UGC 6s",
"id": 6929
},
"league": "TF2 6vs6 - Europe",
"since": [
2017,
52
]
},
{
"team": {
"name": "Xenon",
"id": 7861
},
"league": "TF2 Highlander - Euro Platinum",
"since": [
2013,
221
]
}
]
}