def test_handle_delete_notfound(self): self._create_stack(self.template) deployment_id = 'c8a19429-7fde-47ea-a42f-40045488226c' self.deployment.resource_id = deployment_id self.mock_software_config() derived_sc = self.mock_derived_software_config() sd = self.mock_deployment() sd.config_id = derived_sc.id self.deployments.get.return_value = sd sd.delete.side_effect = HTTPNotFound() self.software_configs.delete.side_effect = HTTPNotFound() self.assertIsNone(self.deployment.handle_delete()) self.assertEqual((derived_sc.id, ), self.software_configs.delete.call_args[0])
def test_handle_delete(self): self.resource_id = None self.assertIsNone(self.config.handle_delete()) config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' self.config.resource_id = config_id self.software_configs.delete.return_value = None self.assertIsNone(self.config.handle_delete()) self.software_configs.delete.side_effect = HTTPNotFound() self.assertIsNone(self.config.handle_delete())
def test_resolve_attribute(self): self.assertIsNone(self.config._resolve_attribute('others')) self.config.resource_id = None self.assertIsNone(self.config._resolve_attribute('config')) self.config.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = mock.MagicMock() value.config = '#!/bin/bash' self.software_configs.get.return_value = value self.assertEqual('#!/bin/bash', self.config._resolve_attribute('config')) self.software_configs.get.side_effect = HTTPNotFound() self.assertEqual('', self.config._resolve_attribute('config'))
def test_resolve_attribute(self): self.assertIsNone(self.component._resolve_attribute('others')) self.component.resource_id = None self.assertIsNone(self.component._resolve_attribute('configs')) self.component.resource_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = mock.MagicMock() configs = self.\ template['resources']['mysql_component']['properties']['configs'] # configs list is stored in 'config' property of SoftwareConfig value.config = {'configs': configs} self.software_configs.get.return_value = value self.assertEqual(configs, self.component._resolve_attribute('configs')) self.software_configs.get.side_effect = HTTPNotFound() self.assertIsNone(self.component._resolve_attribute('configs'))
def test_get_software_config(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = mock.MagicMock() value.config = '#!/bin/bash' self.software_configs.get.return_value = value heatclient = self.heatclient config = sc.SoftwareConfig.get_software_config(heatclient, config_id) self.assertEqual('#!/bin/bash', config) self.software_configs.get.side_effect = HTTPNotFound() err = self.assertRaises(exception.SoftwareConfigMissing, self.config.get_software_config, heatclient, config_id) self.assertEqual(('The config (c8a19429-7fde-47ea-a42f-40045488226c) ' 'could not be found.'), str(err))
def test_stack_not_found(self): self.hclient.stacks.get.side_effect = HTTPNotFound('not found') self.assertEqual(None, self.inventory._get_stack())
def test_outputs_are_empty_if_stack_doesnt_exist(self): self.hclient.stacks.get.side_effect = HTTPNotFound('not found') stack_outputs = StackOutputs('no-plan', self.hclient) self.assertEqual(list(stack_outputs), [])