Ejemplo n.º 1
0
 def test_controller_init(self):
     """init_controller function imports then instantiates a component by its module path."""
     mock_controller_class = MagicMock()
     with patch('controller.helpers.import_controllers', return_value=mock_controller_class) as \
             mock_import_controllers:
         init_controller('test.component.path', 'arg', kwarg='kwarg')
         mock_import_controllers.assert_called_with('test.component.path')
         mock_controller_class.assert_called_with('arg', kwarg='kwarg')
Ejemplo n.º 2
0
 def test_controller_init(self):
     """init_controller function imports then instantiates a component by its module path."""
     mock_controller_class = MagicMock()
     with patch('controller.helpers.import_controllers', return_value=mock_controller_class) as \
             mock_import_controllers:
         init_controller('test.component.path', 'arg', kwarg='kwarg')
         mock_import_controllers.assert_called_with('test.component.path')
         mock_controller_class.assert_called_with('arg', kwarg='kwarg')
Ejemplo n.º 3
0
 def insert_new_controller(self, path, component_name, *args, **kwargs):
     """
     Similar to the insert_controller method, however it takes a component name
     and arguments and will init the controller before inserting it at the given path,
     replacing the existing controller stack with a new stack containing just this
     controller.
     """
     controller = init_controller(component_name, *args, **kwargs)
     self.insert_controller(path, controller)
     return controller