예제 #1
0
 def _check_success(self, tosca_file, hot_file, params, mock_stdout):
     arglist = ["--template-file", tosca_file, "--template-type", "tosca"]
     parsed_args = self.check_parser(self.cmd, arglist, [])
     parsed_args.parameter = params
     self.cmd.take_action(parsed_args)
     expected_output = YamlUtils.get_dict(hot_file)
     mock_stdout_yaml = "\n".join(mock_stdout.getvalue().split("\n"))
     actual_output = toscaparser.utils.yamlparser.simple_parse(mock_stdout_yaml)
     self.assertEqual({}, CompareUtils.diff_dicts(actual_output, expected_output))
 def _compare_hot_params(self, resulted_hot_params,
                         expected_hot_params):
     for expected_param in expected_hot_params:
         for resulted_param_obj in resulted_hot_params:
             resulted_param = resulted_param_obj.get_dict_output()
             result = CompareUtils.compare_dicts(expected_param,
                                                 resulted_param)
             if not result:
                 raise Exception(_("hot input and resulted input "
                                 "params are not equal."))
 def _compare_hot_params(self, resulted_hot_params, expected_hot_params):
     for expected_param in expected_hot_params:
         for resulted_param_obj in resulted_hot_params:
             resulted_param = resulted_param_obj.get_dict_output()
             result = CompareUtils.compare_dicts(expected_param,
                                                 resulted_param)
             if not result:
                 raise Exception(
                     _("hot input and resulted input "
                       "params are not equal."))
예제 #4
0
 def _check_success(self, tosca_file, hot_file, params, mock_stdout):
     arglist = ["--template-file", tosca_file,
                "--template-type", "tosca"]
     parsed_args = self.check_parser(self.cmd, arglist, [])
     parsed_args.parameter = params
     self.cmd.take_action(parsed_args)
     expected_output = YamlUtils.get_dict(hot_file)
     mock_stdout_yaml = "\n".join(mock_stdout.getvalue().split("\n"))
     actual_output = toscaparser.utils.yamlparser.simple_parse(
         mock_stdout_yaml)
     self.assertEqual({}, CompareUtils.diff_dicts(
         actual_output, expected_output))
예제 #5
0
    def test_translate_output_order(self):
        tosca_yaml_file = "data/tosca_single_server.yaml"
        tosca_tpl = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 tosca_yaml_file)
        parsed_params = {'cpus': 2}
        tosca = ToscaTemplate(tosca_tpl)
        translate = TOSCATranslator(tosca, parsed_params)
        hot_translated_output = translate.translate()

        #load expected hot yaml file
        hot_yaml_file = "data/hot_output/hot_single_server.yaml"
        hot_tpl = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               hot_yaml_file)
        with open(hot_tpl) as f:
            hot_expected_output = f.read()

        #compare generated and expected hot templates
        status = CompareUtils.compare_hot_yamls(hot_translated_output,
                                                hot_expected_output)
        self.assertEqual(status, True)
    def test_translate_output_order(self):
        tosca_yaml_file = "data/tosca_single_server.yaml"
        tosca_tpl = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            tosca_yaml_file)
        parsed_params = {'cpus': 2}
        tosca = ToscaTemplate(tosca_tpl)
        translate = TOSCATranslator(tosca, parsed_params)
        hot_translated_output = translate.translate()

        #load expected hot yaml file
        hot_yaml_file = "data/hot_output/hot_single_server.yaml"
        hot_tpl = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            hot_yaml_file)
        with open(hot_tpl) as f:
            hot_expected_output = f.read()

        #compare generated and expected hot templates
        status = CompareUtils.compare_hot_yamls(hot_translated_output,
                                                hot_expected_output)
        self.assertEqual(status, True)
예제 #7
0
    def test_single_template_objectstore(self):
        tosca_yaml_file = "../toscalib/tests/data/storage/" + \
            "tosca_single_object_store.yaml"
        tosca_tpl = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                 tosca_yaml_file)
        parsed_params = {'objectstore_name': 'test_obj_store'}
        tosca = ToscaTemplate(tosca_tpl)
        translate = TOSCATranslator(tosca, parsed_params)
        hot_translated_output = translate.translate()

        #load expected hot yaml file
        hot_yaml_file = "../toscalib/tests/data/hot_output/" + \
            "hot_single_object_store.yaml"
        hot_tpl = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                               hot_yaml_file)
        with open(hot_tpl) as f:
            hot_expected_output = f.read()

        #compare generated and expected hot templates
        status = CompareUtils.compare_hot_yamls(hot_translated_output,
                                                hot_expected_output)
        self.assertEqual(status, True)
    def test_single_template_objectstore(self):
        tosca_yaml_file = "../toscalib/tests/data/storage/" + \
            "tosca_single_object_store.yaml"
        tosca_tpl = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            tosca_yaml_file)
        parsed_params = {'objectstore_name': 'test_obj_store'}
        tosca = ToscaTemplate(tosca_tpl)
        translate = TOSCATranslator(tosca, parsed_params)
        hot_translated_output = translate.translate()

        #load expected hot yaml file
        hot_yaml_file = "../toscalib/tests/data/hot_output/" + \
            "hot_single_object_store.yaml"
        hot_tpl = os.path.join(
            os.path.dirname(os.path.abspath(__file__)),
            hot_yaml_file)
        with open(hot_tpl) as f:
            hot_expected_output = f.read()

        #compare generated and expected hot templates
        status = CompareUtils.compare_hot_yamls(hot_translated_output,
                                                hot_expected_output)
        self.assertEqual(status, True)