Show More
@@ -23,23 +23,23 b' import pytest' | |||
|
23 | 23 | from rhodecode.apps._base import ADMIN_PREFIX |
|
24 | 24 | from rhodecode.model.db import User |
|
25 | 25 | from rhodecode.tests import ( |
|
26 | TestController, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, | |
|
27 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, assert_session_flash) | |
|
26 | TestController, route_path_generator, assert_session_flash) | |
|
28 | 27 | from rhodecode.tests.fixture import Fixture |
|
29 | 28 | from rhodecode.tests.utils import AssertResponse |
|
30 | 29 | |
|
31 | 30 | fixture = Fixture() |
|
32 | 31 | |
|
33 | 32 | |
|
34 | def route_path(name, **kwargs): | |
|
35 | return { | |
|
33 | def route_path(name, params=None, **kwargs): | |
|
34 | url_defs = { | |
|
36 | 35 | 'my_account_auth_tokens': |
|
37 | 36 | ADMIN_PREFIX + '/my_account/auth_tokens', |
|
38 | 37 | 'my_account_auth_tokens_add': |
|
39 | 38 | ADMIN_PREFIX + '/my_account/auth_tokens/new', |
|
40 | 39 | 'my_account_auth_tokens_delete': |
|
41 | 40 | ADMIN_PREFIX + '/my_account/auth_tokens/delete', |
|
42 | }[name].format(**kwargs) | |
|
41 | } | |
|
42 | return route_path_generator(url_defs, name=name, params=params, **kwargs) | |
|
43 | 43 | |
|
44 | 44 | |
|
45 | 45 | class TestMyAccountAuthTokens(TestController): |
@@ -25,20 +25,20 b' import pytest' | |||
|
25 | 25 | from whoosh import query |
|
26 | 26 | |
|
27 | 27 | from rhodecode.tests import ( |
|
28 | TestController, HG_REPO, | |
|
28 | TestController, route_path_generator, HG_REPO, | |
|
29 | 29 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
30 | 30 | from rhodecode.tests.utils import AssertResponse |
|
31 | 31 | |
|
32 | 32 | |
|
33 | def route_path(name, **kwargs): | |
|
33 | def route_path(name, params=None, **kwargs): | |
|
34 | 34 | from rhodecode.apps._base import ADMIN_PREFIX |
|
35 | return { | |
|
35 | url_defs = { | |
|
36 | 36 | 'search': |
|
37 | 37 | ADMIN_PREFIX + '/search', |
|
38 | 38 | 'search_repo': |
|
39 | 39 | '/{repo_name}/search', |
|
40 | ||
|
41 | }[name].format(**kwargs) | |
|
40 | } | |
|
41 | return route_path_generator(url_defs, name=name, params=params, **kwargs) | |
|
42 | 42 | |
|
43 | 43 | |
|
44 | 44 | class TestSearchController(TestController): |
@@ -33,15 +33,15 b' import pytest' | |||
|
33 | 33 | from rhodecode.model.db import User |
|
34 | 34 | from rhodecode.lib import auth |
|
35 | 35 | from rhodecode.lib import helpers as h |
|
36 |
from rhodecode.lib.helpers import flash |
|
|
36 | from rhodecode.lib.helpers import flash | |
|
37 | 37 | from rhodecode.lib.utils2 import safe_str |
|
38 | 38 | |
|
39 | 39 | |
|
40 | 40 | log = logging.getLogger(__name__) |
|
41 | 41 | |
|
42 | 42 | __all__ = [ |
|
43 | 'get_new_dir', 'TestController', | |
|
44 |
|
|
|
43 | 'get_new_dir', 'TestController', 'route_path_generator', | |
|
44 | 'clear_cache_regions', | |
|
45 | 45 | 'assert_session_flash', 'login_user', 'no_newline_id_generator', |
|
46 | 46 | 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'SVN_REPO', |
|
47 | 47 | 'NEW_HG_REPO', 'NEW_GIT_REPO', |
@@ -243,3 +243,13 b' def no_newline_id_generator(test_name):' | |||
|
243 | 243 | .replace(' ', '_S') |
|
244 | 244 | |
|
245 | 245 | return test_name or 'test-with-empty-name' |
|
246 | ||
|
247 | ||
|
248 | def route_path_generator(url_defs, name, params=None, **kwargs): | |
|
249 | import urllib | |
|
250 | ||
|
251 | base_url = url_defs[name].format(**kwargs) | |
|
252 | ||
|
253 | if params: | |
|
254 | base_url = '{}?{}'.format(base_url, urllib.urlencode(params)) | |
|
255 | return base_url |
General Comments 0
You need to be logged in to leave comments.
Login now