# Path: kosek/ImplementationDefinition/NestableDefinition.py
# class NestableDefinition(object):
#     def __init__(self, *args, **kws):
#         pass
# 
#     def validate(self, parameter, path):
#         parameterName = parameter.parameterName
#         path.append(parameterName)
#         self.setDefaults(parameter)
#         print "Validating '%s'" % ('::'.join(path))
#         self._validate(parameter, path)
#         path.pop(-1)
# 
# 
#     def setDefaults(self, parameter):
#         ImplRefDef = {}
#         """
#         actualParameters = set([p.parameterName for p in parameter.parameterList])
#         if isinstance(parameter, ImplRefDef):
#             defaultParameters = set()
#         else:
#             defaultParameters = set([key for key, value in parameter.implDefinition.items() if not isinstance(value, ImplRefDef) and value.default])
#             
#         defaultsNeeded = defaultParameters - actualParameters
#         """
# 
# Path: kosek/ImplementationDefinition/Extras.py
# class Extras(object):
#     NUMBER_RANGE    = 0
#     FLOAT_RANGE     = 1
#     ENUMERATION     = 2
#     ATTRIBUTE_NAME  = 3
#     BOOL_VALUES     = 4
#     DUMMY           = 5
# 
#     def __init__(self, type_, args = {}):
#         self.type_ = type_
#         for k,v in args.items():
#             if k == 'range' and v == False:
#                 pass
#             setattr(self, k, v)
# 
# Path: kosek/ImplementationDefinition/Enumeration.py
# class Enumeration(object):
#     def __init__(self, enumerationList):
#         self._dict = dict([(e.name, e) for e in enumerationList])
#         self._enumerationList = enumerationList
# 
#     def values(self):
#         return self._dict.values()
# 
#     def items(self):
#         return self._dict
# 
#     def __getitem__(self, item):
#         return self._dict[item]
#     
#     def __contains__(self, item):
#         return item in self._dict
#     
#     def __repr__(self):
#         return "ENUMERATION(%s)" % str(self._enumerationList)
# 
# class Enumerator(NestableDefinition):
#     def __init__(self, name, parameters, description):
#         self._dict = dict()
#         self.name = name
#         self.parameters = parameters
# 
#         if self.parameters:
#             self._dict.update(parameters.items())
# 
#         self.description = description
#         super(Enumerator, self).__init__(name = name, parameters = self.parameters, description = description)
# 
#     def __repr__(self):
#         if self.parameters:
#             if self.description:
#                 return "(%s %s) : '%s'" % (self.name, self.parameters, self.description)
#             else:
#                 return "(%s %s)" % (self.name, self.parameters)
#         else:
#             if self.description:
#                 return "(%s) : '%s'" % (self.name, self.description)
#             else:
#                 return "(%s)" % (self.name, )
# 
#     def __getitem__(self, item):
#         return self._dict[item]


import unittest
import sys
from kosek.Logger import Logger
from kosek.ImplementationDefinition.NestableDefinition import NestableDefinition
from kosek.ImplementationDefinition.Extras import Extras
from kosek.ImplementationDefinition.Enumeration import Enumeration, Enumerator

    def tearDown(self):
        del self.extras
        del self.values


class TestAttributeDefinitiom(BaseAttributeDefinition):
    def testSetupInstanceMethodMustBeOverwritten(self):
        self.assertRaises(NotImplementedError, AttributeDefinition, None, None, None, None, None, None)


class TestAttributeDefinitionFactory(BaseAttributeDefinition):
    def testCreateBooleanAttributeDefinition(self):
        self.assertIsInstance(AttributeDefinitionFactory(*self.values), BooleanAttribute )

    def testCreateEnumAttributeDefinition(self):
        enumeration = Enumeration((Enumerator(u'ECC1', None, ''), Enumerator(u'(BCC1', None, ''),
            Enumerator(u'(BCC2', None, ''), Enumerator(u'(ECC2', None, ''))
        )
        extras = Extras(Extras.ENUMERATION, {'enumeration': enumeration})
        values = (ImplAttrType.ENUM, 'CC', False, False, None, '', extras )
        self.assertIsInstance(AttributeDefinitionFactory(*values), EnumAttribute )

    def testCreateUint32AttributeDefinition(self):
        extra = Extras(Extras.NUMBER_RANGE, {'range': True, 'numberFrom': 32, 'numberTo': 128})
        values = (ImplAttrType.UINT32, 'IDLE_TASK_STACK_SIZE', False, False, 48, None, extra)
        self.assertIsInstance(AttributeDefinitionFactory(*values), IntegerAttribute )

    ## TODO:Other integer types!!!
    def testCreateFloatAttributeDefinition(self):

# Path: kosek/ImplementationDefinition/NestableDefinition.py
# class NestableDefinition(object):
#     def __init__(self, *args, **kws):
#         pass
# 
#     def validate(self, parameter, path):
#         parameterName = parameter.parameterName
#         path.append(parameterName)
#         self.setDefaults(parameter)
#         print "Validating '%s'" % ('::'.join(path))
#         self._validate(parameter, path)
#         path.pop(-1)
# 
# 
#     def setDefaults(self, parameter):
#         ImplRefDef = {}
#         """
#         actualParameters = set([p.parameterName for p in parameter.parameterList])
#         if isinstance(parameter, ImplRefDef):
#             defaultParameters = set()
#         else:
#             defaultParameters = set([key for key, value in parameter.implDefinition.items() if not isinstance(value, ImplRefDef) and value.default])
#             
#         defaultsNeeded = defaultParameters - actualParameters
#         """
# 
# Path: kosek/ImplementationDefinition/Extras.py
# class Extras(object):
#     NUMBER_RANGE    = 0
#     FLOAT_RANGE     = 1
#     ENUMERATION     = 2
#     ATTRIBUTE_NAME  = 3
#     BOOL_VALUES     = 4
#     DUMMY           = 5
# 
#     def __init__(self, type_, args = {}):
#         self.type_ = type_
#         for k,v in args.items():
#             if k == 'range' and v == False:
#                 pass
#             setattr(self, k, v)
# 
# Path: kosek/ImplementationDefinition/Enumeration.py
# class Enumeration(object):
#     def __init__(self, enumerationList):
#         self._dict = dict([(e.name, e) for e in enumerationList])
#         self._enumerationList = enumerationList
# 
#     def values(self):
#         return self._dict.values()
# 
#     def items(self):
#         return self._dict
# 
#     def __getitem__(self, item):
#         return self._dict[item]
#     
#     def __contains__(self, item):
#         return item in self._dict
#     
#     def __repr__(self):
#         return "ENUMERATION(%s)" % str(self._enumerationList)
# 
# class Enumerator(NestableDefinition):
#     def __init__(self, name, parameters, description):
#         self._dict = dict()
#         self.name = name
#         self.parameters = parameters
# 
#         if self.parameters:
#             self._dict.update(parameters.items())
# 
#         self.description = description
#         super(Enumerator, self).__init__(name = name, parameters = self.parameters, description = description)
# 
#     def __repr__(self):
#         if self.parameters:
#             if self.description:
#                 return "(%s %s) : '%s'" % (self.name, self.parameters, self.description)
#             else:
#                 return "(%s %s)" % (self.name, self.parameters)
#         else:
#             if self.description:
#                 return "(%s) : '%s'" % (self.name, self.description)
#             else:
#                 return "(%s)" % (self.name, )
# 
#     def __getitem__(self, item):
#         return self._dict[item]


# Path: kosek/ImplementationDefinition/AttributeDefinitions.py
import unittest
import sys
from kosek.Logger import Logger
from kosek.ImplementationDefinition.NestableDefinition import NestableDefinition
from kosek.ImplementationDefinition.Extras import Extras
from kosek.ImplementationDefinition.Enumeration import Enumeration, Enumerator


    def tearDown(self):
        del self.extras
        del self.values


class TestAttributeDefinitiom(BaseAttributeDefinition):
    def testSetupInstanceMethodMustBeOverwritten(self):
        self.assertRaises(NotImplementedError, AttributeDefinition, None, None, None, None, None, None)


class TestAttributeDefinitionFactory(BaseAttributeDefinition):
    def testCreateBooleanAttributeDefinition(self):
        self.assertIsInstance(AttributeDefinitionFactory(*self.values), BooleanAttribute )

    def testCreateEnumAttributeDefinition(self):
        enumeration = Enumeration((Enumerator(u'ECC1', None, ''), Enumerator(u'(BCC1', None, ''),
            Enumerator(u'(BCC2', None, ''), Enumerator(u'(ECC2', None, ''))
        )
        extras = Extras(Extras.ENUMERATION, {'enumeration': enumeration})
        values = (ImplAttrType.ENUM, 'CC', False, False, None, '', extras )
        self.assertIsInstance(AttributeDefinitionFactory(*values), EnumAttribute )

    def testCreateUint32AttributeDefinition(self):
        extra = Extras(Extras.NUMBER_RANGE, {'range': True, 'numberFrom': 32, 'numberTo': 128})
        values = (ImplAttrType.UINT32, 'IDLE_TASK_STACK_SIZE', False, False, 48, None, extra)
        self.assertIsInstance(AttributeDefinitionFactory(*values), IntegerAttribute )

    ## TODO:Other integer types!!!
    def testCreateFloatAttributeDefinition(self):

        extra = Extras(Extras.FLOAT_RANGE, {'range': True, 'numberFrom': 32, 'numberTo': 128})