Commit 1a5b5b27 authored by Spiros Koulouzis's avatar Spiros Koulouzis

fixed serialization problem

parent c4e39763
......@@ -64,3 +64,12 @@ class Model(object):
def __ne__(self, other):
"""Returns true if both objects are not equal"""
return not self == other
# def __hash__(self):
# return hash(self.__dict__.keys())
def __key(self):
return tuple(sorted(self.to_dict()))
def __hash__(self):
return hash(self.__key())
\ No newline at end of file
......@@ -15,7 +15,8 @@ class NodeTemplate(Model):
Do not edit the class manually.
"""
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None, type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
def __init__(self, derived_from=None, properties=None, requirements=None, interfaces=None, capabilities=None,
type=None, description=None, directives=None, attributes=None, artifacts=None): # noqa: E501
"""NodeTemplate - a model defined in Swagger
:param derived_from: The derived_from of this NodeTemplate. # noqa: E501
......
......@@ -3,9 +3,9 @@
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from toscaparser.nodetemplate import NodeTemplate
from typing import List, Dict # noqa: F401
from sure_tosca.models import NodeTemplate
from sure_tosca.models.base_model_ import Model
from sure_tosca import util
......@@ -245,3 +245,8 @@ class TopologyTemplate(Model):
"""
self._policies = policies
def __eq__(self, other):
if isinstance(other, TopologyTemplate):
return self.__key() == other.__key()
return NotImplemented
\ No newline at end of file
......@@ -3,9 +3,9 @@
from __future__ import absolute_import
from datetime import date, datetime # noqa: F401
from toscaparser.topology_template import TopologyTemplate
from typing import List, Dict # noqa: F401
from sure_tosca.models import TopologyTemplate
from sure_tosca.models.base_model_ import Model
from sure_tosca import util
......@@ -16,7 +16,11 @@ class ToscaTemplate(Model):
Do not edit the class manually.
"""
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None, topology_template=None, template_author=None, template_version=None, description=None, imports=None, dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None, capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None, group_types=None, repositories=None): # noqa: E501
def __init__(self, tosca_definitions_version=None, tosca_default_namespace=None, template_name=None,
topology_template=None, template_author=None, template_version=None, description=None, imports=None,
dsl_definitions=None, node_types=None, relationship_types=None, relationship_templates=None,
capability_types=None, artifact_types=None, data_types=None, interface_types=None, policy_types=None,
group_types=None, repositories=None): # noqa: E501
"""ToscaTemplate - a model defined in Swagger
:param tosca_definitions_version: The tosca_definitions_version of this ToscaTemplate. # noqa: E501
......@@ -531,3 +535,8 @@ class ToscaTemplate(Model):
"""
self._repositories = repositories
def __eq__(self, other):
if isinstance(other, ToscaTemplate):
return self.__key() == other.__key()
return NotImplemented
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