From 8f68da0a82be727430af6615dc41fe1377cbd1fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Eide?= Date: Fri, 5 Jul 2019 10:03:31 +0200 Subject: [PATCH] Make gen_kw test run by changing key order The order of the gen_kw keys have either changed or this test has never passed. The order is not clear, as the order in the test does not mirror the order in the config file. If the order matters this could be a bug. Changed the test to check that the correct keys were read, and refactored. --- .../enkf/data/test_gen_kw_config_equinor.py | 51 ++++++++----------- 1 file changed, 21 insertions(+), 30 deletions(-) diff --git a/python/tests/res/enkf/data/test_gen_kw_config_equinor.py b/python/tests/res/enkf/data/test_gen_kw_config_equinor.py index 4f1452d91b..193e80123a 100644 --- a/python/tests/res/enkf/data/test_gen_kw_config_equinor.py +++ b/python/tests/res/enkf/data/test_gen_kw_config_equinor.py @@ -18,43 +18,34 @@ def test_gen_kw_config(self): ert = context.getErt() - gen_kw_keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.GEN_KW) + result_gen_kw_keys = ert.ensembleConfig().getKeylistFromImplType(ErtImplType.GEN_KW) - self.assertEqual(gen_kw_keys[0], "GRID_PARAMS") + expected_keys = ["GRID_PARAMS", "FLUID_PARAMS", "MULTFLT"] - node = ert.ensembleConfig().getNode(gen_kw_keys[0]) - gen_kw_config = node.getModelConfig() - self.assertIsInstance(gen_kw_config, GenKwConfig) + self.assertItemsEqual(result_gen_kw_keys, expected_keys) + self.assertEqual(len(expected_keys), len(result_gen_kw_keys)) - self.assertEqual(gen_kw_config.getKey(), "GRID_PARAMS") - self.assertEqual(len(gen_kw_config), 2) + for key in expected_keys: + node = ert.ensembleConfig().getNode(key) + gen_kw_config = node.getModelConfig() + self.assertIsInstance(gen_kw_config, GenKwConfig) - self.assertEqual(gen_kw_config[0], "MULTPV2") - self.assertEqual(gen_kw_config[1], "MULTPV3") + self.assertEqual(gen_kw_config.getKey(), key) - self.assertFalse(gen_kw_config.shouldUseLogScale(0)) - self.assertFalse(gen_kw_config.shouldUseLogScale(1)) + if key == "GRID_PARAMS": + expected_values = ["MULTPV2", "MULTPV3"] + self.assertFalse(gen_kw_config.shouldUseLogScale(0)) + self.assertFalse(gen_kw_config.shouldUseLogScale(1)) - node = ert.ensembleConfig().getNode(gen_kw_keys[1]) - gen_kw_config = node.getModelConfig() - self.assertIsInstance(gen_kw_config, GenKwConfig) + elif key == "MULTFLT": + expected_values = ["F3"] - self.assertEqual(gen_kw_config.getKey(), "MULTFLT") + self.assertTrue(gen_kw_config.shouldUseLogScale(0)) - self.assertTrue(gen_kw_config.shouldUseLogScale(0)) + elif key == "FLUID_PARAMS": + expected_values = ["SWCR", "SGCR"] + self.assertFalse(gen_kw_config.shouldUseLogScale(0)) + self.assertFalse(gen_kw_config.shouldUseLogScale(1)) - - node = ert.ensembleConfig().getNode(gen_kw_keys[2]) - gen_kw_config = node.getModelConfig() - self.assertIsInstance(gen_kw_config, GenKwConfig) - - self.assertEqual(gen_kw_config.getKey(), "FLUID_PARAMS") - - self.assertFalse(gen_kw_config.shouldUseLogScale(0)) - self.assertFalse(gen_kw_config.shouldUseLogScale(1)) - - expected = ["SWCR", "SGCR"] - - for index, keyword in enumerate(gen_kw_config): - self.assertEqual(keyword, expected[index]) + self.assertEqual([value for value in gen_kw_config], expected_values) \ No newline at end of file