tests: made few tests handle database transactions better.
This commit is contained in:
parent
9335656019
commit
b66bbff0e8
4 changed files with 15 additions and 10 deletions
|
|
@ -67,6 +67,7 @@ class TestAdminMainView(TestController):
|
|||
self.log_user()
|
||||
pull_request = pr_util.create_pull_request()
|
||||
pull_request_id = pull_request.pull_request_id
|
||||
repo_name = pull_request.target_repo.repo_name
|
||||
|
||||
response = self.app.get(
|
||||
route_path(view, pull_request_id=pull_request_id),
|
||||
|
|
@ -74,9 +75,8 @@ class TestAdminMainView(TestController):
|
|||
assert response.location.endswith(
|
||||
'pull-request/{}'.format(pull_request_id))
|
||||
|
||||
repo_name = pull_request.target_repo.repo_name
|
||||
redirect_url = route_path(
|
||||
'pullrequest_show', repo_name=repo_name,
|
||||
pull_request_id=pull_request.pull_request_id)
|
||||
pull_request_id=pull_request_id)
|
||||
|
||||
assert redirect_url in response.location
|
||||
|
|
|
|||
|
|
@ -72,10 +72,11 @@ class TestAdminRepos(object):
|
|||
|
||||
def test_repo_list(self, autologin_user, user_util):
|
||||
repo = user_util.create_repo()
|
||||
repo_name = repo.repo_name
|
||||
response = self.app.get(
|
||||
route_path('repos'), status=200)
|
||||
|
||||
response.mustcontain(repo.repo_name)
|
||||
response.mustcontain(repo_name)
|
||||
|
||||
def test_create_page_restricted_to_single_backend(self, autologin_user, backend):
|
||||
with mock.patch('rhodecode.BACKENDS', {'git': 'git'}):
|
||||
|
|
@ -226,12 +227,14 @@ class TestAdminRepos(object):
|
|||
group_description='test',
|
||||
owner=TEST_USER_ADMIN_LOGIN)
|
||||
Session().commit()
|
||||
repo_group_id = gr.group_id
|
||||
|
||||
group_name_allowed = 'reg_sometest_allowed_%s' % backend.alias
|
||||
gr_allowed = RepoGroupModel().create(
|
||||
group_name=group_name_allowed,
|
||||
group_description='test',
|
||||
owner=TEST_USER_REGULAR_LOGIN)
|
||||
allowed_repo_group_id = gr_allowed.group_id
|
||||
Session().commit()
|
||||
|
||||
repo_name = 'ingroup'
|
||||
|
|
@ -243,7 +246,7 @@ class TestAdminRepos(object):
|
|||
repo_name=repo_name,
|
||||
repo_type=backend.alias,
|
||||
repo_description=description,
|
||||
repo_group=gr.group_id,
|
||||
repo_group=repo_group_id,
|
||||
csrf_token=csrf_token))
|
||||
|
||||
response.mustcontain('Invalid value')
|
||||
|
|
@ -260,7 +263,7 @@ class TestAdminRepos(object):
|
|||
repo_name=repo_name,
|
||||
repo_type=backend.alias,
|
||||
repo_description=description,
|
||||
repo_group=gr_allowed.group_id,
|
||||
repo_group=allowed_repo_group_id,
|
||||
csrf_token=csrf_token))
|
||||
|
||||
# TODO: johbo: Cleanup in pytest fixture
|
||||
|
|
@ -293,7 +296,7 @@ class TestAdminRepos(object):
|
|||
|
||||
# add repo permissions
|
||||
Session().commit()
|
||||
|
||||
repo_group_id = gr.group_id
|
||||
repo_name = 'ingroup_inherited_%s' % backend.alias
|
||||
repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
|
||||
description = 'description for newly created repo'
|
||||
|
|
@ -304,7 +307,7 @@ class TestAdminRepos(object):
|
|||
repo_name=repo_name,
|
||||
repo_type=backend.alias,
|
||||
repo_description=description,
|
||||
repo_group=gr.group_id,
|
||||
repo_group=repo_group_id,
|
||||
repo_copy_permissions=True,
|
||||
csrf_token=csrf_token))
|
||||
|
||||
|
|
|
|||
|
|
@ -167,4 +167,4 @@ class TestAdminUserGroupsView(TestController):
|
|||
'csrf_token': self.csrf_token}, status=200)
|
||||
|
||||
response.mustcontain(
|
||||
'User group `{}` already exists'.format(user_group.users_group_name))
|
||||
'User group `{}` already exists'.format(duplicate_name))
|
||||
|
|
|
|||
|
|
@ -137,9 +137,11 @@ class TestAdminUsersView(TestController):
|
|||
self.log_user()
|
||||
|
||||
user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
|
||||
user_id = user.user_id
|
||||
auth_tokens = user.auth_tokens
|
||||
response = self.app.get(
|
||||
route_path('edit_user_auth_tokens', user_id=user.user_id))
|
||||
for token in user.auth_tokens:
|
||||
route_path('edit_user_auth_tokens', user_id=user_id))
|
||||
for token in auth_tokens:
|
||||
response.mustcontain(token)
|
||||
response.mustcontain('never')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue