Files
docker-images/linkki-tiedotus/tests/test_app_language.py
T
ajp_anton 8ec3cde4f2
Build custom container images / build (map[base_image:php:8-fpm-alpine build_args:PHP_VERSION=8 context:php8-pgsql fingerprint_command:{ apk info -v | LC_ALL=C sort; find /usr/local/lib/php/extensions /usr/local/etc/php/conf.d -type f -exec sha256sum {} + | LC_ALL=C sort; } name:ph… (push) Successful in 48s
Build custom container images / build (map[base_image:postgres:18 build_args:PG_VERSION=18 POSTGIS_VERSION=3 VCHORD_VERSION=0.5.3 context:postgres fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; find /usr/lib/postgresql -type f -exec sha256su… (push) Successful in 55s
Build custom container images / build (map[base_image:python:3 build_args:PYTHON_VERSION=3 context:python-tools fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:python-tools oci_labels:org.opencontainers.ima… (push) Successful in 54s
Build custom container images / build (map[base_image:python:3.12-slim build_args:PYTHON_VERSION=3.12-slim context:linkki-tiedotus fingerprint_command:{ dpkg-query -W -f='${binary:Package}=${Version}\n' | LC_ALL=C sort; pip freeze | LC_ALL=C sort; } name:linkki-tiedotus oci_labels:… (push) Successful in 39s
Add Linkki broadcast image
2026-08-19 20:51:26 +00:00

26 lines
971 B
Python

from webapp.app import parse_accept_language, resolve_effective_ui_language
class _Request:
def __init__(self, header: str):
self.headers = {"accept-language": header}
def test_parse_accept_language_collects_supported_languages_in_browser_order() -> None:
assert parse_accept_language("en-US,en;q=0.9,fi;q=0.8,sv;q=0.7") == ["en", "fi", "sv"]
def test_resolve_effective_ui_language_prefers_finnish_then_swedish_then_english() -> None:
request = _Request("en-US,en;q=0.9,sv;q=0.8,fi;q=0.7")
assert resolve_effective_ui_language(request, "auto") == "fi"
def test_resolve_effective_ui_language_falls_back_to_english_when_no_supported_match() -> None:
request = _Request("de-DE,de;q=0.9,fr;q=0.8")
assert resolve_effective_ui_language(request, "auto") == "en"
def test_resolve_effective_ui_language_keeps_explicit_language() -> None:
request = _Request("fi,sv,en")
assert resolve_effective_ui_language(request, "sv") == "sv"