def test_add_missing(self): """Test add_missing_items""" entry1 = { "value": "8000", "section": "acquisition", "readableName": "Acquisition Port", "helpTip": "", "recommended_values": "", "type": "int" } entry2 = { "value": "LSL", "section": "acquisition", "readableName": "Acquisition Device", "helpTip": "", "recommended_values": ["LSL", "DSI"], "type": "str" } {"acq_port": entry1, "acq_device": entry2} parameters = Parameters(source=None) parameters.load({"acq_port": entry1}) new_params = Parameters(source=None) new_params.load({"acq_port": entry1, "acq_device": entry2}) self.assertFalse('acq_device' in parameters.keys()) self.assertTrue(parameters.add_missing_items(new_params)) self.assertTrue('acq_device' in parameters.keys()) self.assertFalse(parameters.add_missing_items(new_params), "Only new parameters should be added.")
def test_values(self): """Test values method""" sample_config = { "acq_port": { "value": "8000", "section": "acquisition", "readableName": "Acquisition Port", "helpTip": "", "recommended_values": "", "type": "int" }, "acq_device": { "value": "LSL", "section": "acquisition", "readableName": "Acquisition Device", "helpTip": "", "recommended_values": ["LSL", "DSI"], "type": "str" } } parameters = Parameters(source=None, cast_values=True) parameters.load(sample_config) self.assertEqual(list(parameters.keys()), ['acq_port', 'acq_device']) self.assertEqual(list(parameters.values()), [8000, 'LSL']) parameters.cast_values = False for value in parameters.values(): self.assertEqual(type(value), dict)