mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 10:14:11 +02:00
cleanups, tests, clippy
This commit is contained in:
parent
d937dbbb5e
commit
a9a3751067
16 changed files with 5932 additions and 117 deletions
2579
tests/data/player_76561198024494988.html
Normal file
2579
tests/data/player_76561198024494988.html
Normal file
File diff suppressed because it is too large
Load diff
2559
tests/data/player_details_76561198024494988.html
Normal file
2559
tests/data/player_details_76561198024494988.html
Normal file
File diff suppressed because it is too large
Load diff
19
tests/player.rs
Normal file
19
tests/player.rs
Normal 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);
|
||||
}
|
||||
128
tests/snapshots/player__parse_player_details_html.snap
Normal file
128
tests/snapshots/player__parse_player_details_html.snap
Normal 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
|
||||
]
|
||||
}
|
||||
]
|
||||
234
tests/snapshots/player__parse_player_html.snap
Normal file
234
tests/snapshots/player__parse_player_html.snap
Normal 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
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue