From 440a306216ef943d13c4f8ba1b15ea1e20d1ffe1 Mon Sep 17 00:00:00 2001 From: Sergey Kraynev Date: Thu, 18 Feb 2016 06:33:13 -0500 Subject: [PATCH] Add one general testing of resource_mapping Each resource in Heat has resource_mapping fucntion for loading his type in environment for futher using. This method should be callable and should return dictionary, where key is resource type and value is corresponding resource class. More over resource_type should have format: "Platform Type"/"Service type"/.../"Resource Name" This patch adds common test for this method and check all modules in heat.engine.resources sub-directories. Duplicate useless tests were removed. Change-Id: I8148811418c21277a4b732de98a53c5291f57f1f --- .../openstack/cinder/test_volume_type.py | 9 ---- .../cinder/test_volume_type_encryption.py | 11 ----- heat/tests/openstack/designate/test_domain.py | 6 --- heat/tests/openstack/designate/test_record.py | 6 --- heat/tests/openstack/glance/test_image.py | 7 --- .../tests/openstack/heat/test_cloud_config.py | 8 ---- heat/tests/openstack/heat/test_multi_part.py | 8 ---- .../openstack/heat/test_resource_chain.py | 4 -- .../openstack/heat/test_software_component.py | 8 ---- .../openstack/heat/test_software_config.py | 8 ---- .../heat/test_software_deployment.py | 4 -- .../openstack/heat/test_structured_config.py | 13 ------ .../tests/openstack/keystone/test_endpoint.py | 7 --- heat/tests/openstack/keystone/test_group.py | 6 --- heat/tests/openstack/keystone/test_project.py | 6 --- heat/tests/openstack/keystone/test_region.py | 6 --- heat/tests/openstack/keystone/test_role.py | 6 --- .../keystone/test_role_assignments.py | 8 ---- heat/tests/openstack/keystone/test_service.py | 8 ---- heat/tests/openstack/keystone/test_user.py | 6 --- heat/tests/openstack/magnum/test_bay.py | 5 --- heat/tests/openstack/magnum/test_baymodel.py | 5 --- .../openstack/manila/test_security_service.py | 6 --- .../openstack/manila/test_share_network.py | 6 --- .../openstack/mistral/test_cron_trigger.py | 6 --- heat/tests/openstack/mistral/test_workflow.py | 6 --- .../monasca/test_alarm_definition.py | 8 ---- .../openstack/monasca/test_notification.py | 8 ---- .../openstack/neutron/test_address_scope.py | 8 ---- .../neutron/test_neutron_rbac_policy.py | 6 --- .../neutron/test_neutron_subnetpool.py | 10 ----- heat/tests/openstack/neutron/test_qos.py | 14 ------ heat/tests/openstack/nova/test_flavor.py | 7 --- .../openstack/nova/test_host_aggregate.py | 9 ---- heat/tests/openstack/sahara/test_cluster.py | 8 ---- .../openstack/sahara/test_data_source.py | 6 --- heat/tests/openstack/sahara/test_image.py | 6 --- .../tests/openstack/sahara/test_job_binary.py | 6 --- heat/tests/openstack/sahara/test_templates.py | 16 ------- heat/tests/openstack/senlin/test_cluster.py | 6 --- heat/tests/openstack/senlin/test_policy.py | 6 --- heat/tests/openstack/senlin/test_profile.py | 6 --- heat/tests/openstack/senlin/test_receiver.py | 6 --- heat/tests/openstack/trove/test_cluster.py | 6 --- heat/tests/test_resource.py | 43 +++++++++++++++++++ 45 files changed, 43 insertions(+), 321 deletions(-) diff --git a/heat/tests/openstack/cinder/test_volume_type.py b/heat/tests/openstack/cinder/test_volume_type.py index 11b64a42d5..05a868ce1f 100644 --- a/heat/tests/openstack/cinder/test_volume_type.py +++ b/heat/tests/openstack/cinder/test_volume_type.py @@ -15,7 +15,6 @@ import mock import six from heat.common import exception -from heat.engine.resources.openstack.cinder import volume_type from heat.engine import stack from heat.engine import template from heat.tests import common @@ -57,14 +56,6 @@ class CinderVolumeTypeTest(common.HeatTestCase): self.project_list = mock.MagicMock() keystoneclient.client.projects.get = self.project_list - def test_resource_mapping(self): - mapping = volume_type.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(volume_type.CinderVolumeType, - mapping['OS::Cinder::VolumeType']) - self.assertIsInstance(self.my_volume_type, - volume_type.CinderVolumeType) - def _test_handle_create(self, is_public=True, projects=None): value = mock.MagicMock() volume_type_id = '927202df-1afb-497f-8368-9c2d2f26e5db' diff --git a/heat/tests/openstack/cinder/test_volume_type_encryption.py b/heat/tests/openstack/cinder/test_volume_type_encryption.py index aa3ffcee9f..2526160dfa 100644 --- a/heat/tests/openstack/cinder/test_volume_type_encryption.py +++ b/heat/tests/openstack/cinder/test_volume_type_encryption.py @@ -13,7 +13,6 @@ import mock -from heat.engine.resources.openstack.cinder import encrypted_volume_type from heat.engine import stack from heat.engine import template from heat.tests import common @@ -55,16 +54,6 @@ class CinderEncryptedVolumeTypeTest(common.HeatTestCase): self.volume_encryption_types = ( self.cinderclient.volume_encryption_types) - def test_resource_mapping(self): - mapping = encrypted_volume_type.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(encrypted_volume_type.CinderEncryptedVolumeType, - mapping['OS::Cinder::EncryptedVolumeType']) - self.assertIsInstance( - self.my_encrypted_vol_type, - encrypted_volume_type.CinderEncryptedVolumeType - ) - def test_handle_create(self): value = mock.MagicMock() volume_type_id = '01bd581d-33fe-4d6d-bd7b-70ae076d39fb' diff --git a/heat/tests/openstack/designate/test_domain.py b/heat/tests/openstack/designate/test_domain.py index dd00e41ffd..2b9e37cf16 100644 --- a/heat/tests/openstack/designate/test_domain.py +++ b/heat/tests/openstack/designate/test_domain.py @@ -159,12 +159,6 @@ class DesignateDomainTest(common.HeatTestCase): self.test_resource.resource_id ) - def test_resource_mapping(self): - mapping = domain.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(domain.DesignateDomain, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_resource, domain.DesignateDomain) - def test_resource_show_resource(self): args = dict( name='test', diff --git a/heat/tests/openstack/designate/test_record.py b/heat/tests/openstack/designate/test_record.py index 984c90ff07..a14d52a2ae 100644 --- a/heat/tests/openstack/designate/test_record.py +++ b/heat/tests/openstack/designate/test_record.py @@ -226,12 +226,6 @@ class DesignateRecordTest(common.HeatTestCase): mock_record_delete.side_effect = designate_exception.NotFound self.assertIsNone(self.test_resource.handle_delete()) - def test_resource_mapping(self): - mapping = record.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(record.DesignateRecord, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_resource, record.DesignateRecord) - def test_resource_show_resource(self): args = dict( name='test-record.com', diff --git a/heat/tests/openstack/glance/test_image.py b/heat/tests/openstack/glance/test_image.py index 50aba341ce..a3987424e1 100644 --- a/heat/tests/openstack/glance/test_image.py +++ b/heat/tests/openstack/glance/test_image.py @@ -16,7 +16,6 @@ import six from heat.common import exception from heat.common import template_format -from heat.engine.resources.openstack.glance import image as gi from heat.engine import stack as parser from heat.engine import template from heat.tests import common @@ -79,12 +78,6 @@ class GlanceImageTest(common.HeatTestCase): resource.validate) self.assertIn(error_msg, six.text_type(exc)) - def test_resource_mapping(self): - mapping = gi.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(gi.GlanceImage, mapping['OS::Glance::Image']) - self.assertIsInstance(self.my_image, gi.GlanceImage) - def test_invalid_min_disk(self): # invalid 'min_disk' tpl = template_format.parse(image_template_validate) diff --git a/heat/tests/openstack/heat/test_cloud_config.py b/heat/tests/openstack/heat/test_cloud_config.py index d7dbc71e3f..424866424a 100644 --- a/heat/tests/openstack/heat/test_cloud_config.py +++ b/heat/tests/openstack/heat/test_cloud_config.py @@ -15,7 +15,6 @@ import uuid import mock -from heat.engine.resources.openstack.heat import cloud_config from heat.engine import stack from heat.engine import template from heat.tests import common @@ -43,13 +42,6 @@ class CloudConfigTest(common.HeatTestCase): self.rpc_client = mock.MagicMock() self.config._rpc_client = self.rpc_client - def test_resource_mapping(self): - mapping = cloud_config.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(cloud_config.CloudConfig, - mapping['OS::Heat::CloudConfig']) - self.assertIsInstance(self.config, cloud_config.CloudConfig) - def test_handle_create(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = {'id': config_id} diff --git a/heat/tests/openstack/heat/test_multi_part.py b/heat/tests/openstack/heat/test_multi_part.py index f03ca6d6a2..41b43d62cb 100644 --- a/heat/tests/openstack/heat/test_multi_part.py +++ b/heat/tests/openstack/heat/test_multi_part.py @@ -17,7 +17,6 @@ import uuid import mock from heat.common import exception as exc -from heat.engine.resources.openstack.heat import multi_part as mp from heat.engine import stack as parser from heat.engine import template from heat.tests import common @@ -47,13 +46,6 @@ class MultipartMimeTest(common.HeatTestCase): self.rpc_client = mock.MagicMock() self.config._rpc_client = self.rpc_client - def test_resource_mapping(self): - mapping = mp.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(mp.MultipartMime, - mapping['OS::Heat::MultipartMime']) - self.assertIsInstance(self.config, mp.MultipartMime) - def test_handle_create(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' sc = {'id': config_id} diff --git a/heat/tests/openstack/heat/test_resource_chain.py b/heat/tests/openstack/heat/test_resource_chain.py index 7d9046ea17..f0efce586d 100644 --- a/heat/tests/openstack/heat/test_resource_chain.py +++ b/heat/tests/openstack/heat/test_resource_chain.py @@ -197,10 +197,6 @@ class ResourceChainTests(common.HeatTestCase): chain = self._create_chain(TEMPLATE) self.assertEqual({}, chain.child_params()) - def test_resource_mapping(self): - found = resource_chain.resource_mapping()['OS::Heat::ResourceChain'] - self.assertEqual(found, resource_chain.ResourceChain) - def _create_chain(self, t): self.stack = utils.parse_stack(t) snip = self.stack.t.resource_definitions(self.stack)['test-chain'] diff --git a/heat/tests/openstack/heat/test_software_component.py b/heat/tests/openstack/heat/test_software_component.py index d590447685..1651327fe1 100644 --- a/heat/tests/openstack/heat/test_software_component.py +++ b/heat/tests/openstack/heat/test_software_component.py @@ -16,7 +16,6 @@ import six from heat.common import exception as exc from heat.common import template_format -from heat.engine.resources.openstack.heat import software_component as sc from heat.engine import stack from heat.engine import template from heat.tests import common @@ -60,13 +59,6 @@ class SoftwareComponentTest(common.HeatTestCase): self.rpc_client = mock.MagicMock() self.component._rpc_client = self.rpc_client - def test_resource_mapping(self): - mapping = sc.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sc.SoftwareComponent, - mapping['OS::Heat::SoftwareComponent']) - self.assertIsInstance(self.component, sc.SoftwareComponent) - def test_handle_create(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = {'id': config_id} diff --git a/heat/tests/openstack/heat/test_software_config.py b/heat/tests/openstack/heat/test_software_config.py index fe1fe5ae60..62df0d3ee3 100644 --- a/heat/tests/openstack/heat/test_software_config.py +++ b/heat/tests/openstack/heat/test_software_config.py @@ -14,7 +14,6 @@ import mock from heat.common import exception as exc -from heat.engine.resources.openstack.heat import software_config as sc from heat.engine import stack from heat.engine import template from heat.tests import common @@ -46,13 +45,6 @@ class SoftwareConfigTest(common.HeatTestCase): self.rpc_client = mock.MagicMock() self.config._rpc_client = self.rpc_client - def test_resource_mapping(self): - mapping = sc.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sc.SoftwareConfig, - mapping['OS::Heat::SoftwareConfig']) - self.assertIsInstance(self.config, sc.SoftwareConfig) - def test_handle_create(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = {'id': config_id} diff --git a/heat/tests/openstack/heat/test_software_deployment.py b/heat/tests/openstack/heat/test_software_deployment.py index bacef3b7cf..80004eb5ef 100644 --- a/heat/tests/openstack/heat/test_software_deployment.py +++ b/heat/tests/openstack/heat/test_software_deployment.py @@ -214,10 +214,6 @@ class SoftwareDeploymentTest(common.HeatTestCase): "SOFTWARE_CONFIG since there are " "software deployments on it.", six.text_type(err)) - def test_resource_mapping(self): - self._create_stack(self.template) - self.assertIsInstance(self.deployment, sd.SoftwareDeployment) - def mock_software_config(self): config = { 'id': '48e8ade1-9196-42d5-89a2-f709fde42632', diff --git a/heat/tests/openstack/heat/test_structured_config.py b/heat/tests/openstack/heat/test_structured_config.py index 9eec543116..2108340bf8 100644 --- a/heat/tests/openstack/heat/test_structured_config.py +++ b/heat/tests/openstack/heat/test_structured_config.py @@ -133,19 +133,6 @@ class StructuredConfigTestJSON(common.HeatTestCase): self.rpc_client = mock.MagicMock() self.config._rpc_client = self.rpc_client - def test_resource_mapping(self): - mapping = sc.resource_mapping() - self.assertEqual(4, len(mapping)) - self.assertEqual(sc.StructuredConfig, - mapping['OS::Heat::StructuredConfig']) - self.assertEqual(sc.StructuredDeployment, - mapping['OS::Heat::StructuredDeployment']) - self.assertEqual(sc.StructuredDeploymentGroup, - mapping['OS::Heat::StructuredDeploymentGroup']) - self.assertEqual(sc.StructuredDeployments, - mapping['OS::Heat::StructuredDeployments']) - self.assertIsInstance(self.config, sc.StructuredConfig) - def test_handle_create(self): config_id = 'c8a19429-7fde-47ea-a42f-40045488226c' value = {'id': config_id} diff --git a/heat/tests/openstack/keystone/test_endpoint.py b/heat/tests/openstack/keystone/test_endpoint.py index d147ca1e86..f25ff2d31c 100644 --- a/heat/tests/openstack/keystone/test_endpoint.py +++ b/heat/tests/openstack/keystone/test_endpoint.py @@ -213,13 +213,6 @@ class KeystoneEndpointTest(common.HeatTestCase): enabled=prop_diff[endpoint.KeystoneEndpoint.ENABLED] ) - def test_resource_mapping(self): - rsrc = self._setup_endpoint_resource('test_resource_mapping') - mapping = endpoint.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(endpoint.KeystoneEndpoint, mapping[RESOURCE_TYPE]) - self.assertIsInstance(rsrc, endpoint.KeystoneEndpoint) - def test_properties_title(self): property_title_map = { endpoint.KeystoneEndpoint.SERVICE: 'service', diff --git a/heat/tests/openstack/keystone/test_group.py b/heat/tests/openstack/keystone/test_group.py index 4c8301a91c..ee5d1a7ca8 100644 --- a/heat/tests/openstack/keystone/test_group.py +++ b/heat/tests/openstack/keystone/test_group.py @@ -75,12 +75,6 @@ class KeystoneGroupTest(common.HeatTestCase): return value - def test_resource_mapping(self): - mapping = group.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(group.KeystoneGroup, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_group, group.KeystoneGroup) - def test_properties_title(self): property_title_map = { group.KeystoneGroup.NAME: 'name', diff --git a/heat/tests/openstack/keystone/test_project.py b/heat/tests/openstack/keystone/test_project.py index 92573a58e1..bba8bd67ab 100644 --- a/heat/tests/openstack/keystone/test_project.py +++ b/heat/tests/openstack/keystone/test_project.py @@ -76,12 +76,6 @@ class KeystoneProjectTest(common.HeatTestCase): return value - def test_resource_mapping(self): - mapping = project.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(project.KeystoneProject, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_project, project.KeystoneProject) - def test_project_handle_create(self): mock_project = self._get_mock_project() self.projects.create.return_value = mock_project diff --git a/heat/tests/openstack/keystone/test_region.py b/heat/tests/openstack/keystone/test_region.py index d2db7b79a4..d15d30d999 100644 --- a/heat/tests/openstack/keystone/test_region.py +++ b/heat/tests/openstack/keystone/test_region.py @@ -68,12 +68,6 @@ class KeystoneRegionTest(common.HeatTestCase): return value - def test_resource_mapping(self): - mapping = region.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(region.KeystoneRegion, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_region, region.KeystoneRegion) - def test_region_handle_create(self): mock_region = self._get_mock_region() self.regions.create.return_value = mock_region diff --git a/heat/tests/openstack/keystone/test_role.py b/heat/tests/openstack/keystone/test_role.py index 6eab20e81e..4b10c163f7 100644 --- a/heat/tests/openstack/keystone/test_role.py +++ b/heat/tests/openstack/keystone/test_role.py @@ -59,12 +59,6 @@ class KeystoneRoleTest(common.HeatTestCase): return value - def test_resource_mapping(self): - mapping = role.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(role.KeystoneRole, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_role, role.KeystoneRole) - def test_role_handle_create(self): mock_role = self._get_mock_role() self.roles.create.return_value = mock_role diff --git a/heat/tests/openstack/keystone/test_role_assignments.py b/heat/tests/openstack/keystone/test_role_assignments.py index 2668fe6959..8074235202 100644 --- a/heat/tests/openstack/keystone/test_role_assignments.py +++ b/heat/tests/openstack/keystone/test_role_assignments.py @@ -95,14 +95,6 @@ class KeystoneRoleAssignmentMixinTest(common.HeatTestCase): (self.test_role_assignment.client_plugin. return_value) = self.keystone_client_plugin - def test_resource_mapping(self): - mapping = role_assignments.resource_mapping() - self.assertEqual(2, len(mapping)) - self.assertEqual(role_assignments.KeystoneUserRoleAssignment, - mapping['OS::Keystone::UserRoleAssignment']) - self.assertEqual(role_assignments.KeystoneGroupRoleAssignment, - mapping['OS::Keystone::GroupRoleAssignment']) - def test_properties_title(self): property_title_map = {MixinClass.ROLES: 'roles'} diff --git a/heat/tests/openstack/keystone/test_service.py b/heat/tests/openstack/keystone/test_service.py index ec1837b1d4..51cd8c5e17 100644 --- a/heat/tests/openstack/keystone/test_service.py +++ b/heat/tests/openstack/keystone/test_service.py @@ -196,14 +196,6 @@ class KeystoneServiceTest(common.HeatTestCase): enabled=prop_diff[service.KeystoneService.ENABLED] ) - def test_resource_mapping(self): - rsrc = self._setup_service_resource( - 'test_resource_mapping') - mapping = service.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(service.KeystoneService, mapping[RESOURCE_TYPE]) - self.assertIsInstance(rsrc, service.KeystoneService) - def test_properties_title(self): property_title_map = { service.KeystoneService.NAME: 'name', diff --git a/heat/tests/openstack/keystone/test_user.py b/heat/tests/openstack/keystone/test_user.py index 422e2351c1..f2a1774322 100644 --- a/heat/tests/openstack/keystone/test_user.py +++ b/heat/tests/openstack/keystone/test_user.py @@ -83,12 +83,6 @@ class KeystoneUserTest(common.HeatTestCase): return value - def test_resource_mapping(self): - mapping = user.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(user.KeystoneUser, mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_user, user.KeystoneUser) - def test_user_handle_create(self): mock_user = self._get_mock_user() self.users.create.return_value = mock_user diff --git a/heat/tests/openstack/magnum/test_bay.py b/heat/tests/openstack/magnum/test_bay.py index f337f68671..d25efd3e1b 100644 --- a/heat/tests/openstack/magnum/test_bay.py +++ b/heat/tests/openstack/magnum/test_bay.py @@ -144,11 +144,6 @@ class TestMagnumBay(common.HeatTestCase): self.assertEqual((b.DELETE, b.COMPLETE), b.state) self.assertEqual(2, self.client.bays.get.call_count) - def test_resource_mapping(self): - mapping = bay.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(mapping[RESOURCE_TYPE], bay.Bay) - class BaymodelConstraintTest(common.HeatTestCase): def setUp(self): diff --git a/heat/tests/openstack/magnum/test_baymodel.py b/heat/tests/openstack/magnum/test_baymodel.py index 39f4039913..992a021178 100644 --- a/heat/tests/openstack/magnum/test_baymodel.py +++ b/heat/tests/openstack/magnum/test_baymodel.py @@ -90,11 +90,6 @@ class TestMagnumBayModel(common.HeatTestCase): self.assertEqual((bm.CREATE, bm.COMPLETE), bm.state) self.client.baymodels.create.assert_called_once_with(**self.expected) - def test_resource_mapping(self): - mapping = baymodel.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(baymodel.BayModel, mapping[RESOURCE_TYPE]) - class TestMagnumBayModelWithAddedProperties(TestMagnumBayModel): magnum_template = ''' diff --git a/heat/tests/openstack/manila/test_security_service.py b/heat/tests/openstack/manila/test_security_service.py index 90f7fc1bf9..dd01b22b8e 100644 --- a/heat/tests/openstack/manila/test_security_service.py +++ b/heat/tests/openstack/manila/test_security_service.py @@ -117,12 +117,6 @@ class ManilaSecurityServiceTest(common.HeatTestCase): self.assertIn('Exception: resources.security_service: error', six.text_type(exc)) - def test_resource_mapping(self): - mapping = security_service.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(security_service.SecurityService, - mapping['OS::Manila::SecurityService']) - def test_update(self): ss = self._create_resource('security_service', self.rsrc_defn, self.stack) diff --git a/heat/tests/openstack/manila/test_share_network.py b/heat/tests/openstack/manila/test_share_network.py index a247e66fd7..1e037642ab 100644 --- a/heat/tests/openstack/manila/test_share_network.py +++ b/heat/tests/openstack/manila/test_share_network.py @@ -193,9 +193,3 @@ class ManilaShareNetworkTest(common.HeatTestCase): self.assertEqual('3', net.FnGetAtt('cidr')) self.assertEqual('5', net.FnGetAtt('ip_version')) self.assertEqual('6', net.FnGetAtt('network_type')) - - def test_resource_mapping(self): - mapping = share_network.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(share_network.ManilaShareNetwork, - mapping['OS::Manila::ShareNetwork']) diff --git a/heat/tests/openstack/mistral/test_cron_trigger.py b/heat/tests/openstack/mistral/test_cron_trigger.py index 22eed7f2e2..044754684e 100644 --- a/heat/tests/openstack/mistral/test_cron_trigger.py +++ b/heat/tests/openstack/mistral/test_cron_trigger.py @@ -82,12 +82,6 @@ class MistralCronTriggerTest(common.HeatTestCase): expected_state = (ct.CREATE, ct.COMPLETE) self.assertEqual(expected_state, ct.state) - def test_resource_mapping(self): - mapping = cron_trigger.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(cron_trigger.CronTrigger, - mapping['OS::Mistral::CronTrigger']) - def test_attributes(self): ct = self._create_resource('trigger', self.rsrc_defn, self.stack) self.assertEqual('2015-03-01 00:00:00', diff --git a/heat/tests/openstack/mistral/test_workflow.py b/heat/tests/openstack/mistral/test_workflow.py index 1ce127ce5f..8e9d9c0082 100644 --- a/heat/tests/openstack/mistral/test_workflow.py +++ b/heat/tests/openstack/mistral/test_workflow.py @@ -536,12 +536,6 @@ class TestMistralWorkflow(common.HeatTestCase): self.assertEqual(2, self.mistral.executions.delete.call_count) data_delete.assert_called_once_with('executions') - def test_resource_mapping(self): - mapping = workflow.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(workflow.Workflow, - mapping['OS::Mistral::Workflow']) - def test_signal_failed(self): tmpl = template_format.parse(workflow_template_full) stack = utils.parse_stack(tmpl) diff --git a/heat/tests/openstack/monasca/test_alarm_definition.py b/heat/tests/openstack/monasca/test_alarm_definition.py index 81c1c7df13..32115fe884 100644 --- a/heat/tests/openstack/monasca/test_alarm_definition.py +++ b/heat/tests/openstack/monasca/test_alarm_definition.py @@ -222,14 +222,6 @@ class MonascaAlarmDefinitionTest(common.HeatTestCase): mock_alarm_delete.side_effect = client_plugin.monasca_exc.NotFound self.assertIsNone(self.test_resource.handle_delete()) - def test_resource_mapping(self): - mapping = alarm_definition.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(alarm_definition.MonascaAlarmDefinition, - mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_resource, - alarm_definition.MonascaAlarmDefinition) - def test_resource_show_resource(self): mock_notification_get = self.test_client.alarm_definitions.get mock_notification_get.return_value = {} diff --git a/heat/tests/openstack/monasca/test_notification.py b/heat/tests/openstack/monasca/test_notification.py index 9b8002071d..5b94b9dca6 100644 --- a/heat/tests/openstack/monasca/test_notification.py +++ b/heat/tests/openstack/monasca/test_notification.py @@ -168,14 +168,6 @@ class MonascaNotificationTest(common.HeatTestCase): self.assertIsNone(self.test_resource.handle_delete()) - def test_resource_mapping(self): - mapping = notification.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(notification.MonascaNotification, - mapping[RESOURCE_TYPE]) - self.assertIsInstance(self.test_resource, - notification.MonascaNotification) - def test_resource_show_resource(self): mock_notification_get = self.test_client.notifications.get mock_notification_get.return_value = {} diff --git a/heat/tests/openstack/neutron/test_address_scope.py b/heat/tests/openstack/neutron/test_address_scope.py index 18c8523bb3..2294c6e863 100644 --- a/heat/tests/openstack/neutron/test_address_scope.py +++ b/heat/tests/openstack/neutron/test_address_scope.py @@ -15,7 +15,6 @@ import mock from heat.common import template_format from heat.engine.clients.os import neutron -from heat.engine.resources.openstack.neutron import address_scope from heat.engine import rsrc_defn from heat.engine import stack from heat.engine import template @@ -56,13 +55,6 @@ class NeutronAddressScopeTest(common.HeatTestCase): self.my_address_scope.client = mock.MagicMock( return_value=self.neutronclient) - def test_resource_mapping(self): - mapping = address_scope.resource_mapping() - self.assertEqual(address_scope.AddressScope, - mapping['OS::Neutron::AddressScope']) - self.assertIsInstance(self.my_address_scope, - address_scope.AddressScope) - def test_address_scope_handle_create(self): addrs = { 'address_scope': { diff --git a/heat/tests/openstack/neutron/test_neutron_rbac_policy.py b/heat/tests/openstack/neutron/test_neutron_rbac_policy.py index b31529ce6b..e53ba72eae 100644 --- a/heat/tests/openstack/neutron/test_neutron_rbac_policy.py +++ b/heat/tests/openstack/neutron/test_neutron_rbac_policy.py @@ -19,7 +19,6 @@ from neutronclient.common import exceptions from heat.common import exception from heat.common import template_format -from heat.engine.resources.openstack.neutron import rbac_policy from heat.tests import common from heat.tests.openstack.neutron import inline_templates from heat.tests import utils @@ -27,11 +26,6 @@ from heat.tests import utils class RBACPolicyTest(common.HeatTestCase): - def test_resource_mapping(self): - mapping = rbac_policy.resource_mapping() - self.assertEqual(rbac_policy.RBACPolicy, - mapping['OS::Neutron::RBACPolicy']) - @mock.patch('heat.engine.clients.os.neutron.' 'NeutronClientPlugin.has_extension', return_value=True) def _create_stack(self, ext_func, tmpl=inline_templates.RBAC_TEMPLATE): diff --git a/heat/tests/openstack/neutron/test_neutron_subnetpool.py b/heat/tests/openstack/neutron/test_neutron_subnetpool.py index 3b953d2e06..e2da595e09 100644 --- a/heat/tests/openstack/neutron/test_neutron_subnetpool.py +++ b/heat/tests/openstack/neutron/test_neutron_subnetpool.py @@ -63,16 +63,6 @@ class NeutronSubnetPoolTest(common.HeatTestCase): self.assertEqual((rsrc.CREATE, status), rsrc.state) return rsrc - def test_resource_mapping(self): - self.t = template_format.parse(inline_templates.SPOOL_TEMPLATE) - self.stack = utils.parse_stack(self.t) - rsrc = self.stack['sub_pool'] - mapping = subnetpool.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(subnetpool.SubnetPool, - mapping['OS::Neutron::SubnetPool']) - self.assertIsInstance(rsrc, subnetpool.SubnetPool) - def test_validate_prefixlen_min_gt_max(self): self.t = template_format.parse(inline_templates.SPOOL_TEMPLATE) props = self.t['resources']['sub_pool']['properties'] diff --git a/heat/tests/openstack/neutron/test_qos.py b/heat/tests/openstack/neutron/test_qos.py index 5d09b01fc7..2ed0723710 100644 --- a/heat/tests/openstack/neutron/test_qos.py +++ b/heat/tests/openstack/neutron/test_qos.py @@ -15,7 +15,6 @@ import mock from heat.common import template_format from heat.engine.clients.os import neutron -from heat.engine.resources.openstack.neutron import qos from heat.engine import rsrc_defn from heat.engine import stack from heat.engine import template @@ -70,11 +69,6 @@ class NeutronQoSPolicyTest(common.HeatTestCase): self.my_qos_policy.client = mock.MagicMock( return_value=self.neutronclient) - def test_resource_mapping(self): - mapping = qos.resource_mapping() - self.assertEqual(qos.QoSPolicy, mapping['OS::Neutron::QoSPolicy']) - self.assertIsInstance(self.my_qos_policy, qos.QoSPolicy) - def test_qos_policy_handle_create(self): policy = { 'policy': { @@ -192,14 +186,6 @@ class NeutronQoSBandwidthLimitRuleTest(common.HeatTestCase): self.policy_id = '477e8273-60a7-4c41-b683-fdb0bc7cd151' self.find_mock.return_value = self.policy_id - def test_resource_mapping(self): - mapping = qos.resource_mapping() - self.assertEqual(2, len(mapping)) - self.assertEqual(qos.QoSBandwidthLimitRule, - mapping['OS::Neutron::QoSBandwidthLimitRule']) - self.assertIsInstance(self.bandwidth_limit_rule, - qos.QoSBandwidthLimitRule) - def test_rule_handle_create(self): rule = { 'bandwidth_limit_rule': { diff --git a/heat/tests/openstack/nova/test_flavor.py b/heat/tests/openstack/nova/test_flavor.py index 9088385760..fae477dfeb 100644 --- a/heat/tests/openstack/nova/test_flavor.py +++ b/heat/tests/openstack/nova/test_flavor.py @@ -14,7 +14,6 @@ import mock from heat.engine.clients.os import nova as novac -from heat.engine.resources.openstack.nova import flavor from heat.engine import stack from heat.engine import template from heat.tests import common @@ -58,12 +57,6 @@ class NovaFlavorTest(common.HeatTestCase): nova.return_value = self.novaclient self.flavors = self.novaclient.flavors - def test_resource_mapping(self): - mapping = flavor.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(flavor.NovaFlavor, mapping['OS::Nova::Flavor']) - self.assertIsInstance(self.my_flavor, flavor.NovaFlavor) - def test_flavor_handle_create(self): value = mock.MagicMock() flavor_id = '927202df-1afb-497f-8368-9c2d2f26e5db' diff --git a/heat/tests/openstack/nova/test_host_aggregate.py b/heat/tests/openstack/nova/test_host_aggregate.py index 3dc6b94334..2b7dd9d271 100644 --- a/heat/tests/openstack/nova/test_host_aggregate.py +++ b/heat/tests/openstack/nova/test_host_aggregate.py @@ -14,7 +14,6 @@ import mock from heat.engine.clients.os import nova -from heat.engine.resources.openstack.nova import host_aggregate from heat.engine import stack from heat.engine import template from heat.tests import common @@ -57,14 +56,6 @@ class NovaHostAggregateTest(common.HeatTestCase): nova_client.return_value = self.novaclient self.aggregates = self.novaclient.aggregates - def test_resource_mapping(self): - mapping = host_aggregate.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(host_aggregate.HostAggregate, - mapping['OS::Nova::HostAggregate']) - self.assertIsInstance(self.my_aggregate, - host_aggregate.HostAggregate) - def test_aggregate_handle_create(self): value = mock.MagicMock() aggregate_id = '927202df-1afb-497f-8368-9c2d2f26e5db' diff --git a/heat/tests/openstack/sahara/test_cluster.py b/heat/tests/openstack/sahara/test_cluster.py index e25bff37dc..86042e6ca7 100644 --- a/heat/tests/openstack/sahara/test_cluster.py +++ b/heat/tests/openstack/sahara/test_cluster.py @@ -158,14 +158,6 @@ class SaharaClusterTest(common.HeatTestCase): self.assertEqual({"cluster": "info"}, cluster.FnGetAtt('show')) self.assertEqual(3, self.cl_mgr.get.call_count) - def test_cluster_resource_mapping(self): - cluster = self._init_cluster(self.t) - mapping = sc.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sc.SaharaCluster, - mapping['OS::Sahara::Cluster']) - self.assertIsInstance(cluster, sc.SaharaCluster) - def test_cluster_create_no_image_anywhere_fails(self): self.t['resources']['super-cluster']['properties'].pop( 'default_image_id') diff --git a/heat/tests/openstack/sahara/test_data_source.py b/heat/tests/openstack/sahara/test_data_source.py index e9ef89a9bf..7ef335ff08 100644 --- a/heat/tests/openstack/sahara/test_data_source.py +++ b/heat/tests/openstack/sahara/test_data_source.py @@ -72,12 +72,6 @@ class SaharaDataSourceTest(common.HeatTestCase): expected_state = (ds.CREATE, ds.COMPLETE) self.assertEqual(expected_state, ds.state) - def test_resource_mapping(self): - mapping = data_source.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(data_source.DataSource, - mapping['OS::Sahara::DataSource']) - def test_update(self): ds = self._create_resource('data-source', self.rsrc_defn, self.stack) diff --git a/heat/tests/openstack/sahara/test_image.py b/heat/tests/openstack/sahara/test_image.py index 945b0a1c0d..367f15ab63 100644 --- a/heat/tests/openstack/sahara/test_image.py +++ b/heat/tests/openstack/sahara/test_image.py @@ -105,9 +105,3 @@ class SaharaImageTest(common.HeatTestCase): value.to_dict.return_value = {'img': 'info'} self.client.images.get.return_value = value self.assertEqual({'img': 'info'}, img.FnGetAtt('show')) - - def test_resource_mapping(self): - mapping = image.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(image.SaharaImageRegistry, - mapping['OS::Sahara::ImageRegistry']) diff --git a/heat/tests/openstack/sahara/test_job_binary.py b/heat/tests/openstack/sahara/test_job_binary.py index 56a11193f2..62a7ca542e 100644 --- a/heat/tests/openstack/sahara/test_job_binary.py +++ b/heat/tests/openstack/sahara/test_job_binary.py @@ -71,12 +71,6 @@ class SaharaJobBinaryTest(common.HeatTestCase): expected_state = (jb.CREATE, jb.COMPLETE) self.assertEqual(expected_state, jb.state) - def test_resource_mapping(self): - mapping = job_binary.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(job_binary.JobBinary, - mapping['OS::Sahara::JobBinary']) - def test_update(self): jb = self._create_resource('job-binary', self.rsrc_defn, self.stack) diff --git a/heat/tests/openstack/sahara/test_templates.py b/heat/tests/openstack/sahara/test_templates.py index 62bcd8d0e1..6a819a6da8 100644 --- a/heat/tests/openstack/sahara/test_templates.py +++ b/heat/tests/openstack/sahara/test_templates.py @@ -132,14 +132,6 @@ class SaharaNodeGroupTemplateTest(common.HeatTestCase): self.stack = utils.parse_stack(template) return self.stack['node-group'] - def test_ngt_resource_mapping(self): - ngt = self._init_ngt(self.t) - mapping = st.resource_mapping() - self.assertEqual(st.SaharaNodeGroupTemplate, - mapping['OS::Sahara::NodeGroupTemplate']) - self.assertIsInstance(ngt, - st.SaharaNodeGroupTemplate) - def _create_ngt(self, template): ngt = self._init_ngt(template) self.ngt_mgr.create.return_value = self.fake_ngt @@ -312,14 +304,6 @@ class SaharaClusterTemplateTest(common.HeatTestCase): self.stack = utils.parse_stack(template) return self.stack['cluster-template'] - def test_ct_resource_mapping(self): - ct = self._init_ct(self.t) - mapping = st.resource_mapping() - self.assertEqual(st.SaharaClusterTemplate, - mapping['OS::Sahara::ClusterTemplate']) - self.assertIsInstance(ct, - st.SaharaClusterTemplate) - def _create_ct(self, template): ct = self._init_ct(template) self.ct_mgr.create.return_value = self.fake_ct diff --git a/heat/tests/openstack/senlin/test_cluster.py b/heat/tests/openstack/senlin/test_cluster.py index 473aa1c60b..51ffffd3cd 100644 --- a/heat/tests/openstack/senlin/test_cluster.py +++ b/heat/tests/openstack/senlin/test_cluster.py @@ -101,12 +101,6 @@ class SenlinClusterTest(common.HeatTestCase): self.assertEqual(self.fake_cl.id, cluster.resource_id) return cluster - def test_resource_mapping(self): - mapping = sc.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sc.Cluster, - mapping['OS::Senlin::Cluster']) - def test_cluster_create_success(self): self._create_cluster(self.t) expect_kwargs = { diff --git a/heat/tests/openstack/senlin/test_policy.py b/heat/tests/openstack/senlin/test_policy.py index 2191442e68..cc49daa1ce 100644 --- a/heat/tests/openstack/senlin/test_policy.py +++ b/heat/tests/openstack/senlin/test_policy.py @@ -181,9 +181,3 @@ class SenlinPolicyTest(common.HeatTestCase): policy = self._create_policy(self.t) self.senlin_mock.get_policy.return_value = FakePolicy() self.assertEqual(excepted_show, policy._show_resource()) - - def test_resource_mapping(self): - mapping = policy.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(policy.Policy, - mapping['OS::Senlin::Policy']) diff --git a/heat/tests/openstack/senlin/test_profile.py b/heat/tests/openstack/senlin/test_profile.py index 7830971a31..14abe881ba 100644 --- a/heat/tests/openstack/senlin/test_profile.py +++ b/heat/tests/openstack/senlin/test_profile.py @@ -113,9 +113,3 @@ class SenlinProfileTest(common.HeatTestCase): prop_diff=prop_diff) self.senlin_mock.update_profile.assert_called_once_with( profile.resource_id, **prop_diff) - - def test_resource_mapping(self): - mapping = sp.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sp.Profile, - mapping['OS::Senlin::Profile']) diff --git a/heat/tests/openstack/senlin/test_receiver.py b/heat/tests/openstack/senlin/test_receiver.py index baa0549171..8195e82b3c 100644 --- a/heat/tests/openstack/senlin/test_receiver.py +++ b/heat/tests/openstack/senlin/test_receiver.py @@ -113,12 +113,6 @@ class SenlinReceiverTest(common.HeatTestCase): self.senlin_mock.delete_receiver.assert_called_once_with( recv.resource_id) - def test_resource_mapping(self): - mapping = sr.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(sr.Receiver, - mapping['OS::Senlin::Receiver']) - def test_cluster_resolve_attribute(self): excepted_show = { 'id': 'some_id', diff --git a/heat/tests/openstack/trove/test_cluster.py b/heat/tests/openstack/trove/test_cluster.py index 1efd551ff2..37a79c5593 100644 --- a/heat/tests/openstack/trove/test_cluster.py +++ b/heat/tests/openstack/trove/test_cluster.py @@ -117,12 +117,6 @@ class TroveClusterTest(common.HeatTestCase): tc.resource_id) self.assertEqual('clusters', tc.entity) - def test_resource_mapping(self): - mapping = cluster.resource_mapping() - self.assertEqual(1, len(mapping)) - self.assertEqual(cluster.TroveCluster, - mapping['OS::Trove::Cluster']) - def test_attributes(self): tc = self._create_resource('cluster', self.rsrc_defn, self.stack) self.assertEqual(['10.0.0.1'], tc.FnGetAtt('ip')) diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index 59e256a26c..c3dc130cf9 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -33,6 +33,7 @@ from heat.engine import clients from heat.engine import constraints from heat.engine import dependencies from heat.engine import environment +from heat.engine import plugin_manager from heat.engine import properties from heat.engine import resource from heat.engine import resources @@ -3747,3 +3748,45 @@ class ResourceUpdateRestrictionTest(common.HeatTestCase): self.new_stack)) self.assertIn('requires replacement', six.text_type(error)) ev.assert_not_called() + + +class TestResourceMapping(common.HeatTestCase): + + def _check_mapping_func(self, func, module): + self.assertTrue(callable(func)) + res = func() + self.assertIsInstance(res, collections.Mapping) + for r_type, r_class in six.iteritems(res): + self.assertIsInstance(r_type, six.string_types) + type_elements = r_type.split('::') + # type has fixed format + # Platform type::Service/Type::Optional Sub-sections::Name + self.assertTrue(len(type_elements) >= 3) + # type should be OS or AWS + self.assertIn(type_elements[0], ('AWS', 'OS')) + # check that value is a class object + self.assertIsInstance(r_class, six.class_types) + # check that class is subclass of Resource base class + self.assertTrue(issubclass(r_class, resource.Resource)) + # check that mentioned class is presented in the same module + self.assertTrue(hasattr(module, six.text_type(r_class.__name__))) + return len(res) + + def test_resource_mappings(self): + # use plugin manager for loading all resources + # use the same approach like and in heat.engine.resources.__init__ + manager = plugin_manager.PluginManager('heat.engine.resources') + num_of_types = 0 + for module in manager.modules: + # check for both potential mappings + for name in ('resource_mapping', 'available_resource_mapping'): + mapping_func = getattr(module, name, None) + if mapping_func: + num_of_types += self._check_mapping_func( + mapping_func, module) + + # check number of registred resource types to make sure, + # that there is no regressions + # It's soft check and should not be a cause of the merge conflict + # Feel free to update it in some separate patch + self.assertTrue(num_of_types >= 137)