Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
CONF
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UvA
CONF
Commits
b8385753
Commit
b8385753
authored
Jun 04, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added test in dockerfile
parent
92b97dff
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
40 deletions
+44
-40
Dockerfile
sure_tosca-flask-server/Dockerfile
+1
-1
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+26
-29
test_tosca_template_service.py
...ask-server/sure_tosca/test/test_tosca_template_service.py
+17
-10
No files found.
sure_tosca-flask-server/Dockerfile
View file @
b8385753
FROM
python:3.
7
-buster
FROM
python:3.
6
-buster
RUN
mkdir
-p
/usr/src/app
WORKDIR
/usr/src/app
...
...
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
View file @
b8385753
...
...
@@ -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
):
...
...
sure_tosca-flask-server/sure_tosca/test/test_tosca_template_service.py
View file @
b8385753
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment