Commit 11d83af3 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed error with deserialize_model. from_dict was not creating correct model

parent bde03643
...@@ -117,14 +117,22 @@ services: ...@@ -117,14 +117,22 @@ services:
environment: environment:
RABBITMQ_HOST: rabbit RABBITMQ_HOST: rabbit
#provisioner: provisioner:
#depends_on: depends_on:
#- rabbit - rabbit
#- sure-tosca - sure-tosca
#image: alogo53/provisioner:3.0.0 image: alogo53/provisioner:3.0.0
#environment: environment:
#RABBITMQ_HOST: rabbit RABBITMQ_HOST: rabbit
#SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0 SURE_TOSCA_BASE_PATH: http://sure-tosca:8081/tosca-sure/1.0.0
deployer:
depends_on:
- rabbit
- sure-tosca
image: alogo53/deployer:3.0.0
environment:
RABBITMQ_HOST: rabbit
#volumes: #volumes:
......
...@@ -391,7 +391,7 @@ def set_node_properties(id, properties, node_name): # noqa: E501 ...@@ -391,7 +391,7 @@ def set_node_properties(id, properties, node_name): # noqa: E501
if res: if res:
return res return res
return 'Not Found', 404 return 'Not Found', 404
k
def upload_tosca_template(file): # noqa: E501 def upload_tosca_template(file): # noqa: E501
"""upload a tosca template description file """upload a tosca template description file
......
...@@ -294,6 +294,3 @@ def get_node_template_dict(node_template): ...@@ -294,6 +294,3 @@ def get_node_template_dict(node_template):
# print(node_template.templates) # print(node_template.templates)
return node_template_dict return node_template_dict
...@@ -45,6 +45,7 @@ root_key = 'root_key' ...@@ -45,6 +45,7 @@ root_key = 'root_key'
def query_db(queries, db=None): def query_db(queries, db=None):
results = db.all()
if queries: if queries:
query = reduce(lambda a, b: a & b, queries) query = reduce(lambda a, b: a & b, queries)
results = db.search(query) results = db.search(query)
...@@ -221,6 +222,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None, ...@@ -221,6 +222,7 @@ def get_node_templates(id, type_name=None, node_name=None, has_interfaces=None,
prop = None prop = None
queries.append(query.artifacts != prop) queries.append(query.artifacts != prop)
query_results = query_db(queries, db=node_template_db) query_results = query_db(queries, db=node_template_db)
return change_to_node_template_model(query_results) return change_to_node_template_model(query_results)
......
...@@ -30,7 +30,6 @@ class TestDefaultController(BaseTestCase): ...@@ -30,7 +30,6 @@ class TestDefaultController(BaseTestCase):
self.assertTrue(response.is_json) self.assertTrue(response.is_json)
self.assertIsInstance(response.json, list) self.assertIsInstance(response.json, list)
def test_get_all_ancestor_types(self): def test_get_all_ancestor_types(self):
"""Test case for get_all_ancestor_types """Test case for get_all_ancestor_types
......
...@@ -89,7 +89,6 @@ def deserialize_datetime(string): ...@@ -89,7 +89,6 @@ def deserialize_datetime(string):
except ImportError: except ImportError:
return string return string
def deserialize_model(data, klass): def deserialize_model(data, klass):
"""Deserializes list or dict to model. """Deserializes list or dict to model.
...@@ -104,14 +103,39 @@ def deserialize_model(data, klass): ...@@ -104,14 +103,39 @@ 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):
if data is not None \ if data is not None and isinstance(data, (list, dict)):
and instance.attribute_map[attr] in data \ value = None
and isinstance(data, (list, dict)): if instance.attribute_map[attr] in data:
value = data[instance.attribute_map[attr]] value = data[instance.attribute_map[attr]]
elif attr in data:
value = data[attr]
setattr(instance, attr, _deserialize(value, attr_type)) setattr(instance, attr, _deserialize(value, attr_type))
return instance return instance
# def deserialize_model(data, klass):
# """Deserializes list or dict to model.
#
# :param data: dict, list.
# :type data: dict | list
# :param klass: class literal.
# :return: model object.
# """
# instance = klass()
#
# if not instance.swagger_types:
# return data
#
# for attr, attr_type in six.iteritems(instance.swagger_types):
# if data is not None \
# and instance.attribute_map[attr] in data \
# and isinstance(data, (list, dict)):
# value = data[instance.attribute_map[attr]]
# setattr(instance, attr, _deserialize(value, attr_type))
#
# return instance
def _deserialize_list(data, boxed_type): def _deserialize_list(data, boxed_type):
"""Deserializes a list and its elements. """Deserializes a list and its elements.
......
wheel==0.33.6 wheel==0.34.2
flask-testing==0.7.1 flask-testing==0.8.0
coverage==5.0.3 coverage==5.0.3
nose>=1.3.7 nose>=1.3.7
pluggy>=0.13.1 pluggy>=0.13.1
randomize>=0.14 randomize>=0.14
Werkzeug==0.16.1 Werkzeug==1.0.0
\ No newline at end of file \ No newline at end of file
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