Commit 37402bdf authored by Spiros Koulouzis's avatar Spiros Koulouzis

this deserialize_model error keeps happening no idea why

parent 0d49ba8c
...@@ -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:
......
...@@ -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)
......
...@@ -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:
......
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