def test_custom_kw_config_parse_fail(self): data = {"KEY_1": "Value Key_2"} with TestAreaContext("python/enkf/data/custom_kw_config_fail") as test_area: self.createResultFile("result_file", data) custom_kw_config = CustomKWConfig("CUSTOM_KW_FAIL", "result_file") self.assertIsNone(custom_kw_config.getOutputFile()) self.assertFalse(custom_kw_config.parseResultFile("result_file", StringList()))
def test_custom_kw_config_creation(self): data = {"VALUE_1": 2345.234, "VALUE_2": 0.001234, "VALUE_3": "string_1", "VALUE_4": "string_2"} with TestAreaContext("python/enkf/data/custom_kw_config") as test_area: self.createResultFile("result_file", data) custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file", "output_file") self.assertEqual(custom_kw_config.getName(), "CUSTOM_KW") self.assertEqual(custom_kw_config.getResultFile(), "result_file") self.assertEqual(custom_kw_config.getOutputFile(), "output_file") self.assertEqual(len(custom_kw_config), 0) result = StringList() success = custom_kw_config.parseResultFile("result_file", result) self.assertTrue(success) self.assertEqual(len(custom_kw_config), 4) for index, key in enumerate(data): self.assertTrue(key in custom_kw_config) key_is_string = isinstance(data[key], str) self.assertTrue(custom_kw_config.keyIsDouble(key) != key_is_string) self.assertEqual(index, custom_kw_config.indexOfKey(key)) self.assertEqual(result[index], str(data[key])) self.assertTrue(len(custom_kw_config.getKeys()) == 4) for key in custom_kw_config: self.assertTrue(key in data)