-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_app.py
89 lines (66 loc) · 2.87 KB
/
test_app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import pytest
from PyQt5 import QtCore
from pytestqt.plugin import qtbot
from plotX import plotX
@pytest.fixture
def app(qtbot):
app_under_test = plotX()
qtbot.addWidget(app_under_test)
return app_under_test
def test_submit_empty_data_raise_error(app, qtbot):
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Empty Data"
def test_submit_empty_minX_and_maxX_raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Empty Data"
def test_submit_empty_Function_and_maxX_raise_error(app, qtbot):
qtbot.keyClicks(app.minX, "value")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Empty Data"
def test_submit_empty_minX_and_Function_raise_error(app, qtbot):
qtbot.keyClicks(app.maxX, "value")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Empty Data"
def test_submit__string_minX__raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.keyClicks(app.minX, "value")
qtbot.keyClicks(app.maxX, "-5")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Enter a numeric value for minX"
def test_submit__string_maxX__raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.keyClicks(app.minX, "5.5")
qtbot.keyClicks(app.maxX, "value")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Enter a numeric value for maxX"
def test_submit__minX_greater_than_maxX__raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.keyClicks(app.minX, "5.5")
qtbot.keyClicks(app.maxX, "1")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert (
app.error_message_label.text()
== "minX can't be greater than maxX.\nThey will be swaped"
)
def test_submit__minX_equal_maxX__raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.keyClicks(app.minX, "5.5")
qtbot.keyClicks(app.maxX, "5.5")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert (
app.error_message_label.text()
== "minX can't be equal to to maxX"
)
def test_submit__string_invalid_function__raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "Function")
qtbot.keyClicks(app.minX, "5.5")
qtbot.keyClicks(app.maxX, "66")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == "Invalid Process"
def test_valid_submit__does_not_raise_error(app, qtbot):
qtbot.keyClicks(app.F_X, "x+2")
qtbot.keyClicks(app.minX, "5.5")
qtbot.keyClicks(app.maxX, "66")
qtbot.mouseClick(app.PlotButton, QtCore.Qt.LeftButton)
assert app.error_message_label.text() == ""