Skip to content

Commit

Permalink
tests fuxed with the new changes for mode switch data passing
Browse files Browse the repository at this point in the history
  • Loading branch information
mpatrou committed Jan 6, 2025
1 parent 1cb02a3 commit 93ffaa4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 27 deletions.
20 changes: 20 additions & 0 deletions tests/hppt_presenter/test_presenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ def test_Selector_widget_powder_mode(hyspec_app, qtbot):

assert not hyspec_view.SCW.isVisibleTo(hyspec_app)
assert hyspec_view.CW.modQ_edit.isEnabled()


def test_switch_to_SC(hyspec_app, qtbot):
"""Test switch_to_SC() set SingleCrystalWidget visible"""
hyspec_app.show()
qtbot.waitUntil(hyspec_app.show, timeout=5000)
hyspec_view = hyspec_app.main_window.HPPT_view
hyspec_view.switch_to_SC()
assert hyspec_view.SCW.isVisibleTo(hyspec_view)
assert not hyspec_view.CW.modQ_edit.isEnabled()


def test_switch_to_Powder(hyspec_app, qtbot):
"""Test switch_to_Powder() set SingleCrystalWidget visible"""
hyspec_app.show()
qtbot.waitUntil(hyspec_app.show, timeout=5000)
hyspec_view = hyspec_app.main_window.HPPT_view
hyspec_view.switch_to_Powder()
assert not hyspec_view.SCW.isVisibleTo(hyspec_view)
assert hyspec_view.CW.modQ_edit.isEnabled()
16 changes: 0 additions & 16 deletions tests/hppt_view/test_basegui.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,3 @@ def test_Selector_widget(qtbot):

assert SELWidget.powder_rb.text() == "Po&wder"
assert SELWidget.sc_rb.text() == "Single C&rystal"


def test_switch_to_SC():
"""Test switch_to_SC() set SingleCrystalWidget visible"""
view = hppt_view.HyspecPPTView()
view.switch_to_SC()
assert view.SCW.isVisibleTo(view)
assert not view.CW.modQ_edit.isEnabled()


def test_switch_to_Powder():
"""Test switch_to_Powder() set SingleCrystalWidget visible"""
view = hppt_view.HyspecPPTView()
view.switch_to_Powder()
assert not view.SCW.isVisibleTo(view)
assert view.CW.modQ_edit.isEnabled()
27 changes: 16 additions & 11 deletions tests/hppt_view/test_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ def test_Experiment_validators(qtbot):
# all valid
qtbot.keyClicks(ExpWidget.S2_edit, "0")
ExpWidget.S2_edit.editingFinished.emit()
mock_slot.assert_called_once_with({"Ei": 30.0, "S2": -40.0, "alpha_p": -45.0, "plot_type": PLOT_TYPES[0]})
mock_slot.assert_called_once_with(
{"data": {"Ei": 30.0, "S2": -40.0, "alpha_p": -45.0, "plot_type": PLOT_TYPES[0]}, "name": "experiment"}
)


def test_Single_Crystal_validators(qtbot):
Expand Down Expand Up @@ -91,15 +93,18 @@ def test_Single_Crystal_validators(qtbot):
SCWidget.a_edit.editingFinished.emit()
mock_slot.assert_called_once_with(
{
"a": 45.0,
"alpha": 45.0,
"b": 45.0,
"beta": 45.0,
"c": 45.0,
"gamma": 45.0,
"h": -45.0,
"k": -45.0,
"l": -45.0,
"data": {
"a": 45.0,
"alpha": 45.0,
"b": 45.0,
"beta": 45.0,
"c": 45.0,
"gamma": 45.0,
"h": -45.0,
"k": -45.0,
"l": -45.0,
},
"name": "sc_lattice",
}
)

Expand Down Expand Up @@ -129,4 +134,4 @@ def test_Crosshairs_validators(qtbot):
# all valid
qtbot.keyClicks(CHWidget.modQ_edit, "\b")
CHWidget.DeltaE_edit.editingFinished.emit()
mock_slot.assert_called_once_with({"DeltaE": -1.0, "modQ": 2.0})
mock_slot.assert_called_once_with({"data": {"DeltaE": -1.0, "modQ": 2.0}, "name": "crosshair"})

0 comments on commit 93ffaa4

Please sign in to comment.