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
37402bdf
Commit
37402bdf
authored
May 12, 2020
by
Spiros Koulouzis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
this deserialize_model error keeps happening no idea why
parent
0d49ba8c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
18 additions
and
11 deletions
+18
-11
tosca_helper.py
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
+4
-4
test_default_controller.py
...a-flask-server/sure_tosca/test/test_default_controller.py
+4
-4
util.py
sure_tosca-flask-server/sure_tosca/util.py
+10
-3
No files found.
sure_tosca-flask-server/sure_tosca/service/tosca_helper.py
View file @
37402bdf
...
@@ -115,8 +115,8 @@ def node_dict_2_node_template(node_name, node_dict, all_custom_def):
...
@@ -115,8 +115,8 @@ def node_dict_2_node_template(node_name, node_dict, all_custom_def):
# node_dict[node_name].pop(name_to_remove)
# node_dict[node_name].pop(name_to_remove)
node_template
=
NodeTemplate
(
node_name
,
node_templates
=
copy
.
deepcopy
(
node_dict
),
custom_def
=
all_custom_def
)
node_template
=
NodeTemplate
(
node_name
,
node_templates
=
copy
.
deepcopy
(
node_dict
),
custom_def
=
all_custom_def
)
# For some reason the tosca.nodes.
ARTICONF
.Orchestrator doesn't have all definitions so we need to add them
# For some reason the tosca.nodes.
QC
.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.
ARTICONF
.Orchestrator"
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.
QC
.Orchestrator"
# is not a valid type.'
# is not a valid type.'
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
for
def_key
in
all_custom_def
:
for
def_key
in
all_custom_def
:
...
@@ -144,8 +144,8 @@ def node_type_2_node_template(node_type, all_custom_def):
...
@@ -144,8 +144,8 @@ def node_type_2_node_template(node_type, all_custom_def):
node_type
[
next
(
iter
(
node_type
))]
.
pop
(
'type'
)
node_type
[
next
(
iter
(
node_type
))]
.
pop
(
'type'
)
node_template
=
NodeTemplate
(
name
,
node_template_dict
,
node_type
)
node_template
=
NodeTemplate
(
name
,
node_template_dict
,
node_type
)
# For some reason the tosca.nodes.
ARTICONF
.Orchestrator doesn't have all definitions so we need to add them
# For some reason the tosca.nodes.
QC
.Orchestrator doesn't have all definitions so we need to add them
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.
ARTICONF
.Orchestrator"
# manually. We get 'toscaparser.common.exception.InvalidTypeError: Type "tosca.nodes.
QC
.Orchestrator"
# is not a valid type.'
# is not a valid type.'
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
if
len
(
node_template
.
custom_def
)
<
len
(
all_custom_def
):
for
def_key
in
all_custom_def
:
for
def_key
in
all_custom_def
:
...
...
sure_tosca-flask-server/sure_tosca/test/test_default_controller.py
View file @
37402bdf
...
@@ -169,7 +169,7 @@ class TestDefaultController(BaseTestCase):
...
@@ -169,7 +169,7 @@ class TestDefaultController(BaseTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIsInstance
(
response
.
json
,
list
)
self
.
assertIsInstance
(
response
.
json
,
list
)
query_string
=
[(
'type_name'
,
'tosca.nodes.
ARTICONF
.Container.Application.Docker'
),
query_string
=
[(
'type_name'
,
'tosca.nodes.
QC
.Container.Application.Docker'
),
(
'node_name'
,
None
),
(
'node_name'
,
None
),
(
'has_interfaces'
,
None
),
(
'has_interfaces'
,
None
),
(
'has_properties'
,
None
),
(
'has_properties'
,
None
),
...
@@ -185,7 +185,7 @@ class TestDefaultController(BaseTestCase):
...
@@ -185,7 +185,7 @@ class TestDefaultController(BaseTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertIsInstance
(
response
.
json
,
list
)
self
.
assertIsInstance
(
response
.
json
,
list
)
query_string
=
[(
'type_name'
,
'tosca.nodes.
ARTICONF
.Application'
),
query_string
=
[(
'type_name'
,
'tosca.nodes.
QC
.Application'
),
(
'node_name'
,
None
),
(
'node_name'
,
None
),
(
'has_interfaces'
,
True
),
(
'has_interfaces'
,
True
),
(
'has_properties'
,
None
),
(
'has_properties'
,
None
),
...
@@ -298,7 +298,7 @@ class TestDefaultController(BaseTestCase):
...
@@ -298,7 +298,7 @@ class TestDefaultController(BaseTestCase):
self
.
assertTrue
(
id_example
.
strip
()
.
isdigit
())
self
.
assertTrue
(
id_example
.
strip
()
.
isdigit
())
query_string
=
[(
'kind_of_type'
,
'interface_types'
),
query_string
=
[(
'kind_of_type'
,
'interface_types'
),
(
'has_interfaces'
,
None
),
(
'has_interfaces'
,
None
),
(
'type_name'
,
'tosca.interfaces.
ARTICONF
.CloudsStorm'
),
(
'type_name'
,
'tosca.interfaces.
QC
.CloudsStorm'
),
(
'has_properties'
,
None
),
(
'has_properties'
,
None
),
(
'has_attributes'
,
None
),
(
'has_attributes'
,
None
),
(
'has_requirements'
,
None
),
(
'has_requirements'
,
None
),
...
@@ -376,7 +376,7 @@ class TestDefaultController(BaseTestCase):
...
@@ -376,7 +376,7 @@ class TestDefaultController(BaseTestCase):
(
'operation_name'
,
'provision'
)]
(
'operation_name'
,
'provision'
)]
response
=
self
.
client
.
open
(
response
=
self
.
client
.
open
(
'/tosca-sure/1.0.0/tosca_template/{id}/interface/{interface_type}/default'
.
format
(
id
=
id_example
,
'/tosca-sure/1.0.0/tosca_template/{id}/interface/{interface_type}/default'
.
format
(
id
=
id_example
,
interface_type
=
'tosca.interfaces.
ARTICONF
.CloudsStorm'
),
interface_type
=
'tosca.interfaces.
QC
.CloudsStorm'
),
method
=
'GET'
,
method
=
'GET'
,
query_string
=
query_string
)
query_string
=
query_string
)
self
.
assertTrue
(
response
.
is_json
)
self
.
assertTrue
(
response
.
is_json
)
...
...
sure_tosca-flask-server/sure_tosca/util.py
View file @
37402bdf
...
@@ -23,11 +23,16 @@ def _deserialize(data, klass):
...
@@ -23,11 +23,16 @@ def _deserialize(data, klass):
return
deserialize_date
(
data
)
return
deserialize_date
(
data
)
elif
klass
==
datetime
.
datetime
:
elif
klass
==
datetime
.
datetime
:
return
deserialize_datetime
(
data
)
return
deserialize_datetime
(
data
)
elif
hasattr
(
klass
,
'__origin__'
)
:
elif
type
(
klass
)
==
typing
.
GenericMeta
:
if
klass
.
__
origin
__
==
list
:
if
klass
.
__
extra
__
==
list
:
return
_deserialize_list
(
data
,
klass
.
__args__
[
0
])
return
_deserialize_list
(
data
,
klass
.
__args__
[
0
])
if
klass
.
__
origin
__
==
dict
:
if
klass
.
__
extra
__
==
dict
:
return
_deserialize_dict
(
data
,
klass
.
__args__
[
1
])
return
_deserialize_dict
(
data
,
klass
.
__args__
[
1
])
# elif hasattr(klass, '__origin__'):
# if klass.__origin__ == list:
# return _deserialize_list(data, klass.__args__[0])
# if klass.__origin__ == dict:
# return _deserialize_dict(data, klass.__args__[1])
else
:
else
:
return
deserialize_model
(
data
,
klass
)
return
deserialize_model
(
data
,
klass
)
...
@@ -127,6 +132,8 @@ def deserialize_model(data, klass):
...
@@ -127,6 +132,8 @@ def deserialize_model(data, klass):
return
data
return
data
for
attr
,
attr_type
in
six
.
iteritems
(
instance
.
swagger_types
):
for
attr
,
attr_type
in
six
.
iteritems
(
instance
.
swagger_types
):
# print(attr)
# print(attr_type)
if
data
is
not
None
and
isinstance
(
data
,
(
list
,
dict
)):
if
data
is
not
None
and
isinstance
(
data
,
(
list
,
dict
)):
value
=
None
value
=
None
if
instance
.
attribute_map
[
attr
]
in
data
:
if
instance
.
attribute_map
[
attr
]
in
data
:
...
...
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