def test_get_tosca_template_model_by_id(self):
        doc_id = tosca_template_service.save(
            self.upload_file('application_example_updated.yaml'))
        tosca_template_dict = tosca_template_service.get_tosca_template_dict_by_id(
            doc_id)
        tosca_template_model = ToscaTemplateModel.from_dict(
            tosca_template_dict)

        self.assertIsNotNone(tosca_template_model)
        self.assertIsNotNone(tosca_template_model.topology_template)
        self.assertIsNotNone(
            tosca_template_model.topology_template.node_templates)
    def test_workflow(self):
        base_url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/'
        path = self.download_file(base_url + 'workflows.yaml')
        doc_id = tosca_template_service.save(self.upload_file(path))
        tosca_template_dict = tosca_template_service.get_tosca_template_dict_by_id(
            doc_id)
        tosca_template_model = ToscaTemplateModel.from_dict(
            tosca_template_dict)

        self.assertIsNotNone(tosca_template_model)
        self.assertIsNotNone(tosca_template_model.topology_template)
        self.assertIsNotNone(
            tosca_template_model.topology_template.node_templates)
Example #3
0
def upload_tosca_template(file):  # noqa: E501
    """upload a tosca template description file

    upload and validate a tosca template description file # noqa: E501

    :param file: tosca Template description
    :type file: werkzeug.datastructures.FileStorage

    :rtype: str
    """
    res = tosca_template_service.save(file)
    if res:
        return res
    return 'Bad Request', 400
    def test_upload(self):
        file_names = [
            'application_example_outputs.yaml',
            'application_example_2_topologies.yaml', 'lifeWatch_vre1.yaml',
            'application_example_updated.yaml', 'compute.yaml',
            'application_example_provisioned.yaml', 'topology.yaml',
            'kubernetes.yaml', 'application_example_planed.yaml'
        ]

        for file_name in file_names:
            logger.info("Testing : " + str(file_name))
            doc_id = tosca_template_service.save(self.upload_file(file_name))
            logger.info("doc_id : " + str(doc_id))
            self.assertTrue(doc_id >= 0)
    def test_upload(self):
        base_url = 'https://raw.githubusercontent.com/qcdis-sdia/sdia-tosca/master/examples/'
        file_names = [
            'application_example_outputs.yaml',
            'application_example_2_topologies.yaml',
            'application_example_updated.yaml', 'compute.yaml',
            'application_example_provisioned.yaml', 'topology.yaml'
        ]

        for file_name in file_names:
            path = self.download_file(base_url + file_name)
            logger.info("Testing : " + str(file_name))
            doc_id = tosca_template_service.save(self.upload_file(path))
            logger.info("doc_id : " + str(doc_id))
            self.assertTrue(doc_id >= 0)