def test_custom_kw_config_data_is_null(self): data_1 = {"VALUE_1": 123453.3, "VALUE_2": 0.234234} data_2 = {"VALUE_1": 965689, "VALUE_3": 1.1222} with TestAreaContext("python/enkf/data/custom_kw_null_element") as test_area: self.createResultFile("result_file_1", data_1) self.createResultFile("result_file_2", data_2) custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") custom_kw_1 = CustomKW(custom_kw_config) custom_kw_1.fload("result_file_1") custom_kw_2 = CustomKW(custom_kw_config) custom_kw_2.fload("result_file_2") index_1 = custom_kw_config.indexOfKey("VALUE_1") index_2 = custom_kw_config.indexOfKey("VALUE_2") self.assertEqual(custom_kw_1["VALUE_1"], data_1["VALUE_1"]) self.assertEqual(custom_kw_2["VALUE_1"], data_2["VALUE_1"]) self.assertIsNone(custom_kw_2["VALUE_2"]) self.assertFalse( "VALUE_3" in custom_kw_config )
def test_custom_kw_config_data_is_null(self): data_1 = {"VALUE_1": 123453.3, "VALUE_2": 0.234234} data_2 = {"VALUE_1": 965689, "VALUE_3": 1.1222} with TestAreaContext( "python/enkf/data/custom_kw_null_element") as test_area: self.createResultFile("result_file_1", data_1) self.createResultFile("result_file_2", data_2) custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") custom_kw_1 = CustomKW(custom_kw_config) custom_kw_1.fload("result_file_1") custom_kw_2 = CustomKW(custom_kw_config) custom_kw_2.fload("result_file_2") index_1 = custom_kw_config.indexOfKey("VALUE_1") index_2 = custom_kw_config.indexOfKey("VALUE_2") self.assertEqual(custom_kw_1["VALUE_1"], data_1["VALUE_1"]) self.assertEqual(custom_kw_2["VALUE_1"], data_2["VALUE_1"]) self.assertIsNone(custom_kw_2["VALUE_2"]) self.assertFalse("VALUE_3" in custom_kw_config)
def test_custom_kw_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_creation") as test_area: self.createResultFile("result_file", data) custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") self.assertEqual(len(custom_kw_config), 0) custom_kw = CustomKW(custom_kw_config) custom_kw.fload("result_file") self.assertEqual(len(custom_kw_config), 4) for key in data: index = custom_kw_config.indexOfKey(key) self.assertEqual(data[key], custom_kw[key]) with self.assertRaises(KeyError): value = custom_kw["VALUE_5"]
def test_custom_kw_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_creation") as test_area: self.createResultFile("result_file", data) custom_kw_config = CustomKWConfig("CUSTOM_KW", "result_file") self.assertEqual(len(custom_kw_config), 0) custom_kw = CustomKW(custom_kw_config) custom_kw.fload("result_file") self.assertEqual(len(custom_kw_config), 4) for key in data: index = custom_kw_config.indexOfKey(key) self.assertEqual(data[key], custom_kw[key]) with self.assertRaises(KeyError): value = custom_kw["VALUE_5"]