@@ -27,6 +27,9 @@ def function_plotter(app_instance, qtbot):
27
27
return plotter
28
28
29
29
30
+ # good input tests
31
+
32
+
30
33
def test_valid_function_input (function_plotter , qtbot ):
31
34
function_plotter .function_input .setText ("5*x^3 + 2*x" )
32
35
function_plotter .min_input .setText ("0" )
@@ -99,11 +102,62 @@ def test_floating_point_coefficients(function_plotter, qtbot):
99
102
assert function_plotter .ax .has_data ()
100
103
101
104
102
-
103
-
104
105
def test_function_with_spaces (function_plotter , qtbot ):
105
106
function_plotter .function_input .setText (" x ^ 2 + 3 * x " )
106
107
function_plotter .min_input .setText ("-5" )
107
108
function_plotter .max_input .setText ("5" )
108
109
qtbot .mouseClick (function_plotter .plot_button , Qt .LeftButton )
109
110
assert function_plotter .ax .has_data ()
111
+
112
+
113
+ # bad input tests
114
+
115
+
116
+ # def test_invalid_function_input_characters(function_plotter, qtbot):
117
+ # function_plotter.function_input.setText("5*x^3 + 2*x + !")
118
+ # function_plotter.min_input.setText("0")
119
+ # function_plotter.max_input.setText("10")
120
+ # qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
121
+ # qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
122
+ # message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
123
+ # assert "Function contains invalid characters." in message_box.text()
124
+
125
+
126
+ # def test_empty_function_input(function_plotter, qtbot):
127
+ # function_plotter.function_input.setText("")
128
+ # function_plotter.min_input.setText("0")
129
+ # function_plotter.max_input.setText("10")
130
+ # qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
131
+ # qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
132
+ # message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
133
+ # assert "Function cannot be empty." in message_box.text()
134
+
135
+
136
+ # def test_invalid_min_max_values(function_plotter, qtbot):
137
+ # function_plotter.function_input.setText("5*x^3 + 2*x")
138
+ # function_plotter.min_input.setText("10")
139
+ # function_plotter.max_input.setText("0")
140
+ # qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
141
+ # qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
142
+ # message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
143
+ # assert "Min value must be less than Max value." in message_box.text()
144
+
145
+
146
+ # def test_non_numeric_min_max_values(function_plotter, qtbot):
147
+ # function_plotter.function_input.setText("5*x^3 + 2*x")
148
+ # function_plotter.min_input.setText("a")
149
+ # function_plotter.max_input.setText("b")
150
+ # qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
151
+ # qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
152
+ # message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
153
+ # assert "Min and Max values must be numbers." in message_box.text()
154
+
155
+
156
+ # def test_empty_min_max_values(function_plotter, qtbot):
157
+ # function_plotter.function_input.setText("x^2")
158
+ # function_plotter.min_input.setText("")
159
+ # function_plotter.max_input.setText("")
160
+ # qtbot.mouseClick(function_plotter.plot_button, Qt.LeftButton)
161
+ # qtbot.waitUntil(lambda: function_plotter.centralWidget().findChildren(QMessageBox))
162
+ # message_box = function_plotter.centralWidget().findChildren(QMessageBox)[0]
163
+ # assert "Min and Max values cannot be empty." in message_box.text()
0 commit comments