Commit b8385753 authored by Spiros Koulouzis's avatar Spiros Koulouzis

added test in dockerfile

parent 92b97dff
FROM python:3.7-buster
FROM python:3.6-buster
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
......
......@@ -24,35 +24,32 @@ class TestDefaultController(BaseTestCase):
"""
try:
id_example = self.upload_file('https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
# id_example = self.upload_file('https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/application_example_planed.yaml')
# doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/application_example_provisioned.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/glusterFS.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/kubernetes.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/topology.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
except Exception as e:
self.assertTrue(False)
id_example = self.upload_file('https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/TIC.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
# id_example = self.upload_file('https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/application_example_planed.yaml')
# doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/application_example_provisioned.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/glusterFS.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/kubernetes.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/lifeWatch_vre1.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
id_example = self.upload_file(
'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/topology.yaml')
doc_id = int(id_example)
self.assertIsInstance(doc_id,int)
def test_get_all_ancestor_properties(self):
......
import os
import tempfile
from unittest import TestCase
import requests
from six import BytesIO
from werkzeug.datastructures import FileStorage
import logging
......@@ -15,16 +18,18 @@ formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(messag
h.setFormatter(formatter)
logger.addHandler(h)
logger.handler_set = True
base_url = 'https://raw.githubusercontent.com/QCDIS/sdia-tosca/master/examples/'
class Test(TestCase):
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']
'kubernetes.yaml','application_example_planed.yaml','TIC.yaml']
for file_name in file_names:
logger.info("Testing : " + str(file_name))
doc_id = tosca_template_service.save(self.upload_file(file_name))
doc_id = tosca_template_service.save(self.upload_file(base_url+file_name))
logger.info("doc_id : " + str(doc_id))
self.assertTrue (doc_id >= 0)
......@@ -39,7 +44,7 @@ class Test(TestCase):
def test_get_tosca_template_model_by_id(self):
doc_id = tosca_template_service.save(self.upload_file('application_example_updated.yaml'))
doc_id = tosca_template_service.save(self.upload_file(base_url+'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)
......@@ -47,17 +52,12 @@ class Test(TestCase):
self.assertIsNotNone(tosca_template_model.topology_template)
self.assertIsNotNone(tosca_template_model.topology_template.node_templates)
def upload_file(self, file_name):
tosca_path = "../../../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
if not os.path.exists(input_tosca_file_path):
tosca_path = "../TOSCA/"
input_tosca_file_path = tosca_path + '/' + file_name
def upload_file(self, url):
input_tosca_file_path = self.get_remote_tosca_file(url)
dir_path = os.path.dirname(os.path.realpath(__file__))
self.assertEqual(True, os.path.exists(input_tosca_file_path),
'Starting from: ' + dir_path + ' Input TOSCA file: ' + input_tosca_file_path + ' not found')
file = open(input_tosca_file_path, "r")
# with open(input_tosca_file_path, 'r') as file:
# contents = file.read()
......@@ -71,3 +71,10 @@ class Test(TestCase):
return FileStorage(stream=BytesIO(byte_contents), filename=input_tosca_file_path, name=input_tosca_file_path,
content_type=None,
content_length=None, headers=None)
def get_remote_tosca_file(self, url):
tosca = requests.get(url)
input_tosca_file_path = os.path.join(tempfile.gettempdir(),'test_tosca_file.yaml')
open( input_tosca_file_path, 'wb').write(tosca.content)
return input_tosca_file_path
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment