58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
import pathlib
|
|
import sys
|
|
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[1]))
|
|
sys.path.insert(0, str(pathlib.Path(__file__).resolve().parents[2] / "SHARED"))
|
|
|
|
from BOT.transform import build_scoreboard_model
|
|
|
|
|
|
def _game():
|
|
return {
|
|
"_id": "abc",
|
|
"winner": "1",
|
|
"mission_name": "Kursk",
|
|
"tss": {
|
|
"tournament_id": 24965,
|
|
"tournament_name": "2x2 RBm Tanks",
|
|
"1": {"team_id": "111", "team_name": "A", "players": [{"uid": "1", "pvp_ratio": 1500}]},
|
|
"2": {"team_id": "222", "team_name": "B", "players": [{"uid": "2", "pvp_ratio": 1400}]},
|
|
},
|
|
"players": {
|
|
"1": {"name": "alice", "team": "1", "units": [{"unit": "t34", "used": True}]},
|
|
"2": {"name": "bob", "team": "2", "units": [{"unit": "pz", "used": True}]},
|
|
},
|
|
}
|
|
|
|
|
|
def test_model_carries_tournament_id():
|
|
model = build_scoreboard_model(_game())
|
|
assert model is not None
|
|
assert model["tournament_id"] == 24965
|
|
|
|
|
|
def test_model_strips_unit_model_prefixes_for_dead_matching():
|
|
game = _game()
|
|
game["players"]["2"]["units"][0]["unit"] = "tankModels/pz"
|
|
game["players"]["2"]["units"][0]["unit_type"] = "tank"
|
|
game["players"]["2"]["units"][0]["unit_class"] = "medium tank"
|
|
game["players"]["2"]["country"] = "germany"
|
|
game["events"] = {
|
|
"kills": [
|
|
{
|
|
"offended_uid": "2",
|
|
"offended_unit": "tankModels/pz",
|
|
}
|
|
]
|
|
}
|
|
|
|
model = build_scoreboard_model(game)
|
|
|
|
assert model is not None
|
|
bob = model["teams"][1]["players"][0]
|
|
assert bob["country"] == "germany"
|
|
assert bob["units"][0]["internal"] == "pz"
|
|
assert bob["units"][0]["dead"] is True
|
|
assert bob["units"][0]["unit_type"] == "tank"
|
|
assert bob["units"][0]["unit_class"] == "medium tank"
|