# Path: translator/common/utils.py
# class TranslationUtils(object):
# 
#     @staticmethod
#     def compare_tosca_translation_with_hot(tosca_file, hot_files, params):
#         '''Verify tosca translation against the given hot specification.
# 
#         inputs:
#         tosca_file: relative local path or URL to the tosca input file
#         hot_file: relative path to expected hot output
#         params: dictionary of parameter name value pairs
# 
#         Returns as a dictionary the difference between the HOT translation
#         of the given tosca_file and the given hot_file.
#         '''
# 
#         from toscaparser.tosca_template import ToscaTemplate
#         from translator.hot.tosca_translator import TOSCATranslator
# 
#         tosca_tpl = os.path.normpath(os.path.join(
#             os.path.dirname(os.path.abspath(__file__)), tosca_file))
#         a_file = os.path.isfile(tosca_tpl)
#         if not a_file:
#             tosca_tpl = tosca_file
# 
#         expected_hot_templates = []
#         for hot_file in hot_files:
#             expected_hot_templates.append(os.path.join(
#                 os.path.dirname(os.path.abspath(__file__)), hot_file))
# 
#         tosca = ToscaTemplate(tosca_tpl, params, a_file)
#         translate = TOSCATranslator(tosca, params)
# 
#         basename = os.path.basename(hot_files[0])
#         output_hot_templates = translate.translate_to_yaml_files_dict(basename)
#         output_dict = {}
#         for output_hot_template_name in output_hot_templates:
#             output_dict[output_hot_template_name] = \
#                 toscaparser.utils.yamlparser.simple_parse(
#                     output_hot_templates[output_hot_template_name])
# 
#         expected_output_dict = {}
#         for expected_hot_template in expected_hot_templates:
#             expected_output_dict[os.path.basename(expected_hot_template)] = \
#                 YamlUtils.get_dict(expected_hot_template)
# 
#         return CompareUtils.diff_dicts(expected_output_dict, output_dict)


import json
import os
from toscaparser.common.exception import ExceptionCollector
from toscaparser.utils.gettextutils import _
from translator.common.utils import TranslationUtils
from translator.tests.base import TestCase
#    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.




class EtsiToscaHotTranslationTest(TestCase):

    def _test_successful_translation(self, tosca_file, hot_files, params=None):
        if not params:
            params = {}
        if not isinstance(hot_files, list):
            hot_files = [hot_files]
        diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
                                                                   hot_files,
                                                                   params)
        self.assertEqual({}, diff, '<difference> : ' +
                         json.dumps(diff, indent=4, separators=(', ', ': ')))

    def _test_failed_translation(self, tosca_file, hot_file, params, msg,
                                 msg_path, error_raise, error_collect):
        if msg_path:
            path = os.path.normpath(os.path.join(
                os.path.dirname(os.path.realpath(__file__)), tosca_file))
            msg = msg % path
        self.assertRaises(
            error_raise,

# Path: translator/common/utils.py
# class TranslationUtils(object):
# 
#     @staticmethod
#     def compare_tosca_translation_with_hot(tosca_file, hot_files, params):
#         '''Verify tosca translation against the given hot specification.
# 
#         inputs:
#         tosca_file: relative local path or URL to the tosca input file
#         hot_file: relative path to expected hot output
#         params: dictionary of parameter name value pairs
# 
#         Returns as a dictionary the difference between the HOT translation
#         of the given tosca_file and the given hot_file.
#         '''
# 
#         from toscaparser.tosca_template import ToscaTemplate
#         from translator.hot.tosca_translator import TOSCATranslator
# 
#         tosca_tpl = os.path.normpath(os.path.join(
#             os.path.dirname(os.path.abspath(__file__)), tosca_file))
#         a_file = os.path.isfile(tosca_tpl)
#         if not a_file:
#             tosca_tpl = tosca_file
# 
#         expected_hot_templates = []
#         for hot_file in hot_files:
#             expected_hot_templates.append(os.path.join(
#                 os.path.dirname(os.path.abspath(__file__)), hot_file))
# 
#         tosca = ToscaTemplate(tosca_tpl, params, a_file)
#         translate = TOSCATranslator(tosca, params)
# 
#         basename = os.path.basename(hot_files[0])
#         output_hot_templates = translate.translate_to_yaml_files_dict(basename)
#         output_dict = {}
#         for output_hot_template_name in output_hot_templates:
#             output_dict[output_hot_template_name] = \
#                 toscaparser.utils.yamlparser.simple_parse(
#                     output_hot_templates[output_hot_template_name])
# 
#         expected_output_dict = {}
#         for expected_hot_template in expected_hot_templates:
#             expected_output_dict[os.path.basename(expected_hot_template)] = \
#                 YamlUtils.get_dict(expected_hot_template)
# 
#         return CompareUtils.diff_dicts(expected_output_dict, output_dict)


# Path: translator/tests/test_etsi_tosca_hot_translation.py
import json
import os
from toscaparser.common.exception import ExceptionCollector
from toscaparser.utils.gettextutils import _
from translator.common.utils import TranslationUtils
from translator.tests.base import TestCase

#    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.




class EtsiToscaHotTranslationTest(TestCase):

    def _test_successful_translation(self, tosca_file, hot_files, params=None):
        if not params:
            params = {}
        if not isinstance(hot_files, list):
            hot_files = [hot_files]
        diff = TranslationUtils.compare_tosca_translation_with_hot(tosca_file,
                                                                   hot_files,
                                                                   params)
        self.assertEqual({}, diff, '<difference> : ' +
                         json.dumps(diff, indent=4, separators=(', ', ': ')))

    def _test_failed_translation(self, tosca_file, hot_file, params, msg,
                                 msg_path, error_raise, error_collect):
        if msg_path:
            path = os.path.normpath(os.path.join(
                os.path.dirname(os.path.realpath(__file__)), tosca_file))
            msg = msg % path
        self.assertRaises(
            error_raise,

            TranslationUtils.compare_tosca_translation_with_hot,