##// END OF EJS Templates
tests: made few tests handle database transactions better.
marcink -
r2786:35caee67 default
parent child Browse files
Show More
@@ -67,6 +67,7 b' class TestAdminMainView(TestController):'
67 67 self.log_user()
68 68 pull_request = pr_util.create_pull_request()
69 69 pull_request_id = pull_request.pull_request_id
70 repo_name = pull_request.target_repo.repo_name
70 71
71 72 response = self.app.get(
72 73 route_path(view, pull_request_id=pull_request_id),
@@ -74,9 +75,8 b' class TestAdminMainView(TestController):'
74 75 assert response.location.endswith(
75 76 'pull-request/{}'.format(pull_request_id))
76 77
77 repo_name = pull_request.target_repo.repo_name
78 78 redirect_url = route_path(
79 79 'pullrequest_show', repo_name=repo_name,
80 pull_request_id=pull_request.pull_request_id)
80 pull_request_id=pull_request_id)
81 81
82 82 assert redirect_url in response.location
@@ -72,10 +72,11 b' class TestAdminRepos(object):'
72 72
73 73 def test_repo_list(self, autologin_user, user_util):
74 74 repo = user_util.create_repo()
75 repo_name = repo.repo_name
75 76 response = self.app.get(
76 77 route_path('repos'), status=200)
77 78
78 response.mustcontain(repo.repo_name)
79 response.mustcontain(repo_name)
79 80
80 81 def test_create_page_restricted_to_single_backend(self, autologin_user, backend):
81 82 with mock.patch('rhodecode.BACKENDS', {'git': 'git'}):
@@ -226,12 +227,14 b' class TestAdminRepos(object):'
226 227 group_description='test',
227 228 owner=TEST_USER_ADMIN_LOGIN)
228 229 Session().commit()
230 repo_group_id = gr.group_id
229 231
230 232 group_name_allowed = 'reg_sometest_allowed_%s' % backend.alias
231 233 gr_allowed = RepoGroupModel().create(
232 234 group_name=group_name_allowed,
233 235 group_description='test',
234 236 owner=TEST_USER_REGULAR_LOGIN)
237 allowed_repo_group_id = gr_allowed.group_id
235 238 Session().commit()
236 239
237 240 repo_name = 'ingroup'
@@ -243,7 +246,7 b' class TestAdminRepos(object):'
243 246 repo_name=repo_name,
244 247 repo_type=backend.alias,
245 248 repo_description=description,
246 repo_group=gr.group_id,
249 repo_group=repo_group_id,
247 250 csrf_token=csrf_token))
248 251
249 252 response.mustcontain('Invalid value')
@@ -260,7 +263,7 b' class TestAdminRepos(object):'
260 263 repo_name=repo_name,
261 264 repo_type=backend.alias,
262 265 repo_description=description,
263 repo_group=gr_allowed.group_id,
266 repo_group=allowed_repo_group_id,
264 267 csrf_token=csrf_token))
265 268
266 269 # TODO: johbo: Cleanup in pytest fixture
@@ -293,7 +296,7 b' class TestAdminRepos(object):'
293 296
294 297 # add repo permissions
295 298 Session().commit()
296
299 repo_group_id = gr.group_id
297 300 repo_name = 'ingroup_inherited_%s' % backend.alias
298 301 repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
299 302 description = 'description for newly created repo'
@@ -304,7 +307,7 b' class TestAdminRepos(object):'
304 307 repo_name=repo_name,
305 308 repo_type=backend.alias,
306 309 repo_description=description,
307 repo_group=gr.group_id,
310 repo_group=repo_group_id,
308 311 repo_copy_permissions=True,
309 312 csrf_token=csrf_token))
310 313
@@ -167,4 +167,4 b' class TestAdminUserGroupsView(TestContro'
167 167 'csrf_token': self.csrf_token}, status=200)
168 168
169 169 response.mustcontain(
170 'User group `{}` already exists'.format(user_group.users_group_name))
170 'User group `{}` already exists'.format(duplicate_name))
@@ -137,9 +137,11 b' class TestAdminUsersView(TestController)'
137 137 self.log_user()
138 138
139 139 user = User.get_by_username(TEST_USER_REGULAR_LOGIN)
140 user_id = user.user_id
141 auth_tokens = user.auth_tokens
140 142 response = self.app.get(
141 route_path('edit_user_auth_tokens', user_id=user.user_id))
142 for token in user.auth_tokens:
143 route_path('edit_user_auth_tokens', user_id=user_id))
144 for token in auth_tokens:
143 145 response.mustcontain(token)
144 146 response.mustcontain('never')
145 147
General Comments 0
You need to be logged in to leave comments. Login now