50 lines
1.6 KiB
Python
50 lines
1.6 KiB
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from khl_site.khl_data_center import player_sidebar_name
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
def test_player_sidebar_uses_first_name_surname_and_rejects_menu_text() -> None:
|
|
player = {
|
|
"identity": {
|
|
"first_name": "Иван",
|
|
"last_name": "Иванов",
|
|
"full_name": "Иван Иванов",
|
|
},
|
|
"profile": {},
|
|
}
|
|
assert player_sidebar_name(player, "10") == "Иван Иванов"
|
|
|
|
broken = {
|
|
"identity": {
|
|
"first_name": "Конференция",
|
|
"last_name": "«Запад»",
|
|
"full_name": "Конференция «Запад»",
|
|
},
|
|
"profile": {"name": "Конференция «Запад»"},
|
|
}
|
|
assert player_sidebar_name(broken, "56") == "Имя не загружено"
|
|
|
|
repaired = {
|
|
"identity": {},
|
|
"profile": {"list_name_ru": "Петров Пётр", "name": "Пётр Петров"},
|
|
}
|
|
assert player_sidebar_name(repaired, "20") == "Пётр Петров"
|
|
|
|
|
|
def test_player_card_no_longer_references_undefined_flag() -> None:
|
|
html = (ROOT / "khl_site" / "web" / "index.html").read_text(encoding="utf-8")
|
|
assert "links,flag,compact:true" not in html
|
|
assert "facts,links,compact:true" in html
|
|
assert "KHL_API_BASE" in html
|
|
|
|
|
|
def test_admin_khl_tab_is_conditional_on_selected_khl_tournament():
|
|
"""The remaining admin renderer gates KHL correctly; its navigation entry moved to the runtime workspace."""
|
|
from tests.ui_contract_support import ui_contract
|
|
ui_contract("khl_gate")
|