aboutsummaryrefslogtreecommitdiffstats
path: root/functest/tests/unit/ci/test_run_tests.py
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2018-01-29 07:37:37 +0000
committerLinda Wang <wangwulin@huawei.com>2018-02-01 14:38:16 +0000
commit1825aa713952288e4204ea3b38f0d3c0635a6918 (patch)
tree1f5174de93defbf8e703c73785eaaa118f4a940e /functest/tests/unit/ci/test_run_tests.py
parent416461c30d5a9a0df38e6c1bdef7061fce2c7eaf (diff)
Rename a common credential file for OS and K8S
Change-Id: Ib8d24be4b29ab1de00d5dd5e3442146b2437cb94 Signed-off-by: Linda Wang <wangwulin@huawei.com>
Diffstat (limited to 'functest/tests/unit/ci/test_run_tests.py')
-rw-r--r--functest/tests/unit/ci/test_run_tests.py34
1 files changed, 10 insertions, 24 deletions
diff --git a/functest/tests/unit/ci/test_run_tests.py b/functest/tests/unit/ci/test_run_tests.py
index 9f48891e..e5e4a056 100644
--- a/functest/tests/unit/ci/test_run_tests.py
+++ b/functest/tests/unit/ci/test_run_tests.py
@@ -54,22 +54,6 @@ class RunTestsTesting(unittest.TestCase):
self.run_tests_parser = run_tests.RunTestsParser()
- @mock.patch('functest.ci.run_tests.os.path.isfile', return_value=False)
- def test_source_rc_file_ko(self, *args):
- with self.assertRaises(Exception):
- self.runner.source_rc_file()
- args[0].assert_called_once_with(
- '/home/opnfv/functest/conf/openstack.creds')
-
- @mock.patch('functest.ci.run_tests.os.path.isfile',
- return_value=True)
- def test_source_rc_file_default(self, *args):
- with mock.patch('functest.ci.run_tests.os_utils.source_credentials',
- return_value=self.creds):
- self.runner.source_rc_file()
- args[0].assert_called_once_with(
- '/home/opnfv/functest/conf/openstack.creds')
-
@mock.patch('functest.ci.run_tests.ft_utils.get_dict_by_test')
def test_get_run_dict(self, *args):
retval = {'run': mock.Mock()}
@@ -163,7 +147,7 @@ class RunTestsTesting(unittest.TestCase):
self.runner.run_all()
self.assertTrue(mock_methods[1].called)
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file',
+ @mock.patch('functest.utils.openstack_utils.source_credentials',
side_effect=Exception)
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_main_failed(self, *mock_methods):
@@ -174,9 +158,10 @@ class RunTestsTesting(unittest.TestCase):
self.runner.tiers.configure_mock(**args)
self.assertEqual(self.runner.main(**kwargs),
run_tests.Result.EX_ERROR)
- mock_methods[1].assert_called_once_with()
+ mock_methods[1].assert_called_once_with(
+ '/home/opnfv/functest/conf/env_file')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_test',
return_value=TestCase.EX_OK)
@mock.patch('functest.ci.run_tests.Runner.summary')
@@ -196,7 +181,7 @@ class RunTestsTesting(unittest.TestCase):
run_tests.Result.EX_OK)
mock_methods[1].assert_called()
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_test',
return_value=TestCase.EX_OK)
def test_main_test(self, *mock_methods):
@@ -204,12 +189,13 @@ class RunTestsTesting(unittest.TestCase):
args = {'get_tier.return_value': None,
'get_test.return_value': 'test_name'}
self.runner.tiers = mock.Mock()
+ mock_methods[1].return_value = self.creds
self.runner.tiers.configure_mock(**args)
self.assertEqual(self.runner.main(**kwargs),
run_tests.Result.EX_OK)
mock_methods[0].assert_called_once_with('test_name')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
@mock.patch('functest.ci.run_tests.Runner.run_all')
@mock.patch('functest.ci.run_tests.Runner.summary')
def test_main_all_tier(self, *args):
@@ -222,9 +208,9 @@ class RunTestsTesting(unittest.TestCase):
run_tests.Result.EX_OK)
args[0].assert_called_once_with(None)
args[1].assert_called_once_with()
- args[2].assert_called_once_with()
+ args[2].assert_called_once_with('/home/opnfv/functest/conf/env_file')
- @mock.patch('functest.ci.run_tests.Runner.source_rc_file')
+ @mock.patch('functest.utils.openstack_utils.source_credentials')
def test_main_any_tier_test_ko(self, *args):
kwargs = {'get_tier.return_value': None,
'get_test.return_value': None}
@@ -233,7 +219,7 @@ class RunTestsTesting(unittest.TestCase):
self.assertEqual(
self.runner.main(test='any', noclean=True, report=True),
run_tests.Result.EX_ERROR)
- args[0].assert_called_once_with()
+ args[0].assert_called_once_with('/home/opnfv/functest/conf/env_file')
if __name__ == "__main__":