当前位置: 首页>>代码示例>>Python>>正文


Python dispatchstate.DispatchState类代码示例

本文整理汇总了Python中crank.dispatchstate.DispatchState的典型用法代码示例。如果您正苦于以下问题:Python DispatchState类的具体用法?Python DispatchState怎么用?Python DispatchState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了DispatchState类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_one

 def test_get_one(self):
     req = MockRequest('/asdf')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.method.__name__ == 'get_one'
     assert state.params == {}, state.params
     assert state.remainder == ['asdf'], state.remainder
开发者ID:TurboGears,项目名称:crank,代码行数:7,代码来源:test_restdispatcher.py

示例2: test_path_translation_args_skipped

 def test_path_translation_args_skipped(self):
     req = MockRequest('/with.args/para.meter1/para.meter2.json')
     state = DispatchState(req, mock_dispatcher_with_no_default_or_index, path_translator=True)
     state = state.resolve()
     assert state.method.__name__ == 'with_args', state.method
     assert 'para.meter1' in state.remainder, state.remainder
     assert 'para.meter2' in state.remainder, state.remainder
开发者ID:wegotpop,项目名称:crank,代码行数:7,代码来源:test_objectdispatcher.py

示例3: test_delete_hacky

 def test_delete_hacky(self):
     req = MockRequest('/asdf/sub', params={'_method':'delete'}, method='post')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.method.__name__ == 'post_delete', state.method
     assert state.controller.__class__.__name__ == 'MockDispatcher', state.controller
     assert state.params == {}, state.params
开发者ID:TurboGears,项目名称:crank,代码行数:7,代码来源:test_restdispatcher.py

示例4: test_rest_security_check_only_once

 def test_rest_security_check_only_once(self):
     req = MockRequest('/rest/25')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.controller.__class__.__name__ == 'rest', state.controller
     assert state.method.__name__ == 'get', state.method
     assert len(self.security_tracing) == 1, self.security_tracing
开发者ID:TurboGears,项目名称:crank,代码行数:7,代码来源:test_restdispatcher.py

示例5: test_controller_method_with_args_missing_args_index_disabled

    def test_controller_method_with_args_missing_args_index_disabled(self):
        req = MockRequest('/with_args/a')
        state = DispatchState(req, mock_dispatcher_with_index_with_argvars)

        try:
            mock_dispatcher_with_index_with_argvars._use_index_fallback = False
            state = state.resolve()
        finally:
            mock_dispatcher_with_index_with_argvars._use_index_fallback = True
开发者ID:wegotpop,项目名称:crank,代码行数:9,代码来源:test_objectdispatcher.py

示例6: test_path_translation_sub_controller

    def test_path_translation_sub_controller(self):
        req = MockRequest('/sub.child/with.args/para.meter1/para.meter2.json')
        state = DispatchState(req, mock_dispatcher_with_no_default, path_translator=True)
        state = state.resolve()

        path_pieces = [piece[0] for piece in state.controller_path]
        assert 'sub_child' in path_pieces
        assert state.method.__name__ == 'with_args', state.method
        assert 'para.meter1' in state.remainder, state.remainder
        assert 'para.meter2' in state.remainder, state.remainder
开发者ID:wegotpop,项目名称:crank,代码行数:10,代码来源:test_objectdispatcher.py

示例7: test_call_twice

    def test_call_twice(self):
        req = MockRequest('/')
        state = DispatchState(req, self.dispatcher)
        state = state.resolve()

        try:
            state = state.resolve()
        except RuntimeError:
            assert state.method.__name__ == 'index', state.method
        else:
            assert False, 'Should have raised RuntimeError'
开发者ID:wegotpop,项目名称:crank,代码行数:11,代码来源:test_objectdispatcher.py

示例8: test_sub_dispatcher_override_dispatch

 def test_sub_dispatcher_override_dispatch(self):
     req = MockRequest('/override_dispatch', params={'a':1})
     state = DispatchState(req, self.dispatcher) 
     state = state.resolve()
     assert state.method.__name__ == 'wacky', state.method
开发者ID:wegotpop,项目名称:crank,代码行数:5,代码来源:test_objectdispatcher.py

示例9: test_sub_dispatcher_bad_remainder_call_parent_default

 def test_sub_dispatcher_bad_remainder_call_parent_default(self):
     req = MockRequest('/sub/a')
     state = DispatchState(req, self.dispatcher) 
     state = state.resolve()
     assert state.method.__name__ == '_default', state.method
开发者ID:wegotpop,项目名称:crank,代码行数:5,代码来源:test_objectdispatcher.py

示例10: test_sub_dispatcher_bad_params_call_parent_default

 def test_sub_dispatcher_bad_params_call_parent_default(self):
     req = MockRequest('/sub', params={'a':1})
     state = DispatchState(req, self.dispatcher) 
     state = state.resolve()
     assert state.method.__name__ == '_default', state.method
开发者ID:wegotpop,项目名称:crank,代码行数:5,代码来源:test_objectdispatcher.py

示例11: test_rest_with_lookup

 def test_rest_with_lookup(self):
     req = MockRequest('/rest/somethingelse/method')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.controller.__class__.__name__ == 'sub', state.controller
     assert state.method.__name__ == 'method', state.method
开发者ID:TurboGears,项目名称:crank,代码行数:6,代码来源:test_restdispatcher.py

示例12: test_sub_dispatcher

 def test_sub_dispatcher(self):
     req = MockRequest('/sub')
     state = DispatchState(req, self.dispatcher) 
     state = state.resolve()
     assert state.method.__name__ == 'index', state.method
     assert state.controller.__class__.__name__ == 'MockSubDispatcher', state.controller
开发者ID:wegotpop,项目名称:crank,代码行数:6,代码来源:test_objectdispatcher.py

示例13: test_path_translation_no_extension

 def test_path_translation_no_extension(self):
     req = MockRequest('/no.args')
     state = DispatchState(req, mock_dispatcher_with_no_default_or_index,
                           strip_extension=False, path_translator=True)
     state = state.resolve()
     assert state.method.__name__ == 'no_args', state.method
开发者ID:wegotpop,项目名称:crank,代码行数:6,代码来源:test_objectdispatcher.py

示例14: test_post_hacky

 def test_post_hacky(self):
     req = MockRequest('/', params={'_method':'custom'}, method='post')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.method.__name__ == 'post_custom', state.method
开发者ID:TurboGears,项目名称:crank,代码行数:5,代码来源:test_restdispatcher.py

示例15: test_get_url

 def test_get_url(self):
     req = MockRequest('/sub', params={'_method':'custom'}, method='get')
     state = DispatchState(req, self.dispatcher)
     state = state.resolve()
     assert state.method.__name__ == 'get_custom', state.method
开发者ID:TurboGears,项目名称:crank,代码行数:5,代码来源:test_restdispatcher.py


注:本文中的crank.dispatchstate.DispatchState类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。