from heat.engine import parser
from heat.engine import parameters
from heat.engine import template
+
from heat.tests.utils import stack_delete_after
+from heat.tests import generic_resource as generic_rsrc
+
import heat.db as db_api
self.ctx.username = self.username
self.ctx.tenant_id = 'test_tenant'
+ resource._register_class('GenericResourceType',
+ generic_rsrc.GenericResource)
+
self.m.ReplayAll()
def tearDown(self):
def test_update_modify_ok_replace(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
updated_stack = parser.Stack(self.ctx, 'updated_stack',
template.Template(tmpl2))
# patch in a dummy handle_update
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
self.m.ReplayAll()
def test_update_modify_update_failed(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
template.Template(tmpl2))
# patch in a dummy handle_update
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_FAILED)
self.m.ReplayAll()
def test_update_modify_replace_failed_delete(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
template.Template(tmpl2))
# patch in a dummy handle_update
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
def test_update_modify_replace_failed_create(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
template.Template(tmpl2))
# patch in a dummy handle_update
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
# patch in a dummy handle_create making the replace fail creating
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
- resource.GenericResource.handle_create().AndRaise(Exception)
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
self.m.ReplayAll()
self.stack.update(updated_stack)
def test_update_rollback(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
# There will be two calls to handle_update, one for the new template
# then another (with the initial template) for rollback
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
# patch in a dummy handle_create making the replace fail when creating
# the replacement resource, but succeed the second call (rollback)
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
- resource.GenericResource.handle_create().AndRaise(Exception)
- resource.GenericResource.handle_create().AndReturn(None)
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
+ generic_rsrc.GenericResource.handle_create().AndReturn(None)
self.m.ReplayAll()
self.stack.update(updated_stack)
def test_update_rollback_fail(self):
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}}}}
# There will be two calls to handle_update, one for the new template
# then another (with the initial template) for rollback
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
# patch in a dummy handle_create making the replace fail when creating
# the replacement resource, and again on the second call (rollback)
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
- resource.GenericResource.handle_create().AndRaise(Exception)
- resource.GenericResource.handle_create().AndRaise(Exception)
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
self.m.ReplayAll()
self.stack.update(updated_stack)
# patch in a dummy handle_create making the replace fail when creating
# the replacement resource, and succeed on the second call (rollback)
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
- resource.GenericResource.handle_create().AndRaise(Exception)
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
self.m.ReplayAll()
self.stack.update(updated_stack)
'''
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {
'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}},
self.assertEqual(self.stack['BResource'].properties['Foo'],
'AResource')
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- resource.GenericResource.handle_update(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
br2_snip = {'Type': 'GenericResourceType',
'Properties': {'Foo': 'inst-007'}}
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
br2_snip).AndReturn(
resource.Resource.UPDATE_REPLACE)
- self.m.StubOutWithMock(resource.GenericResource, 'FnGetRefId')
- resource.GenericResource.FnGetRefId().AndReturn(
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'FnGetRefId')
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'AResource')
- resource.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
'inst-007')
self.m.ReplayAll()
'''
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {
'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}},
self.assertEqual(self.stack['BResource'].properties['Foo'],
'AResource')
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- self.m.StubOutWithMock(resource.GenericResource, 'FnGetRefId')
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'FnGetRefId')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
# mocks for first (failed update)
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'AResource')
# mock to make the replace fail when creating the replacement resource
- resource.GenericResource.handle_create().AndRaise(Exception)
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
# mocks for second rollback update
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
- resource.GenericResource.handle_create().AndReturn(None)
- resource.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
+ generic_rsrc.GenericResource.handle_create().AndReturn(None)
+ generic_rsrc.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
'AResource')
self.m.ReplayAll()
'''
# patch in a dummy property schema for GenericResource
dummy_schema = {'Foo': {'Type': 'String'}}
- resource.GenericResource.properties_schema = dummy_schema
+ generic_rsrc.GenericResource.properties_schema = dummy_schema
tmpl = {'Resources': {
'AResource': {'Type': 'GenericResourceType',
'Properties': {'Foo': 'abc'}},
self.assertEqual(self.stack['BResource'].properties['Foo'],
'AResource')
- self.m.StubOutWithMock(resource.GenericResource, 'handle_update')
- self.m.StubOutWithMock(resource.GenericResource, 'FnGetRefId')
- self.m.StubOutWithMock(resource.GenericResource, 'handle_create')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_update')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'FnGetRefId')
+ self.m.StubOutWithMock(generic_rsrc.GenericResource, 'handle_create')
# mocks for first and second (failed update)
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl2['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
br2_snip = {'Type': 'GenericResourceType',
'Properties': {'Foo': 'inst-007'}}
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
br2_snip).AndReturn(
resource.Resource.UPDATE_REPLACE)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'AResource')
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.state_set(self.UPDATE_IN_PROGRESS)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.state_set(self.DELETE_IN_PROGRESS)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.state_set(self.DELETE_COMPLETE)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.properties.validate()
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.state_set(self.CREATE_IN_PROGRESS)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# mock to make the replace fail when creating the second
# replacement resource
- resource.GenericResource.handle_create().AndReturn(None)
- resource.GenericResource.handle_create().AndRaise(Exception)
+ generic_rsrc.GenericResource.handle_create().AndReturn(None)
+ generic_rsrc.GenericResource.handle_create().AndRaise(Exception)
# mocks for second rollback update
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
tmpl['Resources']['AResource']).AndReturn(
resource.Resource.UPDATE_REPLACE)
br2_snip = {'Type': 'GenericResourceType',
'Properties': {'Foo': 'AResource'}}
- resource.GenericResource.handle_update(
+ generic_rsrc.GenericResource.handle_update(
br2_snip).AndReturn(
resource.Resource.UPDATE_REPLACE)
# self.state_set(self.DELETE_IN_PROGRESS)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
# self.state_set(self.DELETE_IN_PROGRESS)
- resource.GenericResource.FnGetRefId().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().AndReturn(
'inst-007')
- resource.GenericResource.handle_create().AndReturn(None)
- resource.GenericResource.handle_create().AndReturn(None)
+ generic_rsrc.GenericResource.handle_create().AndReturn(None)
+ generic_rsrc.GenericResource.handle_create().AndReturn(None)
# reverting to AResource
- resource.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
+ generic_rsrc.GenericResource.FnGetRefId().MultipleTimes().AndReturn(
'AResource')
self.m.ReplayAll()
import mox
from heat.common import context
+from heat.common import exception
from heat.engine import parser
from heat.engine import resource
from heat.openstack.common import uuidutils
+from heat.tests import generic_resource as generic_rsrc
+
@attr(tag=['unit', 'resource'])
@attr(speed='fast')
class ResourceTest(unittest.TestCase):
def setUp(self):
+ self.m = mox.Mox()
self.stack = parser.Stack(None, 'test_stack', parser.Template({}),
stack_id=uuidutils.generate_uuid())
+ resource._register_class('GenericResourceType',
+ generic_rsrc.GenericResource)
+
+ def tearDown(self):
+ self.m.UnsetStubs()
+
+ def test_get_class_ok(self):
+ cls = resource.get_class('GenericResourceType')
+ self.assertEqual(cls, generic_rsrc.GenericResource)
+
+ def test_get_class_noexist(self):
+ self.assertRaises(exception.StackValidationFailed, resource.get_class,
+ 'NoExistResourceType')
+
+ def test_resource_new_ok(self):
+ snippet = {'Type': 'GenericResourceType'}
+ res = resource.Resource('aresource', snippet, self.stack)
+
+ def test_resource_new_err(self):
+ snippet = {'Type': 'NoExistResourceType'}
+ self.assertRaises(exception.StackValidationFailed,
+ resource.Resource, 'aresource', snippet, self.stack)
+
def test_state_defaults(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_res_def', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_res_def', tmpl, self.stack)
self.assertEqual(res.state, None)
self.assertEqual(res.state_description, '')
def test_state(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.state_set('bar')
self.assertEqual(res.state, 'bar')
def test_state_description(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.state_set('blarg', 'wibble')
self.assertEqual(res.state_description, 'wibble')
def test_type(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertEqual(res.type(), 'Foo')
def test_created_time(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_res_new', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_res_new', tmpl, self.stack)
self.assertEqual(res.created_time, None)
res._store()
self.assertNotEqual(res.created_time, None)
def test_updated_time(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_res_upd', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_res_upd', tmpl, self.stack)
res._store()
stored_time = res.updated_time
res.state_set(res.CREATE_IN_PROGRESS, 'testing')
'Type': 'Foo',
'foo': {'Fn::Join': [' ', ['bar', 'baz', 'quux']]}
}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
parsed_tmpl = res.parsed_template()
self.assertEqual(parsed_tmpl['Type'], 'Foo')
def test_parsed_template_default(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertEqual(res.parsed_template('foo'), {})
self.assertEqual(res.parsed_template('foo', 'bar'), 'bar')
def test_metadata_default(self):
tmpl = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertEqual(res.metadata, {})
def test_equals_different_stacks(self):
tmpl3 = {'Type': 'Bar'}
stack2 = parser.Stack(None, 'test_stack', parser.Template({}),
stack_id=-1)
- res1 = resource.GenericResource('test_resource', tmpl1, self.stack)
- res2 = resource.GenericResource('test_resource', tmpl2, stack2)
- res3 = resource.GenericResource('test_resource2', tmpl3, stack2)
+ res1 = generic_rsrc.GenericResource('test_resource', tmpl1, self.stack)
+ res2 = generic_rsrc.GenericResource('test_resource', tmpl2, stack2)
+ res3 = generic_rsrc.GenericResource('test_resource2', tmpl3, stack2)
self.assertEqual(res1, res2)
self.assertNotEqual(res1, res3)
def test_equals_names(self):
tmpl1 = {'Type': 'Foo'}
tmpl2 = {'Type': 'Foo'}
- res1 = resource.GenericResource('test_resource1', tmpl1, self.stack)
- res2 = resource.GenericResource('test_resource2', tmpl2, self.stack)
+ res1 = generic_rsrc.GenericResource('test_resource1',
+ tmpl1, self.stack)
+ res2 = generic_rsrc.GenericResource('test_resource2', tmpl2,
+ self.stack)
self.assertNotEqual(res1, res2)
def test_update_template_diff_empty(self):
tmpl = {'Type': 'Foo'}
update_snippet = {}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertRaises(NotImplementedError, res.update_template_diff,
update_snippet)
def test_update_template_diff_changed_notallowed(self):
tmpl = {'Type': 'Foo'}
update_snippet = {'Type': 'Bar'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
self.assertRaises(NotImplementedError, res.update_template_diff,
update_snippet)
def test_update_template_diff_changed_modified(self):
tmpl = {'Type': 'Foo', 'Metadata': {'foo': 123}}
update_snippet = {'Type': 'Foo', 'Metadata': {'foo': 456}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_keys = ('Metadata',)
diff = res.update_template_diff(json_snippet=update_snippet)
self.assertEqual(diff, {'Metadata': {'foo': 456}})
def test_update_template_diff_changed_add(self):
tmpl = {'Type': 'Foo'}
update_snippet = {'Type': 'Foo', 'Metadata': {'foo': 123}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_keys = ('Metadata',)
diff = res.update_template_diff(json_snippet=update_snippet)
self.assertEqual(diff, {'Metadata': {'foo': 123}})
def test_update_template_diff_changed_remove(self):
tmpl = {'Type': 'Foo', 'Metadata': {'foo': 123}}
update_snippet = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_keys = ('Metadata',)
diff = res.update_template_diff(json_snippet=update_snippet)
self.assertEqual(diff, {'Metadata': None})
def test_update_template_diff_properties_none(self):
tmpl = {'Type': 'Foo'}
update_snippet = {'Type': 'Foo'}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
diff = res.update_template_diff_properties(json_snippet=update_snippet)
self.assertEqual(diff, {})
def test_update_template_diff_properties_added(self):
tmpl = {'Type': 'Foo'}
update_snippet = {'Type': 'Foo', 'Properties': {'Bar': 123}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_properties = ('Bar',)
diff = res.update_template_diff_properties(json_snippet=update_snippet)
self.assertEqual(diff, {'Bar': 123})
def test_update_template_diff_properties_removed(self):
tmpl = {'Type': 'Foo', 'Properties': {'Bar': 123}}
update_snippet = {'Type': 'Foo', 'Properties': {}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_properties = ('Bar',)
diff = res.update_template_diff_properties(json_snippet=update_snippet)
self.assertEqual(diff, {'Bar': None})
def test_update_template_diff_properties_changed(self):
tmpl = {'Type': 'Foo', 'Properties': {'Bar': 123}}
update_snippet = {'Type': 'Foo', 'Properties': {'Bar': 456}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_properties = ('Bar',)
diff = res.update_template_diff_properties(json_snippet=update_snippet)
self.assertEqual(diff, {'Bar': 456})
def test_update_template_diff_properties_notallowed(self):
tmpl = {'Type': 'Foo', 'Properties': {'Bar': 123}}
update_snippet = {'Type': 'Foo', 'Properties': {'Bar': 456}}
- res = resource.GenericResource('test_resource', tmpl, self.stack)
+ res = generic_rsrc.GenericResource('test_resource', tmpl, self.stack)
res.update_allowed_properties = ('Cat',)
self.assertRaises(NotImplementedError,
res.update_template_diff_properties,
ctx.username = 'metadata_test_user'
self.stack = parser.Stack(ctx, 'test_stack', parser.Template({}))
self.stack.store()
- self.res = resource.GenericResource('metadata_resource',
- tmpl, self.stack)
+ self.res = generic_rsrc.GenericResource('metadata_resource',
+ tmpl, self.stack)
self.res.create()
def tearDown(self):