aboutsummaryrefslogtreecommitdiffstats
path: root/sfc/unit_tests/unit/lib/test_odl_utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'sfc/unit_tests/unit/lib/test_odl_utils.py')
-rw-r--r--sfc/unit_tests/unit/lib/test_odl_utils.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/sfc/unit_tests/unit/lib/test_odl_utils.py b/sfc/unit_tests/unit/lib/test_odl_utils.py
index 043c7bbe..1dfcf1ed 100644
--- a/sfc/unit_tests/unit/lib/test_odl_utils.py
+++ b/sfc/unit_tests/unit/lib/test_odl_utils.py
@@ -1,9 +1,9 @@
#!/usr/bin/env python
###############################################################################
-# Copyright (c) 2018 All rights reserved.
+# Copyright (c) 2018 Venkata Harshavardhan Reddy Allu and others.
#
-# This program and the accompanying materials
+# 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
@@ -331,11 +331,35 @@ class SfcOdlUtilsTesting(unittest.TestCase):
'/etc/ml2_conf.ini')
mock_rawconfigparser.return_value.read.assert_called_once_with(
'/etc/ml2_conf.ini')
- mock_rawconfigparser.return_value.get.assert_called_once_with(
+ mock_rawconfigparser.return_value.get.assert_called_with(
'ml2_odl', 'url')
mock_search.assert_called_once_with(r'[0-9]+(?:\.[0-9]+){3}\:[0-9]+',
'config')
+ @patch('re.search', autospec=True)
+ @patch('ConfigParser.RawConfigParser', autospec=True)
+ @patch('os.getcwd', autospec=True, return_value='/etc')
+ @patch('os.path.join', autospec=True, return_value='/etc/ml2_conf.ini')
+ def test_get_odl_username_password(self, mock_join,
+ mock_getcwd,
+ mock_rawconfigparser,
+ mock_search):
+ """
+ Check the proper functionality of get odl_username_password
+ function
+ """
+
+ mock_rawconfigparser.return_value.get.return_value = 'odl_username'
+ result = odl_utils.get_odl_username_password()
+ self.assertEqual(('odl_username'), result[0])
+ mock_getcwd.assert_called_once_with()
+ mock_join.assert_called_once_with('/etc', 'ml2_conf.ini')
+ mock_rawconfigparser.return_value.read.assert_called_once_with(
+ '/etc/ml2_conf.ini')
+ mock_rawconfigparser.return_value.get.return_value = 'odl_password'
+ result = odl_utils.get_odl_username_password()
+ self.assertEqual(('odl_password'), result[1])
+
def test_pluralize(self):
"""
Checks the proper functionality of pluralize