# Path: hyperengine/base/named_dict.py
# class NamedDict(object):
#   def __init__(self, input):
#     for k, v in input.items():
#       if isinstance(v, (list, tuple)):
#         setattr(self, k, [NamedDict(x) if isinstance(x, dict) else x for x in v])
#       else:
#         setattr(self, k, NamedDict(v) if isinstance(v, dict) else v)
# 
#   def keys(self):
#     return self.__dict__.keys()
# 
#   def items(self):
#     return self.__dict__.items()
# 
#   def values(self):
#     return self.__dict__.values()
# 
#   def get(self, key, default=None):
#     return self.__dict__.get(key, default)
# 
#   def __getitem__(self, key):
#     return self.__dict__[key]
# 
#   def __getattribute__(self, key):
#     if (key in ['get', 'keys', 'items', 'values']) or (key.startswith('__') and key.endswith('__')):
#       return object.__getattribute__(self, key)
#     return self.__dict__.get(key, None)
# 
#   def __contains__(self, key):
#     return key in self.__dict__
# 
#   def __repr__(self):
#     return smart_str(self.__dict__)


import six
import unittest
import numpy as np
import hyperengine as hype
from hyperengine.base import NamedDict
#! /usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'maxim'






class NamedDictTest(unittest.TestCase):
  def test_embedded_dict(self):
    spec = hype.spec.new({
      'foo': {
        'bar': {
          'baz': 999
        },
        'baz': []
      }
    })

    instance = self._instantiate(spec)
    self.assertEqual(repr(instance), "{'foo': {'bar': {'baz': 999}, 'baz': []}}")
    six.assertCountEqual(self, instance.foo.keys(), ['bar', 'baz'])

    self.assertTrue('foo' in instance)
    self.assertTrue('bar' in instance.foo)
    self.assertTrue('baz' in instance.foo.bar)


# Path: hyperengine/base/named_dict.py
# class NamedDict(object):
#   def __init__(self, input):
#     for k, v in input.items():
#       if isinstance(v, (list, tuple)):
#         setattr(self, k, [NamedDict(x) if isinstance(x, dict) else x for x in v])
#       else:
#         setattr(self, k, NamedDict(v) if isinstance(v, dict) else v)
# 
#   def keys(self):
#     return self.__dict__.keys()
# 
#   def items(self):
#     return self.__dict__.items()
# 
#   def values(self):
#     return self.__dict__.values()
# 
#   def get(self, key, default=None):
#     return self.__dict__.get(key, default)
# 
#   def __getitem__(self, key):
#     return self.__dict__[key]
# 
#   def __getattribute__(self, key):
#     if (key in ['get', 'keys', 'items', 'values']) or (key.startswith('__') and key.endswith('__')):
#       return object.__getattribute__(self, key)
#     return self.__dict__.get(key, None)
# 
#   def __contains__(self, key):
#     return key in self.__dict__
# 
#   def __repr__(self):
#     return smart_str(self.__dict__)


# Path: hyperengine/tests/named_dict_test.py
import six
import unittest
import numpy as np
import hyperengine as hype
from hyperengine.base import NamedDict

#! /usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'maxim'






class NamedDictTest(unittest.TestCase):
  def test_embedded_dict(self):
    spec = hype.spec.new({
      'foo': {
        'bar': {
          'baz': 999
        },
        'baz': []
      }
    })

    instance = self._instantiate(spec)
    self.assertEqual(repr(instance), "{'foo': {'bar': {'baz': 999}, 'baz': []}}")
    six.assertCountEqual(self, instance.foo.keys(), ['bar', 'baz'])

    self.assertTrue('foo' in instance)
    self.assertTrue('bar' in instance.foo)
    self.assertTrue('baz' in instance.foo.bar)


    self.assertEqual(type(instance), NamedDict)