diff --git a/translator/hot/translate_node_templates.py b/translator/hot/translate_node_templates.py index 05d6973c..b049a960 100644 --- a/translator/hot/translate_node_templates.py +++ b/translator/hot/translate_node_templates.py @@ -91,7 +91,7 @@ def _load_classes(locations, classes): if f == 'tosca_block_storage_attachment.py': continue - mod_name = cls_path + '/' + f.strip('.py') + mod_name = cls_path + '/' + os.path.splitext(f)[0] mod_name = mod_name.replace('/', '.') try: mod = importlib.import_module(mod_name) diff --git a/translator/tests/test_conf.py b/translator/tests/test_conf.py index 6506c272..ec5aa48c 100644 --- a/translator/tests/test_conf.py +++ b/translator/tests/test_conf.py @@ -42,16 +42,16 @@ class ConfTest(TestCase): translatorConfig._load_config('fake_file.conf') self.assertTrue(translatorConfig._translator_config.read.called) - def test_get_value(self): - ret_value = mock.MagicMock(return_value='hot') - translatorConfig._translator_config.get = ret_value + @mock.patch.object(translatorConfig._translator_config, 'get') + def test_get_value(self, mock_translator_config): + mock_translator_config.return_value = 'hot' value = translatorConfig.get_value('DEFAULT', 'language') self.assertTrue(translatorConfig._translator_config.get.called) self.assertEqual(value, 'hot') - def test_get_all_values(self): - ret_value = mock.MagicMock(return_value=['hot']) - translatorConfig._translator_config.items = ret_value + @mock.patch.object(translatorConfig._translator_config, 'items') + def test_get_all_values(self, mock_translator_config): + mock_translator_config.return_value = ['hot'] values = translatorConfig.get_all_values() self.assertTrue(translatorConfig._translator_config.items.called) self.assertEqual(values[0], 'hot') diff --git a/translator/tests/test_translate_node_template.py b/translator/tests/test_translate_node_template.py new file mode 100644 index 00000000..98b9d0cd --- /dev/null +++ b/translator/tests/test_translate_node_template.py @@ -0,0 +1,41 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from translator.hot.translate_node_templates import _generate_type_map +from translator.tests.base import TestCase + + +class TranslateNodeTemplatesTest(TestCase): + + def test_generate_type_map(self): + + expected_type_list = [ + 'tosca.nodes.BlockStorage', + 'tosca.nodes.Compute', + 'tosca.nodes.DBMS', + 'tosca.nodes.Database', + 'tosca.nodes.ObjectStorage', + 'tosca.nodes.SoftwareComponent', + 'tosca.nodes.WebApplication', + 'tosca.nodes.WebServer', + 'tosca.nodes.network.FloatingIP', + 'tosca.nodes.network.Network', + 'tosca.nodes.network.Port', + 'tosca.policies.Monitoring', + 'tosca.policies.Placement', + 'tosca.policies.Reservation', + 'tosca.policies.Scaling', + 'tosca.policies.Scaling.Cluster' + ] + actual_type_list = list(_generate_type_map()) + + self.assertItemsEqual(expected_type_list, actual_type_list)