Show More
@@ -23,23 +23,23 b' import pytest' | |||||
23 | from rhodecode.apps._base import ADMIN_PREFIX |
|
23 | from rhodecode.apps._base import ADMIN_PREFIX | |
24 | from rhodecode.model.db import User |
|
24 | from rhodecode.model.db import User | |
25 | from rhodecode.tests import ( |
|
25 | from rhodecode.tests import ( | |
26 | TestController, TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS, |
|
26 | TestController, route_path_generator, assert_session_flash) | |
27 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS, assert_session_flash) |
|
|||
28 | from rhodecode.tests.fixture import Fixture |
|
27 | from rhodecode.tests.fixture import Fixture | |
29 | from rhodecode.tests.utils import AssertResponse |
|
28 | from rhodecode.tests.utils import AssertResponse | |
30 |
|
29 | |||
31 | fixture = Fixture() |
|
30 | fixture = Fixture() | |
32 |
|
31 | |||
33 |
|
32 | |||
34 | def route_path(name, **kwargs): |
|
33 | def route_path(name, params=None, **kwargs): | |
35 | return { |
|
34 | url_defs = { | |
36 | 'my_account_auth_tokens': |
|
35 | 'my_account_auth_tokens': | |
37 | ADMIN_PREFIX + '/my_account/auth_tokens', |
|
36 | ADMIN_PREFIX + '/my_account/auth_tokens', | |
38 | 'my_account_auth_tokens_add': |
|
37 | 'my_account_auth_tokens_add': | |
39 | ADMIN_PREFIX + '/my_account/auth_tokens/new', |
|
38 | ADMIN_PREFIX + '/my_account/auth_tokens/new', | |
40 | 'my_account_auth_tokens_delete': |
|
39 | 'my_account_auth_tokens_delete': | |
41 | ADMIN_PREFIX + '/my_account/auth_tokens/delete', |
|
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 | class TestMyAccountAuthTokens(TestController): |
|
45 | class TestMyAccountAuthTokens(TestController): |
@@ -25,20 +25,20 b' import pytest' | |||||
25 | from whoosh import query |
|
25 | from whoosh import query | |
26 |
|
26 | |||
27 | from rhodecode.tests import ( |
|
27 | from rhodecode.tests import ( | |
28 | TestController, HG_REPO, |
|
28 | TestController, route_path_generator, HG_REPO, | |
29 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) |
|
29 | TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS) | |
30 | from rhodecode.tests.utils import AssertResponse |
|
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 | from rhodecode.apps._base import ADMIN_PREFIX |
|
34 | from rhodecode.apps._base import ADMIN_PREFIX | |
35 | return { |
|
35 | url_defs = { | |
36 | 'search': |
|
36 | 'search': | |
37 | ADMIN_PREFIX + '/search', |
|
37 | ADMIN_PREFIX + '/search', | |
38 | 'search_repo': |
|
38 | 'search_repo': | |
39 | '/{repo_name}/search', |
|
39 | '/{repo_name}/search', | |
40 |
|
40 | } | ||
41 | }[name].format(**kwargs) |
|
41 | return route_path_generator(url_defs, name=name, params=params, **kwargs) | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | class TestSearchController(TestController): |
|
44 | class TestSearchController(TestController): |
@@ -33,15 +33,15 b' import pytest' | |||||
33 | from rhodecode.model.db import User |
|
33 | from rhodecode.model.db import User | |
34 | from rhodecode.lib import auth |
|
34 | from rhodecode.lib import auth | |
35 | from rhodecode.lib import helpers as h |
|
35 | from rhodecode.lib import helpers as h | |
36 |
from rhodecode.lib.helpers import flash |
|
36 | from rhodecode.lib.helpers import flash | |
37 | from rhodecode.lib.utils2 import safe_str |
|
37 | from rhodecode.lib.utils2 import safe_str | |
38 |
|
38 | |||
39 |
|
39 | |||
40 | log = logging.getLogger(__name__) |
|
40 | log = logging.getLogger(__name__) | |
41 |
|
41 | |||
42 | __all__ = [ |
|
42 | __all__ = [ | |
43 | 'get_new_dir', 'TestController', |
|
43 | 'get_new_dir', 'TestController', 'route_path_generator', | |
44 |
|
|
44 | 'clear_cache_regions', | |
45 | 'assert_session_flash', 'login_user', 'no_newline_id_generator', |
|
45 | 'assert_session_flash', 'login_user', 'no_newline_id_generator', | |
46 | 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'SVN_REPO', |
|
46 | 'TESTS_TMP_PATH', 'HG_REPO', 'GIT_REPO', 'SVN_REPO', | |
47 | 'NEW_HG_REPO', 'NEW_GIT_REPO', |
|
47 | 'NEW_HG_REPO', 'NEW_GIT_REPO', | |
@@ -243,3 +243,13 b' def no_newline_id_generator(test_name):' | |||||
243 | .replace(' ', '_S') |
|
243 | .replace(' ', '_S') | |
244 |
|
244 | |||
245 | return test_name or 'test-with-empty-name' |
|
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