This commit is contained in:
Yaojia Wang
2026-02-12 23:06:00 +01:00
parent ad5ed46b4c
commit 58d36c8927
26 changed files with 3903 additions and 2551 deletions

View File

@@ -203,15 +203,33 @@ class TestValueSelectorOcrField:
assert len(result) == 1
assert result[0].text == "94228110015950070"
def test_ignores_short_digit_tokens(self):
"""Tokens with fewer than 5 digits are not OCR references."""
tokens = _tokens("OCR", "123")
def test_ignores_single_digit_tokens(self):
"""Tokens with fewer than 2 digits are not OCR references."""
tokens = _tokens("OCR", "5")
result = ValueSelector.select_value_tokens(tokens, "OCR")
# Fallback: return all tokens since no valid OCR found
assert len(result) == 2
def test_ocr_4_digit_token_selected(self):
"""4-digit OCR token should be selected."""
tokens = _tokens("OCR", "3046")
result = ValueSelector.select_value_tokens(tokens, "OCR")
assert len(result) == 1
assert result[0].text == "3046"
def test_ocr_2_digit_token_selected(self):
"""2-digit OCR token should be selected."""
tokens = _tokens("OCR", "42")
result = ValueSelector.select_value_tokens(tokens, "OCR")
assert len(result) == 1
assert result[0].text == "42"
class TestValueSelectorInvoiceNumberField:
"""Tests for InvoiceNumber field value selection."""