mirror of
https://github.com/BOSWatch/BW3-Core.git
synced 2026-04-05 14:25:45 +00:00
edit config class and test
This commit is contained in:
parent
def65fe5a9
commit
e29628fb7c
2 changed files with 41 additions and 69 deletions
|
|
@ -26,44 +26,53 @@ class Test_Config:
|
|||
|
||||
def test_loadLocalConfig(self):
|
||||
"""!load a local config file"""
|
||||
bwConfig = Config(paths.TEST_PATH + "test.ini")
|
||||
bwConfig = Config()
|
||||
bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini")
|
||||
assert bwConfig._config is not None
|
||||
|
||||
def test_getLocalConfig(self):
|
||||
"""!get values from local config file"""
|
||||
bwConfig = Config(paths.TEST_PATH + "test.ini")
|
||||
bwConfig = Config()
|
||||
bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini")
|
||||
assert bwConfig.getConfig("test", "one") == "1"
|
||||
assert bwConfig.getConfig("test", "two") == "two"
|
||||
assert bwConfig.getConfig("testcase", "test") == "ok"
|
||||
|
||||
def test_getLocalConfigFailed(self):
|
||||
"""!fail while get values from local config file"""
|
||||
bwConfig = Config(paths.TEST_PATH + "test.ini")
|
||||
bwConfig = Config()
|
||||
bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini")
|
||||
assert bwConfig.getConfig("test", "abc") is None
|
||||
assert bwConfig.getConfig("abc", "test") is None
|
||||
|
||||
def test_shareConfig(self):
|
||||
"""!load local config file and share it"""
|
||||
bwConfig = Config(paths.TEST_PATH + "test.ini", "test_shareConfig")
|
||||
assert bwConfig._sharedConfig["test_shareConfig"] is not None
|
||||
bwConfig = Config()
|
||||
bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini", "test_shareConfig")
|
||||
assert bwConfig._sharePoints["test_shareConfig"] is not None
|
||||
|
||||
def test_shareConfigUsed(self):
|
||||
"""!load local config file and tr to share it twice with same name"""
|
||||
bwConfig1 = Config(paths.TEST_PATH + "test.ini", "test_shareConfigUsed")
|
||||
assert bwConfig1._sharedConfig["test_shareConfigUsed"] is not None
|
||||
bwConfig2 = Config(paths.TEST_PATH + "test.ini")
|
||||
bwConfig1 = Config()
|
||||
bwConfig1.loadConfigFile(paths.TEST_PATH + "test.ini", "test_shareConfigUsed")
|
||||
assert bwConfig1._sharePoints["test_shareConfigUsed"] is not None
|
||||
|
||||
bwConfig2 = Config()
|
||||
bwConfig2.loadConfigFile(paths.TEST_PATH + "test.ini")
|
||||
assert bwConfig2._shareConfig("test_shareConfigUsed") is False
|
||||
|
||||
def test_getNotSetSharedConfig(self):
|
||||
"""!try to get values from shared config where not exists"""
|
||||
bwConfig = Config(paths.TEST_PATH + "test.ini")
|
||||
bwConfig = Config()
|
||||
bwConfig.loadConfigFile(paths.TEST_PATH + "test.ini")
|
||||
assert bwConfig.getConfig("test", "one") == "1"
|
||||
assert bwConfig.getConfig("test", "one", "NotSetSharedConfig") is None
|
||||
|
||||
def test_getSharedConfig(self):
|
||||
"""!get values from shared config file"""
|
||||
bwConfig1 = Config(paths.TEST_PATH + "test.ini", "test_getSharedConfig")
|
||||
assert bwConfig1._sharedConfig["test_getSharedConfig"] is not None
|
||||
bwConfig1 = Config()
|
||||
bwConfig1.loadConfigFile(paths.TEST_PATH + "test.ini", "test_getSharedConfig")
|
||||
assert bwConfig1._sharePoints["test_getSharedConfig"] is not None
|
||||
|
||||
bwConfig2 = Config()
|
||||
assert bwConfig2.getConfig("test", "one") is None
|
||||
|
|
@ -71,8 +80,9 @@ class Test_Config:
|
|||
|
||||
def test_getSharedConfigFailed(self):
|
||||
"""!fail while get values from shared config file"""
|
||||
bwConfig1 = Config(paths.TEST_PATH + "test.ini", "test_getSharedConfigFailed")
|
||||
assert bwConfig1._sharedConfig["test_getSharedConfigFailed"] is not None
|
||||
bwConfig1 = Config()
|
||||
bwConfig1.loadConfigFile(paths.TEST_PATH + "test.ini", "test_getSharedConfigFailed")
|
||||
assert bwConfig1._sharePoints["test_getSharedConfigFailed"] is not None
|
||||
|
||||
bwConfig2 = Config()
|
||||
assert bwConfig2.getConfig("test", "abc", "test_getSharedConfigFailed") is None
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue