summaryrefslogtreecommitdiffstats
path: root/dovetail/tests/unit/utils/test_dovetail_config.py
diff options
context:
space:
mode:
authorStamatis Katsaounis <mokats@intracom-telecom.com>2018-11-08 16:58:09 +0200
committerDan Xu <xudan16@huawei.com>2018-11-14 14:31:50 +0000
commitc92c49a9031602030f0f4d4fe2f99a9054eabaee (patch)
treee6ca8b2bbb9d80d064dfeae1e91ac86d50dc318b /dovetail/tests/unit/utils/test_dovetail_config.py
parent930ebc4af5c9895775443b9a0ab17a73dc35693c (diff)
Add missing unit tests for utils files
JIRA: DOVETAIL-724 This patch adds unit tests which were missing from dovetail code base. Furthermore it updates the test_parser existing unit test. Finally, it fixes some minor issues in dovetail_utils itself. Change-Id: I8fd7cd4f6b1ede11664914746d2279f062511639 Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
Diffstat (limited to 'dovetail/tests/unit/utils/test_dovetail_config.py')
-rw-r--r--dovetail/tests/unit/utils/test_dovetail_config.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/dovetail/tests/unit/utils/test_dovetail_config.py b/dovetail/tests/unit/utils/test_dovetail_config.py
new file mode 100644
index 00000000..c7ac5b96
--- /dev/null
+++ b/dovetail/tests/unit/utils/test_dovetail_config.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2018 mokats@intracom-telecom.com and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##
+
+import unittest
+from mock import patch
+
+from dovetail.utils.dovetail_config import DovetailConfig
+
+__author__ = 'Stamatis Katsaounis <mokats@intracom-telecom.com>'
+
+
+class DovetailConfigTesting(unittest.TestCase):
+
+ def setUp(self):
+ pass
+
+ def tearDown(self):
+ pass
+
+ @patch.object(DovetailConfig, 'update_non_envs')
+ def test_update_config(self, mock_non_envs):
+ config_dict = {'key': {'path': ['aa / bb/ cc'], 'value': 'val'}}
+ dovetail_cfg = DovetailConfig()
+
+ dovetail_cfg.update_config(config_dict)
+
+ mock_non_envs.assert_called_once_with(['aa', 'bb', 'cc'], 'val')
+
+ def test_set_leaf_dict(self):
+ dict_to_test = {}
+ dovetail_cfg = DovetailConfig()
+
+ dovetail_cfg.set_leaf_dict(dict_to_test, ['aa', 'bb', 'cc'], 'val')
+
+ self.assertEquals({'aa': {'bb': {'cc': 'val'}}}, dict_to_test)
+
+ @patch.object(DovetailConfig, 'set_leaf_dict')
+ @patch.object(DovetailConfig, 'dovetail_config')
+ def test_update_non_envs(self, mock_cfg, mock_set_leaf):
+ path = ['aa', 'bb', 'cc']
+ value = 'val'
+ dovetail_cfg = DovetailConfig()
+
+ dovetail_cfg.update_non_envs(path, value)
+
+ mock_set_leaf.assert_called_once_with(mock_cfg, path, value)