def call(url, request, get_session_func): action_name, parameter_list = url_parser.parse(url) action = actions_definition.select(action_name) if action['protected']: session = get_session_func(parameter_list[0]) if session is None: raise AuthException parameters = url_parser.parse_parameters(action['parameters'], parameter_list[1:]) parameters['session'] = session else: parameters = url_parser.parse_parameters(action['parameters'], parameter_list) parameters['request'] = request return action_manager.run_action(action_name, parameters)
def test_parse(): action, parameters = url_parser.parse('example.com/test_func/value') assert action == 'test_func' assert parameters == ['value']