| Server IP : 202.61.199.114 / Your IP : 216.73.217.139 Web Server : nginx/1.22.1 System : Linux de.arni-solutions.de 6.1.0-49-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64 User : web20 ( 1018) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/clients/client2/web31/web/plate-ai-api/tests/ |
Upload File : |
"""Deterministische Tests des Kennzeichen-Postprocessings (Phase 4)."""
from app.config import settings
from app.services.plate_postprocessor import PlatePostprocessor
PP = PlatePostprocessor(settings.path(settings.regions_de_file))
def test_region_rostock():
r = PP.process("HRO AB 123", 0.9)
assert r.region_code == "HRO"
assert r.region_name == "Rostock"
assert r.region_state == "Mecklenburg-Vorpommern"
assert r.normalized == "HRO-AB-123"
assert r.plate_type == "standard"
def test_region_berlin_single_letter():
r = PP.process("B AB 1234", 0.9)
assert r.region_code == "B"
assert r.region_name == "Berlin"
assert r.normalized == "B-AB-1234"
def test_region_muenchen():
r = PP.process("M X 99", 0.8)
assert r.region_code == "M"
assert r.region_name == "München"
def test_electric_suffix():
r = PP.process("HH AB 123 E", 0.9)
assert r.plate_type == "electric"
assert r.normalized.endswith("E")
def test_historic_suffix():
r = PP.process("K AB 12 H", 0.9)
assert r.plate_type == "historic"
def test_normalization_removes_noise():
r = PP.process("hro-ab-123", 0.7)
assert r.normalized == "HRO-AB-123"
def test_season_plate():
# Saisonkennzeichen: Monate 04..10 rechts angehaengt
r = PP.process("HRO AB 12 0410", 0.8)
assert r.season == "04-10"
assert r.plate_type == "season"
def test_careful_correction_zero_to_o():
# '0RO' -> 'ORO'? Nein: HR0 (Ziffer 0) am Bezirksende -> HRO (Buchstabe O)
r = PP.process("HR0 AB 123", 0.9)
assert r.region_code == "HRO"
assert any("->" in c for c in r.corrections)
assert r.confidence < 0.9 # Korrektur senkt Confidence
def test_unknown_region_no_crash():
r = PP.process("ZZZ QQ 1", 0.5)
# ZZZ ist kein gueltiger Bezirk -> kein DE-Muster
assert r.region_code is None
assert r.plate_type in ("unknown",)
def test_empty_input():
r = PP.process("", 0.0)
assert r.plate_type == "unknown"
assert "empty_ocr" in r.warnings