def test_reflect_instance_creates_configured_callback(self):
        def MyClass():
            return 'socks'

        config_manager = ConfigManager()
        config_manager['box_implementation'] = {'cat_type': MyClass}
        instance = config_manager.reflect_instance('box', 'cat', lambda: None)
        self.assertEqual('socks', instance)
 def test_reflect_instance_creates_configured_callback_with_string_type(
         self):
     config_manager = ConfigManager()
     config_manager['box_implementation'] = {
         'cat_type': 'str',
         'constructor_arguments': ['socks']
     }
     instance = config_manager.reflect_instance('box', 'cat', lambda: None)
     self.assertEqual('socks', instance)
    def test_reflect_instance_creates_configured_callback_with_different_type(
            self):
        def MyClass():
            return 'shorts'

        config_manager = ConfigManager()
        config_manager['cup_implementation'] = {'mouse_type': MyClass}
        instance = config_manager.reflect_instance('cup', 'mouse',
                                                   lambda: None)
        self.assertEqual('shorts', instance)
    def test_reflect_instance_creates_configured_callback_with_arguments(self):
        def MyClass(first, second):
            return '{}.{}'.format(first, second)

        config_manager = ConfigManager()
        config_manager['box_implementation'] = {
            'cat_type': MyClass,
            'constructor_arguments': ['hello', 'pippin']
        }
        instance = config_manager.reflect_instance('box', 'cat', lambda: None)
        self.assertEqual('hello.pippin', instance)
    def test_reflect_instance_creates_configured_callback_with_different_keyword_arguments(
            self):
        def MyClass(first, second):
            return '{} {}'.format(first, second)

        config_manager = ConfigManager()
        config_manager['box_implementation'] = {
            'cat_type': MyClass,
            'constructor_keyword_arguments': {
                'first': 'i am not',
                'second': 'a good potato'
            }
        }
        instance = config_manager.reflect_instance('box', 'cat', lambda: None)
        self.assertEqual('i am not a good potato', instance)
 def test_reflect_instance_creates_default_implementation_different_default(
         self):
     config_manager = ConfigManager()
     instance = config_manager.reflect_instance('box', 'cat',
                                                lambda: 'socks')
     self.assertEqual('socks', instance)
 def test_reflect_instance_creates_default_implementation(self):
     config_manager = ConfigManager()
     instance = config_manager.reflect_instance('potato', 'tomato',
                                                lambda: 'carrot')
     self.assertEqual('carrot', instance)