# Path: omelette/compiler/uml.py
# class UMLObject(object):
#     """Class representing UML diagram object."""
# 
#     def __init__(self, parent=None, name=None, is_prototype=False,
#             code_object=None):
#         """
#         Create UMLObject
# 
#         Keyword arguments:
#         parent -- name of UMLObject this object is based upon (default: None)
#         name -- name of this UMLObject (default: None)
#         is_prototype -- prototype objects aren't returned by Compiler.compile
#         method (default: False)
#         """
# 
#         self.__operations = []
#         self.__attributes = []
#         self.properties = {}
# 
#         self.required = {}
#         self.allowed = {}
# 
#         self.type = None
#         self.parent = parent
#         self.name = name
#         self.is_prototype = is_prototype
#         self.code_object = code_object
# 
#     def __setitem__(self, key, value):
#         property = self.properties.get(key)
#         type = property[1] if property else None
# 
#         self.properties[key] = (value, type)
# 
#     def __getitem__(self, key):
#         return self.properties[key][0]
# 
#     def add_operation(self, operation):
#         """Adds an instance of Operation class to objects operations"""
#         self.__operations.append(operation)
# 
#     def add_attribute(self, attribute):
#         """Adds an instance of Attribute class to objects attributes"""
#         self.__attributes.append(attribute)
# 
#     def operations(self):
#         """Returns list of object's operations"""
#         return self.__operations
# 
#     def attributes(self):
#         """Returns list of object's attributes"""
#         return self.__attributes
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __contains__(self, key):
#         return key in self.properties


import unittest
from omelette.compiler.uml import UMLObject
from mock import Mock, MagicMock

class UMLObjectTest(unittest.TestCase):

    def test_constructor(self):
        o = UMLObject("fasada", "asd", True)
        self.assertEquals(o.parent, "fasada")
        self.assertEquals(o.name, "asd")
        self.assertTrue(o.is_prototype)

    def test_eq(self):
        instance = UMLObject("fasada", "asd", True)
        other = UMLObject("fasada", "asd", True)
        instance["a"] = 3
        other["a"] = 3

        self.assertEquals(instance, other)

    def test_not_eq_field(self):
        instance = UMLObject("fasada", "asd", False)
        other = UMLObject("fasada", "asd", True)

        self.assertNotEqual(instance, other)


# Path: omelette/compiler/uml.py
# class UMLObject(object):
#     """Class representing UML diagram object."""
# 
#     def __init__(self, parent=None, name=None, is_prototype=False,
#             code_object=None):
#         """
#         Create UMLObject
# 
#         Keyword arguments:
#         parent -- name of UMLObject this object is based upon (default: None)
#         name -- name of this UMLObject (default: None)
#         is_prototype -- prototype objects aren't returned by Compiler.compile
#         method (default: False)
#         """
# 
#         self.__operations = []
#         self.__attributes = []
#         self.properties = {}
# 
#         self.required = {}
#         self.allowed = {}
# 
#         self.type = None
#         self.parent = parent
#         self.name = name
#         self.is_prototype = is_prototype
#         self.code_object = code_object
# 
#     def __setitem__(self, key, value):
#         property = self.properties.get(key)
#         type = property[1] if property else None
# 
#         self.properties[key] = (value, type)
# 
#     def __getitem__(self, key):
#         return self.properties[key][0]
# 
#     def add_operation(self, operation):
#         """Adds an instance of Operation class to objects operations"""
#         self.__operations.append(operation)
# 
#     def add_attribute(self, attribute):
#         """Adds an instance of Attribute class to objects attributes"""
#         self.__attributes.append(attribute)
# 
#     def operations(self):
#         """Returns list of object's operations"""
#         return self.__operations
# 
#     def attributes(self):
#         """Returns list of object's attributes"""
#         return self.__attributes
# 
#     def __eq__(self, other):
#         return self.__dict__ == other.__dict__
# 
#     def __contains__(self, key):
#         return key in self.properties


# Path: omelette/compiler/test/test_umlobject.py
import unittest
from omelette.compiler.uml import UMLObject
from mock import Mock, MagicMock


class UMLObjectTest(unittest.TestCase):

    def test_constructor(self):
        o = UMLObject("fasada", "asd", True)
        self.assertEquals(o.parent, "fasada")
        self.assertEquals(o.name, "asd")
        self.assertTrue(o.is_prototype)

    def test_eq(self):
        instance = UMLObject("fasada", "asd", True)
        other = UMLObject("fasada", "asd", True)
        instance["a"] = 3
        other["a"] = 3

        self.assertEquals(instance, other)

    def test_not_eq_field(self):
        instance = UMLObject("fasada", "asd", False)
        other = UMLObject("fasada", "asd", True)

        self.assertNotEqual(instance, other)


    def test_not_eq_property(self):