From 9138cc184b23cef2067605d6464e0acbd6bd105d Mon Sep 17 00:00:00 2001 From: Benoit HERARD Date: Fri, 7 Jul 2017 09:44:48 +0200 Subject: 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 --- functest/tests/unit/energy/test_functest_energy.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'functest/tests/unit/energy/test_functest_energy.py') 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) -- cgit 1.2.3-korg