diff options
author | Benoit HERARD <benoit.herard@orange.com> | 2017-07-07 09:44:48 +0200 |
---|---|---|
committer | Benoit HERARD <benoit.herard@orange.com> | 2017-07-11 14:32:14 +0200 |
commit | 9138cc184b23cef2067605d6464e0acbd6bd105d (patch) | |
tree | 9baf065d28101644fb7554e60fe8ad03168a91e9 /functest/tests | |
parent | cf40eb1f837d73077168588097fd066287ff22e6 (diff) |
Add decorators in testcases for energy recording.
Test cases are:
- rally (sanity and full)
- refstack
- cloudify_ims
- vping_ssh
It also fix a bug on "energy_recording" decorator of energy module.
Change-Id: I625c214552ad1b89eaf7e196e706d7c69b37da33
Signed-off-by: Benoit HERARD <benoit.herard@orange.com>
Diffstat (limited to 'functest/tests')
-rw-r--r-- | functest/tests/unit/energy/test_functest_energy.py | 5 | ||||
-rw-r--r-- | functest/tests/unit/openstack/rally/test_rally.py | 12 |
2 files changed, 10 insertions, 7 deletions
diff --git a/functest/tests/unit/energy/test_functest_energy.py b/functest/tests/unit/energy/test_functest_energy.py index 177788bc..f8bb13c9 100644 --- a/functest/tests/unit/energy/test_functest_energy.py +++ b/functest/tests/unit/energy/test_functest_energy.py @@ -248,7 +248,9 @@ class EnergyRecorderTest(unittest.TestCase): self.__decorated_method() == self.returned_value_to_preserve ) - def test_decorator_preserve_ex(self): + @mock.patch( + "functest.energy.energy.finish_session") + def test_decorator_preserve_ex(self, finish_mock=None): """Test that decorator preserve method exceptions.""" self.test_load_config() with self.assertRaises(Exception) as context: @@ -256,6 +258,7 @@ class EnergyRecorderTest(unittest.TestCase): self.assertTrue( self.exception_message_to_preserve in context.exception ) + self.assertTrue(finish_mock.called) @mock.patch("functest.utils.functest_utils.get_functest_config", side_effect=config_loader_mock) diff --git a/functest/tests/unit/openstack/rally/test_rally.py b/functest/tests/unit/openstack/rally/test_rally.py index def9c93b..32cc1513 100644 --- a/functest/tests/unit/openstack/rally/test_rally.py +++ b/functest/tests/unit/openstack/rally/test_rally.py @@ -217,7 +217,7 @@ class OSRallyTesting(unittest.TestCase): self.assertRaises(Exception): self.rally_base._run_task('test_name') - @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.info') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.info') def test_run_task_no_tests_for_scenario(self, mock_logger_info): with mock.patch('functest.opnfv_tests.openstack.rally.rally.' 'os.path.exists', @@ -227,10 +227,10 @@ class OSRallyTesting(unittest.TestCase): mock.patch.object(self.rally_base, 'file_is_empty', return_value=True): self.rally_base._run_task('test_name') - str = 'No tests for scenario "test_name"' - mock_logger_info.assert_any_call(str) + mock_logger_info.assert_any_call('No tests for scenario \"%s\"', + 'test_name') - @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.error') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.error') def test_run_task_taskid_missing(self, mock_logger_error): with mock.patch('functest.opnfv_tests.openstack.rally.rally.' 'os.path.exists', @@ -253,8 +253,8 @@ class OSRallyTesting(unittest.TestCase): str = 'Failed to retrieve task_id, validating task...' mock_logger_error.assert_any_call(str) - @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.info') - @mock.patch('functest.opnfv_tests.openstack.rally.rally.logger.error') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.info') + @mock.patch('functest.opnfv_tests.openstack.rally.rally.LOGGER.error') def test_run_task_default(self, mock_logger_error, mock_logger_info): popen = mock.Mock() |