Skip to content
This repository has been archived by the owner on Jul 19, 2021. It is now read-only.

Commit

Permalink
Add key_manager test
Browse files Browse the repository at this point in the history
  • Loading branch information
ManInFez committed Feb 1, 2019
1 parent 67ee858 commit 3108972
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/tests/res/enkf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(TEST_SOURCES
test_data_kw_define.py
test_programmatic_res_config.py
test_rng_config.py
test_key_manager.py
)

add_python_package("python.tests.res.enkf" ${PYTHON_INSTALL_PREFIX}/tests/res/enkf "${TEST_SOURCES}" False)
Expand Down Expand Up @@ -109,6 +110,7 @@ python_config_test(tests.res.enkf.test_summary_key_set.SummaryKeySetTest)
python_config_test(tests.res.enkf.test_ecl_config.EclConfigTest)
python_config_test(tests.res.enkf.test_ert_context.ErtTestContextTest)
python_config_test(tests.res.enkf.test_field_export.FieldExportTest)
python_config_test(tests.res.enkf.test_key_manager.KeyManagerTest)

# The following two tests involve loading the rml module as part of
# the bootup process. That fails with a dlopen( ) error I just can
Expand Down
49 changes: 49 additions & 0 deletions python/tests/res/enkf/test_key_manager.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from res.enkf.key_manager import KeyManager
from res.test import ErtTestContext

from tests import ResTest

class KeyManagerTest(ResTest):
def setUp(self):
self.config_file = self.createTestPath("local/snake_oil/snake_oil.ert")

def test_summary_keys(self):
with ErtTestContext("enkf_key_manager_test", self.config_file) as testContext:
ert = testContext.getErt()
key_man = KeyManager(ert)

self.assertEqual( len(key_man.summaryKeys()), 47)
self.assertTrue("FOPT" in key_man.summaryKeys())

self.assertEqual(len(key_man.summaryKeysWithObservations()), 2)
self.assertTrue("FOPR" in key_man.summaryKeysWithObservations())
self.assertTrue(key_man.isKeyWithObservations("FOPR"))


def test_gen_data_keys(self):
with ErtTestContext("enkf_key_manager_test", self.config_file) as testContext:
ert = testContext.getErt()
key_man = KeyManager(ert)

self.assertEqual( len(key_man.genDataKeys()), 3)
self.assertTrue("SNAKE_OIL_WPR_DIFF@199" in key_man.genDataKeys())

self.assertEqual(len(key_man.genDataKeysWithObservations()), 1)
self.assertTrue("SNAKE_OIL_WPR_DIFF@199" in key_man.genDataKeysWithObservations())
self.assertTrue(key_man.isKeyWithObservations("SNAKE_OIL_WPR_DIFF@199"))

def test_custom_keys(self):
with ErtTestContext("enkf_key_manager_test", self.config_file) as testContext:
ert = testContext.getErt()
key_man = KeyManager(ert)

self.assertEqual( len(key_man.customKwKeys()), 2)
self.assertTrue("SNAKE_OIL_NPV:NPV" in key_man.customKwKeys())

def test_gen_kw_keys(self):
with ErtTestContext("enkf_key_manager_test", self.config_file) as testContext:
ert = testContext.getErt()
key_man = KeyManager(ert)

self.assertEqual(len(key_man.genKwKeys()), 10)
self.assertTrue("SNAKE_OIL_PARAM:BPR_555_PERSISTENCE" in key_man.genKwKeys())

0 comments on commit 3108972

Please sign in to comment.