# 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
    def test_not_eq_operation(self):
        instance = UMLObject()
        other = UMLObject()
        (o1, o2) = (Mock(), Mock())
        instance.add_operation(o1)
        instance.add_operation(o2)

        self.assertNotEqual(instance, other)

    def test_eq_operation(self):
        instance = UMLObject()
        other = UMLObject()
        o1 = MagicMock()
        o1.__eq__.return_value = True
        o2 = MagicMock()
        o2.__eq__.return_value = True
        instance.add_operation(o1)
        other.add_operation(o2)

        self.assertEqual(instance, other)

    def test_operation(self):
        instance = UMLObject()
        operation = Mock()
        instance.add_operation(operation)
        result = instance.operations()[0]

        self.assertEquals(result, operation)

    def test_attribute(self):

# 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

    def test_not_eq_operation(self):
        instance = UMLObject()
        other = UMLObject()
        (o1, o2) = (Mock(), Mock())
        instance.add_operation(o1)
        instance.add_operation(o2)

        self.assertNotEqual(instance, other)

    def test_eq_operation(self):
        instance = UMLObject()
        other = UMLObject()
        o1 = MagicMock()
        o1.__eq__.return_value = True
        o2 = MagicMock()
        o2.__eq__.return_value = True
        instance.add_operation(o1)
        other.add_operation(o2)

        self.assertEqual(instance, other)

    def test_operation(self):
        instance = UMLObject()
        operation = Mock()
        instance.add_operation(operation)
        result = instance.operations()[0]

        self.assertEquals(result, operation)

    def test_attribute(self):

        instance = UMLObject()