##// END OF EJS Templates
python3: fix usage of int/long
python3: fix usage of int/long

File last commit:

r4914:49ad81de default
r4935:18be5f3a default
Show More
test_admin_main_views.py
82 lines | 2.9 KiB | text/x-python | PythonLexer
/ rhodecode / apps / admin / tests / test_admin_main_views.py
audit-logs: introduced new view to replace admin journal....
r1758 # -*- coding: utf-8 -*-
code: update copyrights to 2020
r4306 # Copyright (C) 2010-2020 RhodeCode GmbH
audit-logs: introduced new view to replace admin journal....
r1758 #
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3
# (only), as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# This program is dual-licensed. If you wish to learn more about the
# RhodeCode Enterprise Edition, including its added features, Support services,
# and proprietary license terms, please see https://rhodecode.com/licenses/
import pytest
from rhodecode.tests import TestController
from rhodecode.tests.fixture import Fixture
fixture = Fixture()
def route_path(name, params=None, **kwargs):
python3: fix urllib usage
r4914 import urllib.request, urllib.parse, urllib.error
audit-logs: introduced new view to replace admin journal....
r1758 from rhodecode.apps._base import ADMIN_PREFIX
base_url = {
'admin_home': ADMIN_PREFIX,
'pullrequest_show': '/{repo_name}/pull-request/{pull_request_id}',
'pull_requests_global': ADMIN_PREFIX + '/pull-request/{pull_request_id}',
'pull_requests_global_0': ADMIN_PREFIX + '/pull_requests/{pull_request_id}',
'pull_requests_global_1': ADMIN_PREFIX + '/pull-requests/{pull_request_id}',
}[name].format(**kwargs)
if params:
python3: fix urllib usage
r4914 base_url = '{}?{}'.format(base_url, urllib.parse.urlencode(params))
audit-logs: introduced new view to replace admin journal....
r1758 return base_url
class TestAdminMainView(TestController):
tests: fixed broken tests after UI chages
r3609 def test_access_admin_home(self):
audit-logs: introduced new view to replace admin journal....
r1758 self.log_user()
tests: fixed broken tests after UI chages
r3609 response = self.app.get(route_path('admin_home'), status=200)
response.mustcontain("Administration area")
audit-logs: introduced new view to replace admin journal....
r1758
def test_redirect_pull_request_view(self, view):
self.log_user()
self.app.get(
route_path(view, pull_request_id='xxxx'),
status=404)
@pytest.mark.backends("git", "hg")
@pytest.mark.parametrize('view', [
'pull_requests_global',
'pull_requests_global_0',
'pull_requests_global_1',
])
def test_redirect_pull_request_view(self, view, pr_util):
self.log_user()
pull_request = pr_util.create_pull_request()
pull_request_id = pull_request.pull_request_id
tests: made few tests handle database transactions better.
r2786 repo_name = pull_request.target_repo.repo_name
audit-logs: introduced new view to replace admin journal....
r1758
response = self.app.get(
route_path(view, pull_request_id=pull_request_id),
status=302)
assert response.location.endswith(
'pull-request/{}'.format(pull_request_id))
redirect_url = route_path(
'pullrequest_show', repo_name=repo_name,
tests: made few tests handle database transactions better.
r2786 pull_request_id=pull_request_id)
audit-logs: introduced new view to replace admin journal....
r1758
assert redirect_url in response.location