@mock.patch.object(function, 'validate')
def test_validate_assertion_exception_rethrow(self, func_val):
    expected_msg = 'Expected Assertion Error'
    with mock.patch('heat.engine.stack.dependencies', new_callable=mock.PropertyMock) as mock_dependencies:
        mock_dependency = mock.MagicMock()
        mock_dependency.name = 'res'
        mock_dependency.external_id = None
        mock_dependency.validate.side_effect = AssertionError(expected_msg)
        mock_dependencies.Dependencies.return_value = [mock_dependency]
        stc = stack.Stack(self.ctx, utils.random_name(), self.tmpl)
        mock_res = mock.Mock()
        mock_res.name = mock_dependency.name
        mock_res.t = mock.Mock()
        mock_res.t.name = mock_res.name
        stc._resources = {mock_res.name: mock_res}
        expected_exception = self.assertRaises(AssertionError, stc.validate)
        self.assertEqual(expected_msg, str(expected_exception))
        mock_dependency.validate.assert_called_once_with()
    tmpl = template_format.parse("\n        HeatTemplateFormatVersion: '2012-12-12'\n        Outputs:\n          foo:\n            Value: bar\n        ")
    stc = stack.Stack(self.ctx, utils.random_name(), template.Template(tmpl))
    func_val.side_effect = AssertionError(expected_msg)
    expected_exception = self.assertRaises(AssertionError, stc.validate)
    self.assertEqual(expected_msg, str(expected_exception))
@mock.patch.object(function, 'validate')
def test_validate_assertion_exception_rethrow(self, func_val):
    expected_msg = 'Expected Assertion Error'
    with mock.patch('heat.engine.stack.dependencies', new_callable=mock.PropertyMock) as mock_dependencies:
        mock_dependency = mock.MagicMock()
        mock_dependency.name = 'res'
        mock_dependency.external_id = None
        mock_dependency.validate.side_effect = AssertionError(expected_msg)
        mock_dependencies.Dependencies.return_value = [mock_dependency]
        stc = stack.Stack(self.ctx, utils.random_name(), self.tmpl)
        mock_res = mock.Mock()
        mock_res.name = mock_dependency.name
        mock_res.t = mock.Mock()
        mock_res.t.name = mock_res.name
        stc._resources = {mock_res.name: mock_res}
        expected_exception = self.assertRaises(AssertionError, stc.validate)
        self.assertEqual(expected_msg, str(expected_exception))
        mock_dependency.validate.assert_called_once_with()
    tmpl = template_format.parse("\n        HeatTemplateFormatVersion: '2012-12-12'\n        Outputs:\n          foo:\n            Value: bar\n        ")
    stc = stack.Stack(self.ctx, utils.random_name(), template.Template(tmpl))
    func_val.side_effect = AssertionError(expected_msg)
    expected_exception = self.assertRaises(AssertionError, stc.validate)
    self.assertEqual(expected_msg, str(expected_exception))