fix some scoreboard shit (#1364)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import importlib
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "SHARED"))
|
||||
|
||||
|
||||
def test_unit_vehicle_fields_translates_vehicle_and_strips_model_prefix(tmp_path, monkeypatch):
|
||||
monkeypatch.setenv("STORAGE_VOL_PATH", str(tmp_path))
|
||||
|
||||
import BOT.storage as storage
|
||||
importlib.reload(storage)
|
||||
|
||||
unit = {
|
||||
"unit": "tankModels/germ_pzkpfw_V_ausf_d_panther",
|
||||
"unit_normalized": "Bad Spectra Name",
|
||||
"used": True,
|
||||
}
|
||||
|
||||
assert storage._unit_vehicle_fields(unit) == ("Panther D", "germ_pzkpfw_V_ausf_d_panther")
|
||||
@@ -55,3 +55,16 @@ def test_model_strips_unit_model_prefixes_for_dead_matching():
|
||||
assert bob["units"][0]["dead"] is True
|
||||
assert bob["units"][0]["unit_type"] == "tank"
|
||||
assert bob["units"][0]["unit_class"] == "medium tank"
|
||||
|
||||
|
||||
def test_model_ignores_spectra_unit_normalized_for_vehicle_name():
|
||||
game = _game()
|
||||
game["players"]["1"]["units"][0]["unit"] = "germ_pzkpfw_V_ausf_d_panther"
|
||||
game["players"]["1"]["units"][0]["unit_normalized"] = "Bad Spectra Name"
|
||||
|
||||
model = build_scoreboard_model(game, "<English>")
|
||||
|
||||
assert model is not None
|
||||
alice = model["teams"][0]["players"][0]
|
||||
assert alice["units"][0]["internal"] == "germ_pzkpfw_V_ausf_d_panther"
|
||||
assert alice["units"][0]["name"] == "Panther D"
|
||||
|
||||
Reference in New Issue
Block a user