Exemplo n.º 1
0
    def test_initialize_config(self, _initialize_config):
        config = {
            'mycomponent': {
                '__factory__': 'palladium.tests.test_util.MyDummyComponent',
                'arg1': 3,
                'arg2': {
                    'no': 'factory'
                },
                'subcomponent': {
                    '__factory__':
                    'palladium.tests.test_util.MyDummyComponent',
                    'arg1': {
                        'subsubcomponent': {
                            '__factory__':
                            'palladium.tests.test_util.MyDummyComponent',
                            'arg1': 'wobwob',
                            'arg2': 9,
                        },
                    },
                    'arg2': 6,
                },
            },
            'mylistofcomponents': [
                {
                    '__factory__':
                    'palladium.tests.test_util.MyDummyComponent',
                    'arg1': 'wobwob',
                },
                'somethingelse',
            ],
            'myconstant':
            42,
        }

        config = _initialize_config(config)
        assert config['myconstant'] == 42

        mycomponent = config['mycomponent']
        assert isinstance(mycomponent, MyDummyComponent)
        assert mycomponent.arg1 == 3
        assert mycomponent.arg2 == {'no': 'factory'}
        assert mycomponent.initialize_component_arg is config

        subcomponent = mycomponent.subcomponent
        assert isinstance(subcomponent, MyDummyComponent)
        assert subcomponent.arg2 == 6
        assert subcomponent.initialize_component_arg is config

        subsubcomponent = subcomponent.arg1['subsubcomponent']
        assert isinstance(subsubcomponent, MyDummyComponent)
        assert subsubcomponent.arg1 == 'wobwob'
        assert subsubcomponent.arg2 == 9
        assert subsubcomponent.initialize_component_arg is config

        mylistofcomponents = config['mylistofcomponents']
        assert len(mylistofcomponents) == 2
        assert isinstance(mylistofcomponents[0], MyDummyComponent)
        assert mylistofcomponents[0].arg1 == 'wobwob'
        assert mylistofcomponents[1] == 'somethingelse'
Exemplo n.º 2
0
    def test_initialize_config(self, _initialize_config):
        config = {
            'mycomponent': {
                '__factory__': 'palladium.tests.test_util.MyDummyComponent',
                'arg1': 3,
                'arg2': {'no': 'factory'},
                'subcomponent': {
                    '__factory__': 'palladium.tests.test_util.MyDummyComponent',
                    'arg1': {
                        'subsubcomponent': {
                            '__factory__':
                            'palladium.tests.test_util.MyDummyComponent',
                            'arg1': 'wobwob',
                            'arg2': 9,
                            },
                        },
                    'arg2': 6,
                    },
                },
            'mylistofcomponents': [{
                '__factory__': 'palladium.tests.test_util.MyDummyComponent',
                'arg1': 'wobwob',
                },
                'somethingelse',
                ],
            'myconstant': 42,
            }

        config = _initialize_config(config)
        assert config['myconstant'] == 42

        mycomponent = config['mycomponent']
        assert isinstance(mycomponent, MyDummyComponent)
        assert mycomponent.arg1 == 3
        assert mycomponent.arg2 == {'no': 'factory'}
        assert mycomponent.initialize_component_arg is config

        subcomponent = mycomponent.subcomponent
        assert isinstance(subcomponent, MyDummyComponent)
        assert subcomponent.arg2 == 6
        assert subcomponent.initialize_component_arg is config

        subsubcomponent = subcomponent.arg1['subsubcomponent']
        assert isinstance(subsubcomponent, MyDummyComponent)
        assert subsubcomponent.arg1 == 'wobwob'
        assert subsubcomponent.arg2 == 9
        assert subsubcomponent.initialize_component_arg is config

        mylistofcomponents = config['mylistofcomponents']
        assert len(mylistofcomponents) == 2
        assert isinstance(mylistofcomponents[0], MyDummyComponent)
        assert mylistofcomponents[0].arg1 == 'wobwob'
        assert mylistofcomponents[1] == 'somethingelse'
Exemplo n.º 3
0
 def test_initialize_config_logging(self, _initialize_config):
     with patch('palladium.util.dictConfig') as dictConfig:
         _initialize_config({'logging': 'yes, please'})
         dictConfig.assert_called_with('yes, please')
Exemplo n.º 4
0
 def test_initialize_config_logging(self, _initialize_config):
     with patch('palladium.util.dictConfig') as dictConfig:
         _initialize_config({'logging': 'yes, please'})
         dictConfig.assert_called_with('yes, please')