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