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

61 lines
2.0 KiB
Python

from pathlib import Path
from linkki_poster.models import Language
from linkki_poster.scanner import scan_directory
def write_file(path: Path, text: str = "x") -> None:
path.write_text(text, encoding="utf-8")
def test_global_prefix_first_family_wins(tmp_path: Path) -> None:
write_file(tmp_path / "Kuva1.jpg")
write_file(tmp_path / "Image1.jpg")
write_file(tmp_path / "Suomi.md", "hello")
result = scan_directory(tmp_path)
assert [path.name for path in result.global_images] == ["Kuva1.jpg"]
def test_numeric_suffix_rule_and_case_insensitive_matching(tmp_path: Path) -> None:
write_file(tmp_path / "KuvaA.jpg")
write_file(tmp_path / "Kuva2.jpg")
write_file(tmp_path / "sUoMi.MD", "hello")
write_file(tmp_path / "sUoMi10.PNG")
write_file(tmp_path / "sUoMi2.jpg")
result = scan_directory(tmp_path)
assert [path.name for path in result.global_images] == ["Kuva2.jpg"]
assert len(result.languages) == 1
assert result.languages[0].language == Language.FI
assert [path.name for path in result.languages[0].images] == ["sUoMi2.jpg", "sUoMi10.PNG"]
def test_natural_sort_and_text_precedence(tmp_path: Path) -> None:
write_file(tmp_path / "English.md", "right")
write_file(tmp_path / "english10.png")
write_file(tmp_path / "english9.webp")
write_file(tmp_path / "english9.jpg")
write_file(tmp_path / "english.jpg")
result = scan_directory(tmp_path)
assert len(result.languages) == 1
assets = result.languages[0]
assert assets.text_file.name == "English.md"
assert [path.name for path in assets.images] == [
"english.jpg",
"english9.jpg",
"english9.webp",
"english10.png",
]
def test_empty_text_file_is_skipped_as_missing_language(tmp_path: Path) -> None:
write_file(tmp_path / "Suomi.md", "Hei")
write_file(tmp_path / "Svenska.md", " \n\t")
write_file(tmp_path / "English.md", "")
result = scan_directory(tmp_path)
assert [assets.language for assets in result.languages] == [Language.FI]