MCPcopy Create free account
hub / github.com/NSLS2/PyXRF / test_RangeManager_2

Function test_RangeManager_2

pyxrf/gui_module/tests/test_useful_widgets.py:268–295  ·  view source on GitHub ↗

Test the `reset()` method: resetting the selection

(qtbot, full_range, selection, value_type)

Source from the content-addressed store, hash-verified

266])
267# fmt: on
268def test_RangeManager_2(qtbot, full_range, selection, value_type):
269 """Test the `reset()` method: resetting the selection"""
270 rman = RangeManager()
271 qtbot.addWidget(rman)
272 rman.show()
273
274 rman.set_value_type(value_type)
275 rman.set_range(full_range[0], full_range[1])
276 rman.set_selection(value_low=selection[0], value_high=selection[1])
277
278 npt.assert_array_almost_equal(rman.get_range(), full_range, err_msg="Range is set incorrectly")
279
280 # Verify that selection is displayed correctly
281 assert rman.le_min_value.text() == f"{selection[0]:.10g}", "Lower boundary is displayed incorrectly"
282 assert rman.le_max_value.text() == f"{selection[1]:.10g}", "Upper boundary is displayed incorrectly"
283 npt.assert_array_almost_equal(rman.get_selection(), selection, err_msg="Selection is set incorreclty")
284
285 selection_changed = rman.reset()
286 assert selection_changed is True, "Change of selection is incorrectly reported"
287
288 # Verify that selection is displayed correctly
289 assert rman.le_min_value.text() == f"{full_range[0]:.10g}", "Lower boundary is displayed incorrectly"
290 assert rman.le_max_value.text() == f"{full_range[1]:.10g}", "Upper boundary is displayed incorrectly"
291 npt.assert_array_almost_equal(rman.get_selection(), full_range, err_msg="Selection is set incorreclty")
292
293 # Attemtp to reset again (selection shouldn't change)
294 selection_changed = rman.reset()
295 assert selection_changed is False, "Change of selection is incorrectly reported"
296
297
298# fmt: off

Callers

nothing calls this directly

Calls 8

set_value_typeMethod · 0.95
set_rangeMethod · 0.95
set_selectionMethod · 0.95
get_rangeMethod · 0.95
get_selectionMethod · 0.95
resetMethod · 0.95
RangeManagerClass · 0.90
showMethod · 0.80

Tested by

no test coverage detected