M3+M4: Riot client, ladder crawler, endboard extraction
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
68
backend/tests/test_extract.py
Normal file
68
backend/tests/test_extract.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import json
|
||||
|
||||
from tft.matches.extract import extract_match, patch_of, validate_ids
|
||||
|
||||
FAKE_MATCH = {
|
||||
"metadata": {"match_id": "EUW1_123"},
|
||||
"info": {
|
||||
"tft_set_number": 17,
|
||||
"queue_id": 1100,
|
||||
"game_version": "Version 16.14.7945912 (Jul 15 2026/13:37:00)",
|
||||
"participants": [
|
||||
{
|
||||
"puuid": f"player-{i}",
|
||||
"placement": i + 1,
|
||||
"level": 8,
|
||||
"last_round": 30,
|
||||
"gold_left": 4,
|
||||
"units": [
|
||||
{
|
||||
"character_id": "TFT17_Rammus",
|
||||
"tier": 2,
|
||||
"itemNames": ["TFT_Item_InfinityEdge"],
|
||||
}
|
||||
],
|
||||
"traits": [{"name": "TFT17_ResistTank", "num_units": 2, "tier_current": 1}],
|
||||
"augments": [],
|
||||
}
|
||||
for i in range(8)
|
||||
],
|
||||
},
|
||||
}
|
||||
|
||||
STATIC = {
|
||||
"units": {"TFT17_Rammus": {}},
|
||||
"traits": {"TFT17_ResistTank": {}},
|
||||
"items": {"TFT_Item_InfinityEdge": {}},
|
||||
"augments": {},
|
||||
}
|
||||
|
||||
|
||||
def test_patch_of():
|
||||
assert patch_of("Version 16.14.7945912 (Jul 15 2026/13:37:00)") == "16.14"
|
||||
assert patch_of("16.14.7945912") == "16.14"
|
||||
|
||||
|
||||
def test_extract_match_yields_8_rows():
|
||||
rows = extract_match(FAKE_MATCH)
|
||||
assert len(rows) == 8
|
||||
match_id, puuid, set_number, patch, placement, level, *_ = rows[0]
|
||||
assert match_id == "EUW1_123"
|
||||
assert set_number == 17
|
||||
assert patch == "16.14"
|
||||
assert placement == 1
|
||||
assert json.loads(rows[0][8])[0]["character_id"] == "TFT17_Rammus"
|
||||
|
||||
|
||||
def test_validate_ids_clean():
|
||||
rows = extract_match(FAKE_MATCH)
|
||||
assert not validate_ids(rows, STATIC)
|
||||
|
||||
|
||||
def test_validate_ids_flags_unknown():
|
||||
rows = extract_match(FAKE_MATCH)
|
||||
static = {"units": {}, "traits": {}, "items": {}, "augments": {}}
|
||||
unknown = validate_ids(rows, static)
|
||||
assert unknown["unit:TFT17_Rammus"] == 8
|
||||
assert unknown["item:TFT_Item_InfinityEdge"] == 8
|
||||
assert unknown["trait:TFT17_ResistTank"] == 8
|
||||
Reference in New Issue
Block a user