bulid 63
This commit is contained in:
50
tests/test_khl_site_module.py
Normal file
50
tests/test_khl_site_module.py
Normal file
@@ -0,0 +1,50 @@
|
||||
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_surname_first_name_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") == "Игрок #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() -> None:
|
||||
js = (ROOT / "hockey_data" / "static" / "admin-directories.js").read_text(encoding="utf-8")
|
||||
assert 'context.tournamentLevel === "khl"' in js
|
||||
assert 'data-directory-section="khl_site"' in js
|
||||
assert 'src="/khl-site/"' in js
|
||||
Reference in New Issue
Block a user