本文整理匯總了Python中reverser.RSRReverser類的典型用法代碼示例。如果您正苦於以下問題:Python RSRReverser類的具體用法?Python RSRReverser怎麽用?Python RSRReverser使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了RSRReverser類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rsrreverser_reverse_some_params_and_options
def test_rsrreverser_reverse_some_params_and_options():
reverser = RSRReverser('/test[/{param1}]/{param2}[/{param3}]/{param4}')
params = {
'param2': 'some',
'param3': 'options',
}
reverser.reverse(params)
示例2: test_rsrreverser_prune_options_some
def test_rsrreverser_prune_options_some():
reverser = RSRReverser('/test[/{option1}][/{option2}][/{option3}]')
params = {
'option2': 'some',
}
pruned_route = '/test/{option2}'
assert reverser.prune_options(params) == pruned_route
示例3: test_rsrreverser_substitute_parameters_some_params
def test_rsrreverser_substitute_parameters_some_params():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param2': 'lucky_number_2',
}
sub_route = '/test/{param1}/lucky_number_2/{param3}'
assert reverser.substitute_parameters(params) == sub_route
示例4: test_rsrreverser_reverse_some_params
def test_rsrreverser_reverse_some_params():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': 'epic',
'param2': 'fail',
}
reverser.reverse(params)
示例5: test_rsrreverser_substitute_parameters_custom
def test_rsrreverser_substitute_parameters_custom():
reverser = RSRReverser('/test/{param}/<param>', param_bounds='<>')
params = {
'param': 'fake_out',
}
reversed_url = '/test/{param}/fake_out'
assert reverser.substitute_parameters(params) == reversed_url
示例6: test_rsrreverer_reverse_plain
def test_rsrreverer_reverse_plain():
route = '/test/plain/route'
reverser = RSRReverser(route)
params = {
'param1': 'test',
'param2': 'no_sub',
}
assert reverser.reverse(params) == route
示例7: test_rsrreverser_reverse_some_options
def test_rsrreverser_reverse_some_options():
reverser = RSRReverser('/test[/{param1}][/{param2}][/{param3}]')
params = {
'param2': 'some',
'param3': 'options',
}
reversed_url = '/test/some/options'
assert reverser.reverse(params) == reversed_url
示例8: test_rsrreverser_prune_options_nested_incomplete
def test_rsrreverser_prune_options_nested_incomplete():
reverser = RSRReverser('/test[/{option1}[/{option2}]][/{option3}]')
params = {
'option1': 'incomplete_nest',
'option3': 'prune',
}
pruned_route = '/test/{option1}/{option3}'
assert reverser.prune_options(params) == pruned_route
示例9: test_rsrreverser_prune_options_nested_no_parent
def test_rsrreverser_prune_options_nested_no_parent():
reverser = RSRReverser('/test[/{option1}[/{option2}]][/{option3}]')
params = {
'option2': 'no_parent_nest',
'option3': 'prune',
}
pruned_route = '/test/{option3}'
assert reverser.prune_options(params) == pruned_route
示例10: test_rsrreverser_prune_options_invalid
def test_rsrreverser_prune_options_invalid():
reverser = RSRReverser('/test[/{_o1}][/{o2;}][/{o^3}]')
params = {
'_o1': 'invalid',
'o2;': 'but',
'o^3': 'subs',
}
pruned_route = '/test/{_o1}/{o2;}/{o^3}'
assert reverser.prune_options(params) == pruned_route
示例11: test_rsrreverser_reverse_invalid_option
def test_rsrreverser_reverse_invalid_option():
reverser = RSRReverser('/test[/{_p1}][/{p2;}][/{p^3}]')
params = {
'_p1': 'invalid',
'p2;': 'but',
'p^3': 'subs'
}
reversed_url = '/test/invalid/but/subs'
assert reverser.reverse(params) == reversed_url
示例12: test_rsrreverser_reverse_unsafe
def test_rsrreverser_reverse_unsafe():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': '#$%^',
'param2': 'unsafe_',
'param3': ';unsafe'
}
reversed_url = '/test/#$%^/unsafe_/;unsafe'
assert reverser.reverse(params) == reversed_url
示例13: test_rsrreverser_reverse_full_options
def test_rsrreverser_reverse_full_options():
reverser = RSRReverser('/test[/{param1}][/{param2}][/{param3}]')
params = {
'param1': 'options',
'param2': 'are',
'param3': 'fun',
}
reversed_url = '/test/options/are/fun'
assert reverser.reverse(params) == reversed_url
示例14: test_rsrreverser_prune_options_full
def test_rsrreverser_prune_options_full():
reverser = RSRReverser('/test[/{option1}][/{option2}][/{option3}]')
params = {
'option1': 'options',
'option2': 'are',
'option3': 'fun',
}
pruned_route = '/test/{option1}/{option2}/{option3}'
assert reverser.prune_options(params) == pruned_route
示例15: test_rsrreverser_reverse_nested_option_no_parent
def test_rsrreverser_reverse_nested_option_no_parent():
route = '/test[/{param1}[/{param2}]]/sep[/{param3}[/{param4}]]'
reverser = RSRReverser(route)
params = {
'param2': 'some',
'param4': 'nested_options',
}
reversed_url = '/test/sep'
assert reverser.reverse(params) == reversed_url