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

Function test_RangeManager_4

pyxrf/gui_module/tests/test_useful_widgets.py:377–408  ·  view source on GitHub ↗

RangeManager: additional testing of `set_selection()` method: change only higher or lower boundaries of the selection.

(qtbot, full_range, selection, value_type)

Source from the content-addressed store, hash-verified

375])
376# fmt: on
377def test_RangeManager_4(qtbot, full_range, selection, value_type):
378 """
379 RangeManager: additional testing of `set_selection()` method:
380 change only higher or lower boundaries of the selection.
381 """
382 rman = RangeManager()
383 qtbot.addWidget(rman)
384 rman.show()
385
386 def _verify_selection(sel):
387 # Verify that selection is set correctly
388 npt.assert_array_almost_equal(rman.get_selection(), sel, err_msg="Selection is set incorrectly")
389 # Verify that selection is displayed correctly
390 assert rman.le_min_value.text() == f"{sel[0]:.10g}", "Lower boundary is displayed incorrectly"
391 assert rman.le_max_value.text() == f"{sel[1]:.10g}", "Upper boundary is displayed incorrectly"
392
393 rman.set_value_type(value_type)
394 rman.set_range(full_range[0], full_range[1])
395 rman.set_selection(value_low=selection[0], value_high=selection[1])
396 _verify_selection(selection)
397
398 # Change lower boundary
399 sel = (selection[0] + 1, selection[1])
400 result = rman.set_selection(value_low=sel[0])
401 assert result is True, f"Incorrect return value {result} by `set_selection()` method"
402 _verify_selection(sel)
403
404 # Change upper boundary
405 sel = (sel[0], sel[1] - 1)
406 result = rman.set_selection(value_high=sel[1])
407 assert result is True, f"Incorrect return value {result} by `set_selection()` method"
408 _verify_selection(sel)
409
410
411# fmt: off

Callers

nothing calls this directly

Calls 6

set_value_typeMethod · 0.95
set_rangeMethod · 0.95
set_selectionMethod · 0.95
RangeManagerClass · 0.90
_verify_selectionFunction · 0.85
showMethod · 0.80

Tested by

no test coverage detected