Move registration of GenericResource to HeatTest

This patch moves registration of GenericResource to the main test class.
There are several places, where original registration was saved:
- heat/tests/autoscaling/test_lbutils.py - need to be consist with type
names of other resources which are used in test.
- heat/tests/test_environment.py - need special type name for testing
  environment mapping.
- heat/tests/test_engine_service.py - need two different types fro mapping.

Change-Id: I33bdaf3d59e573526e5ffa24086ad55be6bbe6ae
changes/53/189753/2
Sergey Kraynev 7 years ago
parent ee7ad5f106
commit ea116ab17d
  1. 2
      heat/tests/common.py
  2. 16
      heat/tests/engine/test_stack_create.py
  3. 4
      heat/tests/test_engine_api_utils.py
  4. 16
      heat/tests/test_engine_service.py
  5. 3
      heat/tests/test_function.py
  6. 9
      heat/tests/test_hot.py
  7. 6
      heat/tests/test_provider_template.py
  8. 13
      heat/tests/test_resource.py
  9. 4
      heat/tests/test_signal.py
  10. 3
      heat/tests/test_stack.py
  11. 3
      heat/tests/test_stack_delete.py
  12. 3
      heat/tests/test_stack_update.py
  13. 5
      heat/tests/test_template.py

@ -125,6 +125,8 @@ class HeatTestCase(testscenarios.WithScenarios,
self.addCleanup(utils.reset_dummy_db)
def register_test_resources(self):
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
resource._register_class('SignalResourceType',
generic_rsrc.SignalResource)
resource._register_class('ResourceWithPropsType',

@ -20,7 +20,6 @@ from heat.engine.clients.os import glance
from heat.engine.clients.os import nova
from heat.engine import environment
from heat.engine import properties
from heat.engine import resource as res
from heat.engine.resources.aws.ec2 import instance as instances
from heat.engine import service
from heat.engine import stack
@ -29,7 +28,6 @@ from heat.objects import stack as stack_object
from heat.openstack.common import threadgroup
from heat.tests import common
from heat.tests.engine import tools
from heat.tests import generic_resource as generic_rsrc
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
@ -212,13 +210,12 @@ class StackCreateTest(common.HeatTestCase):
def test_stack_create_total_resources_equals_max(self, ctr):
stack_name = 'stack_create_total_resources_equals_max'
params = {}
res._register_class('FakeResourceType', generic_rsrc.GenericResource)
tpl = {
'heat_template_version': '2014-10-16',
'resources': {
'A': {'type': 'FakeResourceType'},
'B': {'type': 'FakeResourceType'},
'C': {'type': 'FakeResourceType'}
'A': {'type': 'GenericResourceType'},
'B': {'type': 'GenericResourceType'},
'C': {'type': 'GenericResourceType'}
}
}
@ -254,13 +251,12 @@ class StackCreateTest(common.HeatTestCase):
def test_stack_create_total_resources_exceeds_max(self):
stack_name = 'stack_create_total_resources_exceeds_max'
params = {}
res._register_class('FakeResourceType', generic_rsrc.GenericResource)
tpl = {
'heat_template_version': '2014-10-16',
'resources': {
'A': {'type': 'FakeResourceType'},
'B': {'type': 'FakeResourceType'},
'C': {'type': 'FakeResourceType'}
'A': {'type': 'GenericResourceType'},
'B': {'type': 'GenericResourceType'},
'C': {'type': 'GenericResourceType'}
}
}

@ -24,12 +24,10 @@ from heat.common import template_format
from heat.engine import api
from heat.engine import event
from heat.engine import parameters
from heat.engine import resource
from heat.engine import stack as parser
from heat.engine import template
from heat.rpc import api as rpc_api
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
from heat.tests import utils
datetime = dt.datetime
@ -48,8 +46,6 @@ class FormatTest(common.HeatTestCase):
'DependsOn': 'generic1'}
}
})
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.stack = parser.Stack(utils.dummy_context(), 'test_stack',
tmpl, stack_id=str(uuid.uuid4()))

@ -595,8 +595,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
environment = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_stack_adopt_data_and_template(
environment)
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
result = self.man.create_stack(self.ctx, "test_adopt_stack",
template, {}, None,
{'adopt_stack_data': str(adopt_data)})
@ -614,8 +612,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
}
template, adopt_data = self._get_stack_adopt_data_and_template(
environment)
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
result = self.man.create_stack(self.ctx, "test_adopt_stack",
template, input_params, None,
{'adopt_stack_data': str(adopt_data)})
@ -630,8 +626,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
env = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_stack_adopt_data_and_template(
env)
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
result = self.man.create_stack(self.ctx, "test_adopt_stack",
template, {}, None,
{'adopt_stack_data': str(adopt_data)})
@ -646,8 +640,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
environment = {'parameters': {"app_dbx": "test"}}
template, adopt_data = self._get_stack_adopt_data_and_template(
environment)
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
ex = self.assertRaises(
dispatcher.ExpectedException,
self.man.create_stack,
@ -886,8 +878,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
def test_stack_update_equals(self, ctr):
stack_name = 'test_stack_update_equals_resource_limit'
params = {}
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
tpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {
'A': {'Type': 'GenericResourceType'},
@ -998,8 +988,6 @@ class StackServiceAdoptUpdateTest(common.HeatTestCase):
def test_stack_update_exceeds_resource_limit(self):
stack_name = 'test_stack_update_exceeds_resource_limit'
params = {}
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
tpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {
'A': {'Type': 'GenericResourceType'},
@ -1481,8 +1469,6 @@ class StackServiceTest(common.HeatTestCase):
@tools.stack_context('event_list_deleted_stack')
def test_stack_event_list_deleted_resource(self):
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
thread = self.m.CreateMockAnything()
thread.link(mox.IgnoreArg()).AndReturn(None)
@ -2855,8 +2841,6 @@ class StackServiceTest(common.HeatTestCase):
def test_lazy_load_resources(self):
stack_name = 'lazy_load_test'
res._register_class('GenericResourceType',
generic_rsrc.GenericResource)
lazy_load_template = {
'HeatTemplateFormatVersion': '2012-12-12',

@ -161,9 +161,6 @@ class ValidateGetAttTest(common.HeatTestCase):
def setUp(self):
super(ValidateGetAttTest, self).setUp()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
env = environment.Environment()
env.load({u'resource_registry':
{u'OS::Test::GenericResource': u'GenericResourceType'}})

@ -896,9 +896,6 @@ class HotStackTest(common.HeatTestCase):
self.tmpl = template.Template(copy.deepcopy(empty_template))
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def resolve(self, snippet):
return function.resolve(self.stack.t.parse(self.stack, snippet))
@ -1133,9 +1130,6 @@ class StackAttributesTest(common.HeatTestCase):
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.m.ReplayAll()
scenarios = [
@ -1223,9 +1217,6 @@ class StackGetAttrValidationTest(common.HeatTestCase):
super(StackGetAttrValidationTest, self).setUp()
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def test_validate_props_from_attrs(self):
stack = parser.Stack(self.ctx, 'test_props_from_attrs',
template.Template(hot_tpl_mapped_props))

@ -48,8 +48,6 @@ class MyCloudResource(generic_rsrc.GenericResource):
class ProviderTemplateTest(common.HeatTestCase):
def setUp(self):
super(ProviderTemplateTest, self).setUp()
resource._register_class('OS::ResourceType',
generic_rsrc.GenericResource)
resource._register_class('myCloud::ResourceType',
MyCloudResource)
@ -58,7 +56,7 @@ class ProviderTemplateTest(common.HeatTestCase):
# default class.
env_str = {'resource_registry': {}}
env = environment.Environment(env_str)
cls = env.get_class('OS::ResourceType', 'fred')
cls = env.get_class('GenericResourceType', 'fred')
self.assertEqual(generic_rsrc.GenericResource, cls)
def test_get_mine_global_map(self):
@ -89,7 +87,7 @@ class ProviderTemplateTest(common.HeatTestCase):
env_str = {'resource_registry': {'resources': {'jerry': {
"OS::ResourceType": "myCloud::ResourceType"}}}}
env = environment.Environment(env_str)
cls = env.get_class('OS::ResourceType', 'fred')
cls = env.get_class('GenericResourceType', 'fred')
self.assertEqual(generic_rsrc.GenericResource, cls)
def test_to_parameters(self):

@ -54,9 +54,6 @@ class ResourceTest(common.HeatTestCase):
def setUp(self):
super(ResourceTest, self).setUp()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.env = environment.Environment()
self.env.load({u'resource_registry':
{u'OS::Test::GenericResource': u'GenericResourceType',
@ -1463,10 +1460,6 @@ class ResourceTest(common.HeatTestCase):
class ResourceAdoptTest(common.HeatTestCase):
def setUp(self):
super(ResourceAdoptTest, self).setUp()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def test_adopt_resource_success(self):
adopt_data = '{}'
@ -1553,9 +1546,6 @@ class ResourceDependenciesTest(common.HeatTestCase):
def setUp(self):
super(ResourceDependenciesTest, self).setUp()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.deps = dependencies.Dependencies()
def test_no_deps(self):
@ -2145,9 +2135,6 @@ class ResourceHookTest(common.HeatTestCase):
def setUp(self):
super(ResourceHookTest, self).setUp()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
self.env = environment.Environment()
self.env.load({u'resource_registry':
{u'OS::Test::GenericResource': u'GenericResourceType',

@ -47,10 +47,6 @@ class SignalTest(common.HeatTestCase):
def setUp(self):
super(SignalTest, self).setUp()
resource._register_class('GenericResourceType',
generic_resource.GenericResource)
self.stack_id = 'STACKABCD1234'
def tearDown(self):

@ -53,9 +53,6 @@ class StackTest(common.HeatTestCase):
self.tmpl = template.Template(copy.deepcopy(empty_template))
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def test_stack_reads_tenant(self):
self.stack = stack.Stack(self.ctx, 'test_stack', self.tmpl,
tenant_id='bar')

@ -23,7 +23,6 @@ from heat.common import exception
from heat.common import heat_keystoneclient as hkc
from heat.common import template_format
from heat.engine.clients.os import keystone
from heat.engine import resource
from heat.engine import scheduler
from heat.engine import stack
from heat.engine import template
@ -46,8 +45,6 @@ class StackTest(common.HeatTestCase):
self.tmpl = template.Template(copy.deepcopy(empty_template))
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def test_delete(self):
self.stack = stack.Stack(self.ctx, 'delete_test', self.tmpl)

@ -37,9 +37,6 @@ class StackUpdateTest(common.HeatTestCase):
self.tmpl = template.Template(copy.deepcopy(empty_template))
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
def test_update_add(self):
tmpl = {'HeatTemplateFormatVersion': '2012-12-12',
'Resources': {'AResource': {'Type': 'GenericResourceType'}}}

@ -28,12 +28,10 @@ from heat.engine import environment
from heat.engine import function
from heat.engine.hot import template as hot_t
from heat.engine import parameters
from heat.engine import resource
from heat.engine import rsrc_defn
from heat.engine import stack
from heat.engine import template
from heat.tests import common
from heat.tests import generic_resource as generic_rsrc
from heat.tests.nova import fakes as fakes_nova
from heat.tests import utils
@ -381,9 +379,6 @@ class TemplateTest(common.HeatTestCase):
super(TemplateTest, self).setUp()
self.ctx = utils.dummy_context()
resource._register_class('GenericResourceType',
generic_rsrc.GenericResource)
@staticmethod
def resolve(snippet, template, stack=None):
return function.resolve(template.parse(stack, snippet))

Loading…
Cancel
Save