def test_init(self): """Test init.""" options = OrderedDict([ (DO_NOT_USE, { 'label': 'Do not use', 'value': None, 'type': STATIC, 'constraint': {} }), (GLOBAL_DEFAULT, { 'label': 'Global default', 'value': 0.5, 'type': STATIC, 'constraint': {} }), (CUSTOM_VALUE, { 'label': 'Custom', 'value': 0.7, # Taken from keywords / recent value 'type': SINGLE_DYNAMIC, 'constraint': { 'min': 0, 'max': 1 } }), (FIELDS, { 'label': 'Ratio fields', 'value': ['field A', 'field B', 'field C'], # Taken from keywords 'type': MULTIPLE_DYNAMIC, 'constraint': {} }) ]) parameter = GroupSelectParameter() parameter.options = options parameter.selected = FIELDS self.widget = GroupSelectParameterWidget(parameter) self.widget.select_radio_button(CUSTOM_VALUE) self.assertEqual(self.widget.get_parameter().value, 0.7) self.assertEqual( self.widget.get_parameter().selected_option_type(), SINGLE_DYNAMIC) self.widget.spin_boxes[CUSTOM_VALUE].setValue(0.6) self.assertEqual(self.widget.get_parameter().value, 0.6) self.assertEqual( self.widget.get_parameter().selected_option_type(), SINGLE_DYNAMIC) self.widget.select_radio_button(GLOBAL_DEFAULT) self.assertEqual(self.widget.get_parameter().value, 0.5) self.assertEqual( self.widget.get_parameter().selected_option_type(), STATIC) self.widget.select_radio_button(DO_NOT_USE) self.assertEqual(self.widget.get_parameter().value, None) self.assertEqual( self.widget.get_parameter().selected_option_type(), STATIC) self.widget.select_radio_button(FIELDS) self.assertListEqual( self.widget.get_parameter().value, ['field A', 'field B', 'field C']) self.assertEqual( self.widget.get_parameter().selected_option_type(), MULTIPLE_DYNAMIC)
def test_init(self): """Test init.""" options = OrderedDict([ (DO_NOT_REPORT, { 'label': 'Do not report', 'value': None, 'type': STATIC, 'constraint': {} }), (GLOBAL_DEFAULT, { 'label': 'Global default', 'value': 0.5, 'type': STATIC, 'constraint': {} }), ( CUSTOM_VALUE, { 'label': 'Custom', 'value': 0.7, # Taken from keywords / recent value 'type': SINGLE_DYNAMIC, 'constraint': { 'min': 0, 'max': 1 } }), ( FIELDS, { 'label': 'Ratio fields', 'value': ['field A', 'field B', 'field C'], # Taken from keywords 'type': MULTIPLE_DYNAMIC, 'constraint': {} }) ]) parameter = GroupSelectParameter() parameter.options = options parameter.selected = FIELDS self.widget = GroupSelectParameterWidget(parameter) self.widget.select_radio_button(CUSTOM_VALUE) self.assertEqual(self.widget.get_parameter().value, 0.7) self.assertEqual(self.widget.get_parameter().selected_option_type(), SINGLE_DYNAMIC) self.widget.spin_boxes[CUSTOM_VALUE].setValue(0.6) self.assertEqual(self.widget.get_parameter().value, 0.6) self.assertEqual(self.widget.get_parameter().selected_option_type(), SINGLE_DYNAMIC) self.widget.select_radio_button(GLOBAL_DEFAULT) self.assertEqual(self.widget.get_parameter().value, 0.5) self.assertEqual(self.widget.get_parameter().selected_option_type(), STATIC) self.widget.select_radio_button(DO_NOT_REPORT) self.assertEqual(self.widget.get_parameter().value, None) self.assertEqual(self.widget.get_parameter().selected_option_type(), STATIC) self.widget.select_radio_button(FIELDS) self.assertListEqual(self.widget.get_parameter().value, ['field A', 'field B', 'field C']) self.assertEqual(self.widget.get_parameter().selected_option_type(), MULTIPLE_DYNAMIC)