Skip to content

Commit 11a0cbc

Browse files
committed
add new test for invalid axis data entry exception handling
1 parent 0828b12 commit 11a0cbc

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/test_models_designaxis.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from pathlib import Path
22

3+
import pytest
4+
35
from PyQt5.QtWidgets import QTableView
46

57
from slice.models import DesignAxisModel, FontModel
@@ -139,6 +141,35 @@ def test_designaxis_model_instance_data_validates_missing_data(qtbot):
139141
assert model.instance_data_validates_missing_data() is True
140142

141143

144+
def test_designaxis_model_instance_data_validates_invalid_data(qtbot):
145+
tableview = QTableView()
146+
model = DesignAxisModel()
147+
tableview.setModel(model)
148+
qtbot.addWidget(tableview)
149+
model.load_font(get_font_model())
150+
151+
# without user entered definitions, we should get
152+
# an empty axis tag / value dict
153+
# this is intentional so that these axes remain
154+
# variable
155+
assert model.get_instance_data() == {}
156+
157+
assert model.instance_data_validates_missing_data() is False
158+
159+
# fill model and try again
160+
# but this time add invalid data
161+
# this should prompt a ValueError exception
162+
model._data[0][1] = ""
163+
model._data[1][1] = "BOGUSVALUE"
164+
model._data[2][1] = ""
165+
model._data[3][1] = ""
166+
model._data[4][1] = ""
167+
model.layoutChanged.emit()
168+
169+
with pytest.raises(ValueError):
170+
model.instance_data_validates_missing_data()
171+
172+
142173
def test_designaxis_model_get_number_of_axes(qtbot):
143174
tableview = QTableView()
144175
model = DesignAxisModel()

0 commit comments

Comments
 (0)