Files
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

79 lines
2.6 KiB
Python

import json
import os
from pathlib import Path
from webapp.auth import load_users
from webapp.config import ConfigFileError, load_webapp_config
from webapp.i18n import load_translation_catalog
from webapp.telegram_targets import load_telegram_target_catalog
def test_load_users_reports_invalid_json_with_path(tmp_path: Path) -> None:
users_file = tmp_path / "users.json"
users_file.write_text("{broken", encoding="utf-8")
try:
load_users(users_file)
except ConfigFileError as error:
assert str(users_file) in str(error)
else:
raise AssertionError("Expected ConfigFileError")
def test_load_telegram_target_catalog_reports_invalid_json_with_path(tmp_path: Path) -> None:
config_dir = tmp_path / "config"
config_dir.mkdir()
config_file = config_dir / "telegram_config.json"
config_file.write_text("{broken", encoding="utf-8")
try:
load_telegram_target_catalog(config_dir)
except ConfigFileError as error:
assert str(config_file) in str(error)
else:
raise AssertionError("Expected ConfigFileError")
def test_load_webapp_config_reports_invalid_json_with_path(tmp_path: Path) -> None:
config_dir = tmp_path / "config"
config_dir.mkdir()
config_file = config_dir / "app_config.json"
config_file.write_text("{broken", encoding="utf-8")
previous = os.environ.get("LINKKI_DATA_DIR")
os.environ["LINKKI_DATA_DIR"] = str(tmp_path)
try:
try:
load_webapp_config()
except ConfigFileError as error:
assert str(config_file) in str(error)
else:
raise AssertionError("Expected ConfigFileError")
finally:
if previous is None:
os.environ.pop("LINKKI_DATA_DIR", None)
else:
os.environ["LINKKI_DATA_DIR"] = previous
def test_load_translation_catalog_reports_invalid_json_with_path(tmp_path: Path) -> None:
translations_dir = tmp_path / "translations"
translations_dir.mkdir()
config_file = translations_dir / "catalog.json"
config_file.write_text('{"a":{"en":"line1\nline2"}}', encoding="utf-8")
from webapp import i18n as i18n_module
original = i18n_module.TRANSLATION_CATALOG_FILE
i18n_module.TRANSLATION_CATALOG_FILE = config_file
try:
try:
load_translation_catalog()
except ConfigFileError as error:
assert str(config_file) in str(error)
assert "raw line breaks" in str(error)
else:
raise AssertionError("Expected ConfigFileError")
finally:
i18n_module.TRANSLATION_CATALOG_FILE = original