Skip to content

Commit

Permalink
add unit test for ConstQCheckBoxHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
backmari committed Nov 26, 2024
1 parent 08edcea commit b1c8ccb
Showing 1 changed file with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b1c8ccb

Please sign in to comment.