Unit tests: add a test resource that takes multiple steps
All of the current test resource types complete in a single step (i.e. have no check_*_complete() methods). In order to test longer-running resources, add a resource type in which the number of steps can be specified as a property. Change-Id: Ia894efa3207130a187032f2f667c096dee883aea
This commit is contained in:
parent
ecdaa8e183
commit
0951799e70
|
@ -141,6 +141,8 @@ class HeatTestCase(testscenarios.WithScenarios,
|
|||
def register_test_resources(self):
|
||||
resource._register_class('GenericResourceType',
|
||||
generic_rsrc.GenericResource)
|
||||
resource._register_class('MultiStepResourceType',
|
||||
generic_rsrc.MultiStepResource)
|
||||
resource._register_class('ResWithShowAttrType',
|
||||
generic_rsrc.ResWithShowAttr)
|
||||
resource._register_class('SignalResourceType',
|
||||
|
|
|
@ -78,6 +78,43 @@ class CancellableResource(GenericResource):
|
|||
self.type())
|
||||
|
||||
|
||||
class MultiStepResource(GenericResource):
|
||||
properties_schema = {
|
||||
'create_steps': properties.Schema(properties.Schema.INTEGER,
|
||||
default=2),
|
||||
'update_steps': properties.Schema(properties.Schema.INTEGER,
|
||||
default=2, update_allowed=True),
|
||||
'delete_steps': properties.Schema(properties.Schema.INTEGER,
|
||||
default=2, update_allowed=True),
|
||||
}
|
||||
|
||||
def handle_create(self):
|
||||
super(MultiStepResource, self).handle_create()
|
||||
return [None] * self.properties['create_steps']
|
||||
|
||||
def check_create_complete(self, cookie):
|
||||
cookie.pop()
|
||||
return not cookie
|
||||
|
||||
def handle_update(self, json_snippet, tmpl_diff, prop_diff):
|
||||
super(MultiStepResource, self).handle_update(json_snippet,
|
||||
tmpl_diff,
|
||||
prop_diff)
|
||||
return [None] * self.properties['update_steps']
|
||||
|
||||
def check_update_complete(self, cookie):
|
||||
cookie.pop()
|
||||
return not cookie
|
||||
|
||||
def handle_delete(self):
|
||||
super(MultiStepResource, self).handle_delete()
|
||||
return [None] * self.properties['delete_steps']
|
||||
|
||||
def check_delete_complete(self, cookie):
|
||||
cookie.pop()
|
||||
return not cookie
|
||||
|
||||
|
||||
class ResWithShowAttr(GenericResource):
|
||||
def _show_resource(self):
|
||||
return {'foo': self.name,
|
||||
|
|
Loading…
Reference in New Issue