From b1c8ccb09307e9a21033302605b4c11c4e138eb4 Mon Sep 17 00:00:00 2001 From: Marie Backman Date: Tue, 26 Nov 2024 14:01:44 -0500 Subject: [PATCH] add unit test for ConstQCheckBoxHandler --- .../test_const_q_checkbox_handler.py | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 test/unit/RefRed/reduction_table_handling/test_const_q_checkbox_handler.py diff --git a/test/unit/RefRed/reduction_table_handling/test_const_q_checkbox_handler.py b/test/unit/RefRed/reduction_table_handling/test_const_q_checkbox_handler.py new file mode 100644 index 00000000..f70d493a --- /dev/null +++ b/test/unit/RefRed/reduction_table_handling/test_const_q_checkbox_handler.py @@ -0,0 +1,37 @@ +from unittest import mock +from unittest.mock import Mock + +from RefRed.calculations.lr_data import LRData +from RefRed.lconfigdataset import LConfigDataset +from RefRed.reduction_table_handling.const_q_checkbox_handler import ConstQCheckBoxHandler +from qtpy.QtCore import Qt + +from RefRed.tabledata import TableData + + +def test_const_q_checkbox_handler(): + big_table_data = TableData(max_row_count=1) + row = 0 + + with mock.patch.object(LRData, '__init__', return_value=None): + instance = LRData() + big_table_data.set_reflectometry_data(row, instance) + big_table_data.set_normalization_data(row, instance) + big_table_data.set_reduction_config(row, LConfigDataset()) + + data = big_table_data.reflectometry_data(row) + norm = big_table_data.normalization_data(row) + config = big_table_data.reduction_config(row) + + parent = Mock() + parent.big_table_data = big_table_data + + ConstQCheckBoxHandler(parent, row, state=Qt.Checked) + assert data.const_q is True + assert norm.const_q is True + assert config.const_q is True + + ConstQCheckBoxHandler(parent, row, state=Qt.Unchecked) + assert data.const_q is False + assert norm.const_q is False + assert config.const_q is False