From 9e0aa779aed95944e7d8a28be8bae282774e2614 Mon Sep 17 00:00:00 2001 From: Bastian Schroll Date: Wed, 10 Jan 2018 22:22:06 +0100 Subject: [PATCH] edit test_config.py to run with new config methods --- boswatch/config.py | 4 ++-- test/test_config.py | 23 ++++++++++++----------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/boswatch/config.py b/boswatch/config.py index 1245eca..1fb2673 100644 --- a/boswatch/config.py +++ b/boswatch/config.py @@ -66,9 +66,9 @@ class Config: @param key: Value to read @param sharePoint: Name of the global config share (empty is only local) @return The value or None""" - value = int(self._get(section, key, sharePoint)) + value = self._get(section, key, sharePoint) if value is None: - return 0 + return int(0) return int(value) def getBool(self, section, key, sharePoint=""): diff --git a/test/test_config.py b/test/test_config.py index 0e3bfa4..967270e 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -34,16 +34,17 @@ class Test_Config: """!get values from local config file""" bwConfig = Config() bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini") - assert bwConfig.get("test", "one") == "1" - assert bwConfig.get("test", "two") == "two" - assert bwConfig.get("testcase", "test") == "ok" + assert bwConfig.getInt("test", "one") == 1 + assert bwConfig.getBool("test", "one") is True + assert bwConfig.getStr("test", "two") == "two" + assert bwConfig.getStr("testcase", "test") == "ok" def test_getLocalConfigFailed(self): """!fail while get values from local config file""" bwConfig = Config() bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini") - assert bwConfig.get("test", "abc") is None - assert bwConfig.get("abc", "test") is None + assert bwConfig.getStr("test", "abc") == "None" + assert bwConfig.getStr("abc", "test") == "None" def test_shareConfig(self): """!load local config file and share it""" @@ -65,8 +66,8 @@ class Test_Config: """!try to get values from shared config where not exists""" bwConfig = Config() bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini") - assert bwConfig.get("test", "one") == "1" - assert bwConfig.get("test", "one", "NotSetSharedConfig") is None + assert bwConfig.getInt("test", "one") == 1 + assert bwConfig.getInt("test", "one", "NotSetSharedConfig") == 0 def test_getSharedConfig(self): """!get values from shared config file""" @@ -75,8 +76,8 @@ class Test_Config: assert bwConfig1._sharePoints["test_getSharedConfig"] is not None bwConfig2 = Config() - assert bwConfig2.get("test", "one") is None - assert bwConfig2.get("test", "one", "test_getSharedConfig") == "1" + assert bwConfig2.getStr("test", "one") == "None" + assert bwConfig2.getInt("test", "one", "test_getSharedConfig") == 1 def test_getSharedConfigFailed(self): """!fail while get values from shared config file""" @@ -85,5 +86,5 @@ class Test_Config: assert bwConfig1._sharePoints["test_getSharedConfigFailed"] is not None bwConfig2 = Config() - assert bwConfig2.get("test", "abc", "test_getSharedConfigFailed") is None - assert bwConfig2.get("abc", "test", "test_getSharedConfigFailed") is None + assert bwConfig2.getStr("test", "abc", "test_getSharedConfigFailed") == "None" + assert bwConfig2.getStr("abc", "test", "test_getSharedConfigFailed") == "None"