Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions tests/core/evaluators/test_greater_than.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
29 changes: 29 additions & 0 deletions tests/core/evaluators/test_greater_than_equal_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
29 changes: 29 additions & 0 deletions tests/core/evaluators/test_less_than.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
29 changes: 29 additions & 0 deletions tests/core/evaluators/test_less_than_equal_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Loading