X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=yardstick%2FvTC%2Fapexlake%2Ftests%2Fdeployment_unit_test.py;h=1ff4225d6967a6ccef51d65d4b8ee5b0cdbad5a6;hb=77ac1aa890964b40aaf12b43301d37575ae753d3;hp=4c701024ed14838351a410b13b06f7e0ba275829;hpb=dd7873b8bec5c3853aa0021eb452d1d6f3be0dc5;p=yardstick.git diff --git a/yardstick/vTC/apexlake/tests/deployment_unit_test.py b/yardstick/vTC/apexlake/tests/deployment_unit_test.py index 4c701024e..1ff4225d6 100644 --- a/yardstick/vTC/apexlake/tests/deployment_unit_test.py +++ b/yardstick/vTC/apexlake/tests/deployment_unit_test.py @@ -12,12 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -__author__ = 'vmriccox' - - +from __future__ import absolute_import import unittest +import logging import mock import experimental_framework.deployment_unit as mut +import experimental_framework.common as common + +__author__ = 'vmriccox' class DummyHeatManager: @@ -128,6 +130,7 @@ class DummyDeploymentUnit(mut.DeploymentUnit): raise Exception +@mock.patch("experimental_framework.deployment_unit.time") class TestDeploymentUnit(unittest.TestCase): def setUp(self): @@ -138,7 +141,7 @@ class TestDeploymentUnit(unittest.TestCase): @mock.patch('experimental_framework.heat_manager.HeatManager', side_effect=DummyHeatManager) - def test_constructor_for_sanity(self, mock_heat_manager): + def test_constructor_for_sanity(self, mock_heat_manager, mock_time): du = mut.DeploymentUnit(dict()) self.assertTrue(isinstance(du.heat_manager, DummyHeatManager)) mock_heat_manager.assert_called_once_with(dict()) @@ -148,7 +151,7 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManager) @mock.patch('os.path.isfile') def test_deploy_heat_template_for_failure(self, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_time): mock_os_is_file.return_value = False du = mut.DeploymentUnit(dict()) template_file = '' @@ -161,12 +164,13 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManager) @mock.patch('os.path.isfile') def test_deploy_heat_template_for_success(self, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_time): mock_os_is_file.return_value = True du = mut.DeploymentUnit(dict()) template_file = '' stack_name = '' parameters = '' + common.LOG = logging.getLogger() output = du.deploy_heat_template(template_file, stack_name, parameters, 0) self.assertEqual(output, True) @@ -175,12 +179,13 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManagerComplete) @mock.patch('os.path.isfile') def test_deploy_heat_template_2_for_success(self, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_time): mock_os_is_file.return_value = True du = mut.DeploymentUnit(dict()) template_file = '' stack_name = '' parameters = '' + common.LOG = logging.getLogger() output = du.deploy_heat_template(template_file, stack_name, parameters, 0) self.assertEqual(output, True) @@ -192,21 +197,23 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyDeploymentUnit) def test_deploy_heat_template_3_for_success(self, mock_dep_unit, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_time): mock_os_is_file.return_value = True du = mut.DeploymentUnit(dict()) template_file = '' stack_name = '' parameters = '' + common.LOG = logging.getLogger() output = du.deploy_heat_template(template_file, stack_name, parameters, 0) self.assertEqual(output, True) + @mock.patch('experimental_framework.common.LOG') @mock.patch('experimental_framework.heat_manager.HeatManager', side_effect=DummyHeatManagerFailed) @mock.patch('os.path.isfile') def test_deploy_heat_template_for_success_2(self, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_log, mock_time): mock_os_is_file.return_value = True du = DummyDeploymentUnit(dict()) template_file = '' @@ -220,7 +227,7 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManagerDestroy) @mock.patch('experimental_framework.common.LOG') def test_destroy_heat_template_for_success(self, mock_log, - mock_heat_manager): + mock_heat_manager, mock_time): openstack_credentials = dict() du = mut.DeploymentUnit(openstack_credentials) du.deployed_stacks = ['stack'] @@ -232,14 +239,14 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManagerDestroyException) @mock.patch('experimental_framework.common.LOG') def test_destroy_heat_template_for_success_2(self, mock_log, - mock_heat_manager): + mock_heat_manager, mock_time): openstack_credentials = dict() du = mut.DeploymentUnit(openstack_credentials) du.deployed_stacks = ['stack'] stack_name = 'stack' self.assertFalse(du.destroy_heat_template(stack_name)) - def test_destroy_all_deployed_stacks_for_success(self): + def test_destroy_all_deployed_stacks_for_success(self, mock_time): du = DeploymentUnitDestroy() du.destroy_all_deployed_stacks() self.assertTrue(du.destroy_heat_template()) @@ -248,7 +255,7 @@ class TestDeploymentUnit(unittest.TestCase): side_effect=DummyHeatManagerReiteration) @mock.patch('os.path.isfile') def test_deploy_heat_template_for_success_3(self, mock_os_is_file, - mock_heat_manager): + mock_heat_manager, mock_time): mock_os_is_file.return_value = True du = mut.DeploymentUnit(dict()) template = 'template_reiteration'