feat(nlp-service): wire NLP_FUZZY_THRESHOLD env var with 0-100 validation

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-07 15:48:57 +02:00
parent 99d6a9a428
commit 2eb5572d7a
3 changed files with 43 additions and 3 deletions

View File

@@ -81,6 +81,23 @@ def test_parse_all_languages(client):
assert r.json()["dateTo"] == "1920-12-31", f"Wrong dateTo for lang={lang}"
def test_fuzzy_threshold_valid_range():
from main import _parse_fuzzy_threshold
assert _parse_fuzzy_threshold("80") == 80
assert _parse_fuzzy_threshold("0") == 0
assert _parse_fuzzy_threshold("100") == 100
def test_fuzzy_threshold_out_of_range_raises():
from main import _parse_fuzzy_threshold
with pytest.raises(ValueError):
_parse_fuzzy_threshold("101")
with pytest.raises(ValueError):
_parse_fuzzy_threshold("-1")
with pytest.raises(ValueError):
_parse_fuzzy_threshold("abc")
def test_parse_exceeds_max_length_returns_422(client):
r = client.post("/parse", json={"query": "a" * 501, "lang": "de"})
assert r.status_code == 422