From 67e612f2e2d08ae1889b51b5b1bc00a148905483 Mon Sep 17 00:00:00 2001 From: Marcus Messer Date: Thu, 20 Aug 2026 11:37:25 +0100 Subject: [PATCH] Added tests for order operators and fixed comparison operator in `less_than_or_equal_node` --- app/context/physical_quantity.py | 2 +- .../physical_quantity_evaluation_test.py | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/context/physical_quantity.py b/app/context/physical_quantity.py index 3155ac5..66f8923 100644 --- a/app/context/physical_quantity.py +++ b/app/context/physical_quantity.py @@ -208,7 +208,7 @@ def less_than_node(criterion, parameters, label=None): def less_than_or_equal_node(criterion, parameters, label=None): # TODO: Add nodes for the equal case - graph = comparison_base_graph(criterion, parameters, comparison_operator=">=", label=label) + graph = comparison_base_graph(criterion, parameters, comparison_operator="<=", label=label) return graph diff --git a/app/tests/physical_quantity_evaluation_test.py b/app/tests/physical_quantity_evaluation_test.py index accd0b2..6d1f635 100644 --- a/app/tests/physical_quantity_evaluation_test.py +++ b/app/tests/physical_quantity_evaluation_test.py @@ -269,6 +269,33 @@ def test_quantity_with_multiple_of_positive_value(self): result = evaluation_function(res, ans, params, include_test_data=True) assert result["is_correct"] is True + @pytest.mark.parametrize( + "response, answer, order_operator, value", + [ + ("10 Hz", "5 Hz", ">", True), + ("5 Hz", "10 Hz", ">", False), + ("10 Hz", "10 Hz", ">", False), + ("10 Hz", "5 Hz", "<", False), + ("5 Hz", "10 Hz", "<", True), + ("10 Hz", "10 Hz", "<", False), + ("10 Hz", "5 Hz", ">=", True), + ("5 Hz", "10 Hz", ">=", False), + ("10 Hz", "10 Hz", ">=", True), + ("10 Hz", "5 Hz", "<=", False), + ("5 Hz", "10 Hz", "<=", True), + ("10 Hz", "10 Hz", "<=", True), + ] + ) + def test_order_operators(self, response, answer, order_operator, value): + params = { + "strict_syntax": False, + "physical_quantity": True, + "elementary functions": True, + "criteria": "response "+order_operator+" answer" + } + result = evaluation_function(response, answer, params, include_test_data=True) + assert result["is_correct"] is value + def test_radians_to_frequency(self): ans = "2*pi*f radian/second" res = "f Hz"