32 lines
1015 B
Python
32 lines
1015 B
Python
import sys, os
|
|
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..")))
|
|
from comparator.field_compare import compare_field, DEFAULT_TOLERANCE
|
|
|
|
|
|
def test_exact_match():
|
|
assert compare_field("F1", "1500000", "1500000", "decimal").status == "PASS"
|
|
|
|
|
|
def test_within_tolerance():
|
|
assert compare_field("F1", "1500000", "1499999.99", "decimal", DEFAULT_TOLERANCE).status == "TOLERATED"
|
|
|
|
|
|
def test_beyond_tolerance():
|
|
assert compare_field("F1", "1500000", "1000000", "decimal", DEFAULT_TOLERANCE).status == "MISMATCH"
|
|
|
|
|
|
def test_string_trim():
|
|
assert compare_field("F1", "A ", "A", "string").status == "PASS"
|
|
|
|
|
|
def test_date_normalization():
|
|
assert compare_field("F1", "20260522", "2026-05-22", "date").status == "PASS"
|
|
|
|
|
|
def test_default_zero():
|
|
assert compare_field("F1", "\x00\x00\x00\x00\x00", "0", "decimal").status in ("PASS", "TOLERATED")
|
|
|
|
|
|
def test_java_null():
|
|
assert compare_field("F1", "1500000", "None", "decimal").status in ("MISMATCH", "NOT_SET")
|