diff --git a/tests/core/evaluators/test_greater_than.py b/tests/core/evaluators/test_greater_than.py index 8da0c432..72a6cba2 100644 --- a/tests/core/evaluators/test_greater_than.py +++ b/tests/core/evaluators/test_greater_than.py @@ -22,3 +22,32 @@ def test_evaluate_passing(): def test_evaluate_failing(): result = evaluator.evaluate(evaluator_input2, evaluator_data2) assert result == {"passed": False, "message": f"`{evaluator_input2}` is not greater than `{evaluator_data2}`"} + + +@mark.parametrize( + "value,other,passed,message", + [ + (5, 5, False, "`5` is not greater than `5`"), + (1.5, 1.25, True, "`1.5` is greater than `1.25`"), + (1.25, 1.5, False, "`1.25` is not greater than `1.5`"), + (2.5, 2, True, "`2.5` is greater than `2`"), + ], + ids=["equal", "greater-floats", "lesser-floats", "float-and-integer"], +) +def test_evaluate_numeric_edge_cases(value, other, passed, message): + assert evaluator.evaluate(value, other) == {"passed": passed, "message": message} + + +@mark.failing +@mark.parametrize( + "value,other,message", + [ + (None, 1, "'>' not supported between instances of 'NoneType' and 'int'"), + (None, None, "'>' not supported between instances of 'NoneType' and 'NoneType'"), + ("5", 5, "'>' not supported between instances of 'str' and 'int'"), + (5, "5", "'>' not supported between instances of 'int' and 'str'"), + ], + ids=["none-and-number", "none-and-none", "string-and-number", "number-and-string"], +) +def test_evaluate_invalid_comparisons(value, other, message): + assert evaluator.evaluate(value, other) == {"passed": False, "message": message} diff --git a/tests/core/evaluators/test_greater_than_equal_to.py b/tests/core/evaluators/test_greater_than_equal_to.py index 20fae9ba..70056717 100644 --- a/tests/core/evaluators/test_greater_than_equal_to.py +++ b/tests/core/evaluators/test_greater_than_equal_to.py @@ -25,3 +25,32 @@ def test_evaluate_failing(): "passed": False, "message": f"`{evaluator_input2}` is not greater than or equal to `{evaluator_data2}`", } + + +@mark.parametrize( + "value,other,passed,message", + [ + (5, 5, True, "`5` is greater than equal to `5`"), + (1.5, 1.25, True, "`1.5` is greater than equal to `1.25`"), + (1.25, 1.5, False, "`1.25` is not greater than or equal to `1.5`"), + (2.5, 2, True, "`2.5` is greater than equal to `2`"), + ], + ids=["equal", "greater-floats", "lesser-floats", "float-and-integer"], +) +def test_evaluate_numeric_edge_cases(value, other, passed, message): + assert evaluator.evaluate(value, other) == {"passed": passed, "message": message} + + +@mark.failing +@mark.parametrize( + "value,other,message", + [ + (None, 1, "'>=' not supported between instances of 'NoneType' and 'int'"), + (None, None, "'>=' not supported between instances of 'NoneType' and 'NoneType'"), + ("5", 5, "'>=' not supported between instances of 'str' and 'int'"), + (5, "5", "'>=' not supported between instances of 'int' and 'str'"), + ], + ids=["none-and-number", "none-and-none", "string-and-number", "number-and-string"], +) +def test_evaluate_invalid_comparisons(value, other, message): + assert evaluator.evaluate(value, other) == {"passed": False, "message": message} diff --git a/tests/core/evaluators/test_less_than.py b/tests/core/evaluators/test_less_than.py index e4efff4f..748c2614 100644 --- a/tests/core/evaluators/test_less_than.py +++ b/tests/core/evaluators/test_less_than.py @@ -22,3 +22,32 @@ def test_evaluate_passing(): def test_evaluate_failing(): result = evaluator.evaluate(evaluator_input2, evaluator_data2) assert result == {"passed": False, "message": f"`{evaluator_input2}` is not less than `{evaluator_data2}`"} + + +@mark.parametrize( + "value,other,passed,message", + [ + (5, 5, False, "`5` is not less than `5`"), + (1.5, 1.25, False, "`1.5` is not less than `1.25`"), + (1.25, 1.5, True, "`1.25` is less than `1.5`"), + (2.5, 2, False, "`2.5` is not less than `2`"), + ], + ids=["equal", "greater-floats", "lesser-floats", "float-and-integer"], +) +def test_evaluate_numeric_edge_cases(value, other, passed, message): + assert evaluator.evaluate(value, other) == {"passed": passed, "message": message} + + +@mark.failing +@mark.parametrize( + "value,other,message", + [ + (None, 1, "'<' not supported between instances of 'NoneType' and 'int'"), + (None, None, "'<' not supported between instances of 'NoneType' and 'NoneType'"), + ("5", 5, "'<' not supported between instances of 'str' and 'int'"), + (5, "5", "'<' not supported between instances of 'int' and 'str'"), + ], + ids=["none-and-number", "none-and-none", "string-and-number", "number-and-string"], +) +def test_evaluate_invalid_comparisons(value, other, message): + assert evaluator.evaluate(value, other) == {"passed": False, "message": message} diff --git a/tests/core/evaluators/test_less_than_equal_to.py b/tests/core/evaluators/test_less_than_equal_to.py index 7aa09005..8909bc11 100644 --- a/tests/core/evaluators/test_less_than_equal_to.py +++ b/tests/core/evaluators/test_less_than_equal_to.py @@ -29,3 +29,32 @@ def test_evaluate_failing(): "passed": False, "message": f"{json_format_value(evaluator_input2)} is not less than or equal to {json_format_value(evaluator_data2)}", } + + +@mark.parametrize( + "value,other,passed,message", + [ + (5, 5, True, "`5` is less than equal to `5`"), + (1.5, 1.25, False, "`1.5` is not less than or equal to `1.25`"), + (1.25, 1.5, True, "`1.25` is less than equal to `1.5`"), + (2.5, 2, False, "`2.5` is not less than or equal to `2`"), + ], + ids=["equal", "greater-floats", "lesser-floats", "float-and-integer"], +) +def test_evaluate_numeric_edge_cases(value, other, passed, message): + assert evaluator.evaluate(value, other) == {"passed": passed, "message": message} + + +@mark.failing +@mark.parametrize( + "value,other,message", + [ + (None, 1, "'<=' not supported between instances of 'NoneType' and 'int'"), + (None, None, "'<=' not supported between instances of 'NoneType' and 'NoneType'"), + ("5", 5, "'<=' not supported between instances of 'str' and 'int'"), + (5, "5", "'<=' not supported between instances of 'int' and 'str'"), + ], + ids=["none-and-number", "none-and-none", "string-and-number", "number-and-string"], +) +def test_evaluate_invalid_comparisons(value, other, message): + assert evaluator.evaluate(value, other) == {"passed": False, "message": message}