def test_create_fail_missing_req_prop(self): tmpl = {'Type': 'GenericResourceType', 'Properties': {}} rname = 'test_resource' res = generic_rsrc.ResourceWithRequiredProps(rname, tmpl, self.stack) estr = 'Property error : test_resource: Property Foo not assigned' create = scheduler.TaskRunner(res.create) self.assertRaises(exception.ResourceFailure, create) self.assertEqual((res.CREATE, res.FAILED), res.state)
def test_badprop(self): rname = 'bad_resource' defn = rsrc_defn.ResourceDefinition(rname, 'ResourceWithRequiredProps', {'IntFoo': False}) res = generic_rsrc.ResourceWithRequiredProps(rname, defn, self.stack) e = event.Event(self.ctx, self.stack, 'TEST', 'IN_PROGRESS', 'Testing', 'wibble', res.properties, res.name, res.type()) self.assertIn('Error', e.resource_properties)
def test_badprop(self): tmpl = { 'Type': 'ResourceWithRequiredProps', 'Properties': { 'Foo': False } } rname = 'bad_resource' res = generic_rsrc.ResourceWithRequiredProps(rname, tmpl, self.stack) e = event.Event(self.ctx, self.stack, 'TEST', 'IN_PROGRESS', 'Testing', 'wibble', res.properties, res.name, res.type()) self.assertTrue('Error' in e.resource_properties)
def test_update_fail_missing_req_prop(self): tmpl = {'Type': 'GenericResourceType', 'Properties': {'Foo': 'abc'}} res = generic_rsrc.ResourceWithRequiredProps('test_resource', tmpl, self.stack) res.update_allowed_keys = ('Properties', ) res.update_allowed_properties = ('Foo', ) scheduler.TaskRunner(res.create)() self.assertEqual((res.CREATE, res.COMPLETE), res.state) utmpl = {'Type': 'GenericResourceType', 'Properties': {}} self.assertRaises(exception.ResourceFailure, res.update, utmpl) self.assertEqual((res.UPDATE, res.FAILED), res.state)