Skip to content
Snippets Groups Projects
Commit a7ff4a41 authored by Sebastian Lobinger's avatar Sebastian Lobinger
Browse files

enhance tests to reflect also issue #3

parent eda4b1a2
Branches
Tags
1 merge request!2Resolve "reload implementieren"
...@@ -3,7 +3,45 @@ import config_provider ...@@ -3,7 +3,45 @@ import config_provider
class TestConfigProvider(unittest.TestCase): class TestConfigProvider(unittest.TestCase):
def setUp(self):
self.dummy_config = {
'A': 'a',
'B': 'b'}
def read_dummy_conf(self, **kwargs):
conf_dict = dict(self.dummy_config, **kwargs)
return conf_dict
self.read_function = read_dummy_conf
self.config = config_provider.ConfigProvider(
load_function = {
'function': self.read_function, 'args': [self],
'kwargs': {'salt': 'pepper'}})
def test_init(self): def test_init(self):
config = config_provider.ConfigProvider( config = config_provider.ConfigProvider(
load_function = dict, foo = 'bar') load_function = {
self.assertEqual({'foo': 'bar'}, config.dict) 'function': self.read_function, 'args': [self],
\ No newline at end of file 'kwargs': {'foo': 'bar'}})
self.assertEqual({'foo': 'bar', 'A': 'a', 'B': 'b'}, config.dict)
def test_reload(self):
old_dict = dict(self.config.dict)
self.dummy_config = {'A': 'a1', 'B': 'b'}
expected_dict = {'A': 'a1', 'B': 'b', 'salt': 'pepper'}
with self.subTest(
'before Reload: self.config.dict = ' + str(self.config.dict)
+ ' old_dict = ' + str(old_dict) + ' self.dummy_config = '
+ str(self.dummy_config)):
self.assertEqual(
old_dict, self.config.dict, 'old_dict musst equal self.config.dict')
self.assertNotEqual(
self.dummy_config, self.config.dict,
'self.dummy_config musst not equal self.config.dict')
self.config.reload()
with self.subTest('after Reload: self.config.dict = ' + str(self.config.dict)
+ ' old_dict = ' + str(old_dict) + ' self.dummy_config = '
+ str(self.dummy_config)):
self.assertEqual(
expected_dict, self.config.dict,
'expected_dict musst equal self.config.dict')
self.assertNotEqual(
old_dict, self.config.dict, 'old_dict musst not equal self.config.dict')
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment