本文整理匯總了Python中reverser.RSRReverser.substitute_parameters方法的典型用法代碼示例。如果您正苦於以下問題:Python RSRReverser.substitute_parameters方法的具體用法?Python RSRReverser.substitute_parameters怎麽用?Python RSRReverser.substitute_parameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類reverser.RSRReverser
的用法示例。
在下文中一共展示了RSRReverser.substitute_parameters方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_rsrreverser_substitute_parameters_some_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
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
示例2: test_rsrreverser_substitute_parameters_custom
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
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
示例3: test_rsrreverser_substitute_parameters_complex_matching_invalid
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_complex_matching_invalid():
route = '/test/{param1:_digits}/{param2:t&}/{param3:#$*}'
reverser = RSRReverser(route)
params = {
'param1': 'complex',
'param2': 'types',
'param3': 'sub',
}
assert reverser.substitute_parameters(params) == route
示例4: test_rsrreverser_substitute_parameters_superset_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_superset_params():
route = '/test/{param1}/{param2}/{param3}'
reverser = RSRReverser(route)
params = {
'aparam1': 'veni',
'param2s': 'vidi',
'{param3}': 'vici',
}
assert reverser.substitute_parameters(params) == route
示例5: test_rsrreverser_substitute_parameters_url_unsafe
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_url_unsafe():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': '#$%^',
'param2': '{param1[invalid!]}',
'param3': '?q=;',
}
sub_route = '/test/#$%^/{param1[invalid!]}/?q=;'
assert reverser.substitute_parameters(params) == sub_route
示例6: test_rsrreverser_substitute_parameters_simple_matching_invalid
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_simple_matching_invalid():
reverser = RSRReverser('/test/{_p1}/{p2;}/{p^3}')
params = {
'_p1': 'these',
'p2;': 'are',
'p^3': 'invalid_but_match',
}
sub_route = '/test/these/are/invalid_but_match'
assert reverser.substitute_parameters(params) == sub_route
示例7: test_rsrreverser_substitute_parameters_all_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_all_params():
reverser = RSRReverser('/test/{param1}/{param2}/{param3}')
params = {
'param1': 'veni',
'param2': 'vidi',
'param3': 'vici',
}
sub_route = '/test/veni/vidi/vici'
assert reverser.substitute_parameters(params) == sub_route
示例8: test_rsrreverser_substitute_parameters_complex
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_complex():
reverser = RSRReverser('/test/{param1:digits}/{param2:type}/{param3:01}')
params = {
'param1': 'complex',
'param2': 'types',
'param3': 'sub',
}
sub_route = '/test/complex/types/sub'
assert reverser.substitute_parameters(params) == sub_route
示例9: test_rsrreverser_substitute_parameters_all_params_with_options
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_all_params_with_options():
reverser = RSRReverser('/test/{param1}[/{param2}[/{param3}]]')
params = {
'param1': 'tests',
'param2': 'are',
'param3': 'fun',
}
sub_route = '/test/tests[/are[/fun]]'
assert reverser.substitute_parameters(params) == sub_route
示例10: test_rsrreverser_substitute_parameters_url_matches
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_url_matches():
route = '/test/this/case'
reverser = RSRReverser(route)
params = {
'test': '1',
'this': '2',
'case': '3',
}
assert reverser.substitute_parameters(params) == route
示例11: test_rsrreverser_substitute_parameters_no_params
# 需要導入模塊: from reverser import RSRReverser [as 別名]
# 或者: from reverser.RSRReverser import substitute_parameters [as 別名]
def test_rsrreverser_substitute_parameters_no_params():
route = '/test/{param1}/{param2}/{param3}'
reverser = RSRReverser(route)
params = {}
assert reverser.substitute_parameters(params) == route