32 lines
1.2 KiB
Python
32 lines
1.2 KiB
Python
import pytest
|
|
import os
|
|
import sys
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
|
|
from app import translate, display_team_name, COLUMN_LABELS, TRANSLATIONS
|
|
|
|
|
|
def test_display_team_name_localization():
|
|
assert display_team_name('Germany', 'de') == 'Deutschland'
|
|
assert display_team_name('Germany', 'en') == 'Germany'
|
|
assert display_team_name('Spain', 'de') == 'Spain'
|
|
|
|
|
|
def test_dynamic_focus_label_creation():
|
|
focus = 'Spain'
|
|
lang = 'en'
|
|
col_map = COLUMN_LABELS.get(lang, {}).copy()
|
|
col_map['Focus group place'] = f"{display_team_name(focus, lang)} {translate('group_place_phrase', lang)}"
|
|
col_map['Focus path'] = f"{display_team_name(focus, lang)} {translate('path_phrase', lang)}"
|
|
assert col_map['Focus group place'] == 'Spain group place'
|
|
assert col_map['Focus path'] == 'Spain path'
|
|
|
|
|
|
def test_no_untranslated_deutsch_in_non_de():
|
|
# ensure no non-de translation contains the German word 'Deutschland'
|
|
bad = []
|
|
for key, d in TRANSLATIONS.items():
|
|
for lang, text in d.items():
|
|
if lang != 'de' and 'Deutschland' in text:
|
|
bad.append((key, lang, text))
|
|
assert not bad, f"Found German 'Deutschland' in non-de translations: {bad}"
|