"""Unit tests for the adjustments validation utility functions.""" from abacus_common_logic.adjustments_validation.utils import ( clean_upc, has_intersection, is_float, is_integer, load_json, ) def test_clean_upc(): """Test cleaning a UPC.""" assert clean_upc('111122223333') == '111122223333' assert clean_upc('0111102220333') == '111102220333' assert clean_upc('00111122223333') == '0111122223333' def test_is_integer(): """Test checking if a string represents an integer.""" assert is_integer('1') assert not is_integer('1.2') assert not is_integer('a') assert not is_integer(str(float('nan'))) def test_is_float(): """Test checking if a string represents a float.""" assert is_float('1') assert is_float('1.2') assert not is_float('a') assert not is_float(str(float('nan'))) def test_has_intersection(): """Test checking if two sets intersect.""" assert has_intersection({1, 2}, {2, 3}) assert not has_intersection({1, 2}, {3, 4}) def test_load_json(): """Test converting a JSON string.""" assert load_json('{"a": 1}') == {'a': 1} assert load_json('') is None assert load_json(None) is None