def test_create_failed_on_validation(self): tmpl = template_format.parse(template_by_name()) stack = utils.parse_stack(tmpl) props = tmpl['resources']['container']['properties'] props['secrets'].append({'name': 'secret3', 'ref': 'ref1'}) defn = rsrc_defn.ResourceDefinition( 'failed_container', 'OS::Barbican::GenericContainer', props) res = container.GenericContainer('foo', defn, stack) self.assertRaisesRegexp(exception.StackValidationFailed, 'Duplicate refs are not allowed', res.validate)
def test_check_create_complete(self): tmpl = template_format.parse(template_by_name()) stack = utils.parse_stack(tmpl) resource_defns = stack.t.resource_definitions(stack) res_template = resource_defns['container'] res = container.GenericContainer('foo', res_template, stack) mock_active = mock.Mock(status='ACTIVE') self.client.containers.get.return_value = mock_active self.assertTrue(res.check_create_complete('foo')) mock_not_active = mock.Mock(status='PENDING') self.client.containers.get.return_value = mock_not_active self.assertFalse(res.check_create_complete('foo')) mock_not_active = mock.Mock(status='ERROR', error_reason='foo', error_status_code=500) self.client.containers.get.return_value = mock_not_active exc = self.assertRaises(exception.ResourceInError, res.check_create_complete, 'foo') self.assertIn('foo', six.text_type(exc)) self.assertIn('500', six.text_type(exc))