27 lines
1.1 KiB
Python
27 lines
1.1 KiB
Python
from __future__ import annotations
|
|
import pytest
|
|
from legal_mcp.services import corroboration as cor
|
|
|
|
@pytest.mark.parametrize("raw,expected", [
|
|
({"treatment": "followed"}, "followed"),
|
|
({"treatment": "OVERRULED"}, "overruled"), # case-insensitive
|
|
({"treatment": "bananas"}, "mentioned"), # unknown -> neutral default
|
|
({}, "mentioned"), # missing -> neutral default
|
|
])
|
|
def test_coerce_treatment(raw, expected):
|
|
assert cor._coerce_treatment(raw) == expected
|
|
|
|
def test_treatment_polarity():
|
|
assert cor.is_positive("followed") and cor.is_positive("explained")
|
|
assert cor.is_negative("distinguished") and cor.is_negative("overruled")
|
|
assert not cor.is_positive("mentioned") and not cor.is_negative("mentioned")
|
|
|
|
def test_match_accepts_above_threshold():
|
|
assert cor.accept_match(("h1", 0.62), floor=0.50) == "h1"
|
|
|
|
def test_match_rejects_below_threshold():
|
|
assert cor.accept_match(("h1", 0.41), floor=0.50) is None
|
|
|
|
def test_match_rejects_empty():
|
|
assert cor.accept_match(None, floor=0.50) is None
|