##// END OF EJS Templates
tests: stabilize tests for mysql/postgres.
marcink -
r3981:39e93a55 default
parent child Browse files
Show More
@@ -155,7 +155,7 b' class TestAuthSettingsView(object):'
155 155 response = self._post_ldap_settings(params, override={
156 156 'port': invalid_port_value,
157 157 })
158 assertr = AssertResponse(response)
158 assertr = response.assert_response()
159 159 assertr.element_contains(
160 160 '.form .field #port ~ .error-message',
161 161 invalid_port_value)
@@ -81,13 +81,13 b' class TestAdminRepos(object):'
81 81 def test_create_page_restricted_to_single_backend(self, autologin_user, backend):
82 82 with mock.patch('rhodecode.BACKENDS', {'git': 'git'}):
83 83 response = self.app.get(route_path('repo_new'), status=200)
84 assert_response = AssertResponse(response)
84 assert_response = response.assert_response()
85 85 element = assert_response.get_element('#repo_type')
86 86 assert element.text_content() == '\ngit\n'
87 87
88 88 def test_create_page_non_restricted_backends(self, autologin_user, backend):
89 89 response = self.app.get(route_path('repo_new'), status=200)
90 assert_response = AssertResponse(response)
90 assert_response = response.assert_response()
91 91 assert_response.element_contains('#repo_type', 'git')
92 92 assert_response.element_contains('#repo_type', 'svn')
93 93 assert_response.element_contains('#repo_type', 'hg')
@@ -367,7 +367,7 b' class TestAdminSettingsVcs(object):'
367 367
368 368 def test_has_an_input_for_invalidation_of_inline_comments(self):
369 369 response = self.app.get(route_path('admin_settings_vcs'))
370 assert_response = AssertResponse(response)
370 assert_response = response.assert_response()
371 371 assert_response.one_element_exists(
372 372 '[name=rhodecode_use_outdated_comments]')
373 373
@@ -518,7 +518,7 b' class TestOpenSourceLicenses(object):'
518 518 response = self.app.get(
519 519 route_path('admin_settings_open_source'), status=200)
520 520
521 assert_response = AssertResponse(response)
521 assert_response = response.assert_response()
522 522 assert_response.element_contains(
523 523 '.panel-heading', 'Licenses of Third Party Packages')
524 524 for license_data in sample_licenses:
@@ -528,7 +528,7 b' class TestOpenSourceLicenses(object):'
528 528 def test_records_can_be_read(self, autologin_user):
529 529 response = self.app.get(
530 530 route_path('admin_settings_open_source'), status=200)
531 assert_response = AssertResponse(response)
531 assert_response = response.assert_response()
532 532 assert_response.element_contains(
533 533 '.panel-heading', 'Licenses of Third Party Packages')
534 534
@@ -88,7 +88,7 b' class TestPasswordReset(TestController):'
88 88
89 89 response = self.app.get(route_path('reset_password'))
90 90
91 assert_response = AssertResponse(response)
91 assert_response = response.assert_response()
92 92 if show_reset:
93 93 response.mustcontain('Send password reset email')
94 94 assert_response.one_element_exists('#email')
@@ -90,7 +90,7 b' class TestRegisterCaptcha(object):'
90 90
91 91 response = app.get(ADMIN_PREFIX + '/register')
92 92
93 assertr = AssertResponse(response)
93 assertr = response.assert_response()
94 94 if active:
95 95 assertr.one_element_exists('#recaptcha_field')
96 96 else:
@@ -128,6 +128,6 b' class TestRegisterCaptcha(object):'
128 128 else:
129 129 # If captche input is invalid we expect to stay on the registration
130 130 # page with an error message displayed.
131 assertr = AssertResponse(response)
131 assertr = response.assert_response()
132 132 assert response.status_int == 200
133 133 assertr.one_element_exists('#recaptcha_field ~ span.error-message')
@@ -116,7 +116,7 b' class TestFeedView(TestController):'
116 116 self, backend, user_util, feed_type):
117 117 user = user_util.create_user()
118 118 auth_token = AuthTokenModel().create(
119 user.user_id, 'test-token', -1, AuthTokenModel.cls.ROLE_API)
119 user.user_id, u'test-token', -1, AuthTokenModel.cls.ROLE_API)
120 120 auth_token = auth_token.api_key
121 121
122 122 self.app.get(
@@ -127,7 +127,7 b' class TestFeedView(TestController):'
127 127 status=302)
128 128
129 129 auth_token = AuthTokenModel().create(
130 user.user_id, 'test-token', -1, AuthTokenModel.cls.ROLE_FEED)
130 user.user_id, u'test-token', -1, AuthTokenModel.cls.ROLE_FEED)
131 131 auth_token = auth_token.api_key
132 132 self.app.get(
133 133 route_path(
@@ -236,7 +236,7 b' class TestSummaryView(object):'
236 236 with scm_patcher:
237 237 response = self.app.get(
238 238 route_path('repo_summary', repo_name=repo_name))
239 assert_response = AssertResponse(response)
239 assert_response = response.assert_response()
240 240 assert_response.element_contains(
241 241 '.main .alert-warning strong', 'Missing requirements')
242 242 assert_response.element_contains(
@@ -98,7 +98,7 b' class TestVcsSettings(object):'
98 98 repo_name = backend.repo_name
99 99 response = self.app.get(route_path('edit_repo_vcs', repo_name=repo_name))
100 100
101 assert_response = AssertResponse(response)
101 assert_response = response.assert_response()
102 102 element = assert_response.get_element('#inherit_global_settings')
103 103 assert element.checked
104 104
@@ -111,7 +111,7 b' class TestVcsSettings(object):'
111 111 repo, 'inherit_vcs_settings', checked_value, 'bool')
112 112 response = self.app.get(route_path('edit_repo_vcs', repo_name=repo_name))
113 113
114 assert_response = AssertResponse(response)
114 assert_response = response.assert_response()
115 115 element = assert_response.get_element('#inherit_global_settings')
116 116 assert element.checked == checked_value
117 117
@@ -491,7 +491,7 b' class TestVcsSettings(object):'
491 491
492 492 response = self.app.get(
493 493 route_path('edit_repo_vcs', repo_name=repo_name), status=200)
494 assert_response = AssertResponse(response)
494 assert_response = response.assert_response()
495 495 for branch in branches:
496 496 css_selector = '[name=branch_value_{}]'.format(branch.ui_id)
497 497 element = assert_response.get_element(css_selector)
@@ -668,7 +668,7 b' class TestVcsSettings(object):'
668 668 Session().commit()
669 669
670 670 def assert_repo_value_equals_global_value(self, response, setting):
671 assert_response = AssertResponse(response)
671 assert_response = response.assert_response()
672 672 global_css_selector = '[name={}_inherited]'.format(setting)
673 673 repo_css_selector = '[name={}]'.format(setting)
674 674 repo_element = assert_response.get_element(repo_css_selector)
@@ -59,7 +59,7 b' class TestAdminRepoVcsSettings(object):'
59 59 rhodecode.CONFIG, {'labs_settings_active': 'true'}):
60 60 response = self.app.get(vcs_settings_url)
61 61
62 assertr = AssertResponse(response)
62 assertr = response.assert_response()
63 63 assertr.one_element_exists('#rhodecode_{}'.format(setting_name))
64 64
65 65 @pytest.mark.parametrize('setting_name, setting_backends', [
@@ -46,7 +46,7 b' class TestSearchController(TestControlle'
46 46 def test_index(self):
47 47 self.log_user()
48 48 response = self.app.get(route_path('search'))
49 assert_response = AssertResponse(response)
49 assert_response = response.assert_response()
50 50 assert_response.one_element_exists('input#q')
51 51
52 52 def test_search_files_empty_search(self):
@@ -46,14 +46,14 b' class TestUsersController(TestController'
46 46 response = self.app.get(route_path('user_profile', username=username))
47 47 response.mustcontain('testme')
48 48 response.mustcontain('testme@rhodecode.org')
49 assert_response = AssertResponse(response)
49 assert_response = response.assert_response()
50 50 assert_response.no_element_exists(edit_link_css)
51 51
52 52 # edit should be available to superadmin users
53 53 self.logout_user()
54 54 self.log_user(TEST_USER_ADMIN_LOGIN, TEST_USER_ADMIN_PASS)
55 55 response = self.app.get(route_path('user_profile', username=username))
56 assert_response = AssertResponse(response)
56 assert_response = response.assert_response()
57 57 assert_response.element_contains(edit_link_css, 'Edit')
58 58
59 59 def test_user_profile_not_available(self, user_util):
@@ -584,7 +584,7 b' class User(Base, BaseModel):'
584 584 _user_data = Column("user_data", LargeBinary(), nullable=True) # JSON data
585 585
586 586 user_log = relationship('UserLog')
587 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all')
587 user_perms = relationship('UserToPerm', primaryjoin="User.user_id==UserToPerm.user_id", cascade='all, delete-orphan')
588 588
589 589 repositories = relationship('Repository')
590 590 repository_groups = relationship('RepoGroup')
@@ -593,9 +593,9 b' class User(Base, BaseModel):'
593 593 user_followers = relationship('UserFollowing', primaryjoin='UserFollowing.follows_user_id==User.user_id', cascade='all')
594 594 followings = relationship('UserFollowing', primaryjoin='UserFollowing.user_id==User.user_id', cascade='all')
595 595
596 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all')
597 repo_group_to_perm = relationship('UserRepoGroupToPerm', primaryjoin='UserRepoGroupToPerm.user_id==User.user_id', cascade='all')
598 user_group_to_perm = relationship('UserUserGroupToPerm', primaryjoin='UserUserGroupToPerm.user_id==User.user_id', cascade='all')
596 repo_to_perm = relationship('UserRepoToPerm', primaryjoin='UserRepoToPerm.user_id==User.user_id', cascade='all, delete-orphan')
597 repo_group_to_perm = relationship('UserRepoGroupToPerm', primaryjoin='UserRepoGroupToPerm.user_id==User.user_id', cascade='all, delete-orphan')
598 user_group_to_perm = relationship('UserUserGroupToPerm', primaryjoin='UserUserGroupToPerm.user_id==User.user_id', cascade='all, delete-orphan')
599 599
600 600 group_member = relationship('UserGroupMember', cascade='all')
601 601
@@ -1328,7 +1328,7 b' class UserGroup(Base, BaseModel):'
1328 1328 created_on = Column('created_on', DateTime(timezone=False), nullable=False, default=datetime.datetime.now)
1329 1329 _group_data = Column("group_data", LargeBinary(), nullable=True) # JSON data
1330 1330
1331 members = relationship('UserGroupMember', cascade="all, delete, delete-orphan", lazy="joined")
1331 members = relationship('UserGroupMember', cascade="all, delete-orphan", lazy="joined")
1332 1332 users_group_to_perm = relationship('UserGroupToPerm', cascade='all')
1333 1333 users_group_repo_to_perm = relationship('UserGroupRepoToPerm', cascade='all')
1334 1334 users_group_repo_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
@@ -1665,21 +1665,21 b' class Repository(Base, BaseModel):'
1665 1665 primaryjoin='UserFollowing.follows_repo_id==Repository.repo_id',
1666 1666 cascade='all')
1667 1667 extra_fields = relationship(
1668 'RepositoryField', cascade="all, delete, delete-orphan")
1668 'RepositoryField', cascade="all, delete-orphan")
1669 1669 logs = relationship('UserLog')
1670 1670 comments = relationship(
1671 'ChangesetComment', cascade="all, delete, delete-orphan")
1671 'ChangesetComment', cascade="all, delete-orphan")
1672 1672 pull_requests_source = relationship(
1673 1673 'PullRequest',
1674 1674 primaryjoin='PullRequest.source_repo_id==Repository.repo_id',
1675 cascade="all, delete, delete-orphan")
1675 cascade="all, delete-orphan")
1676 1676 pull_requests_target = relationship(
1677 1677 'PullRequest',
1678 1678 primaryjoin='PullRequest.target_repo_id==Repository.repo_id',
1679 cascade="all, delete, delete-orphan")
1679 cascade="all, delete-orphan")
1680 1680 ui = relationship('RepoRhodeCodeUi', cascade="all")
1681 1681 settings = relationship('RepoRhodeCodeSetting', cascade="all")
1682 integrations = relationship('Integration', cascade="all, delete, delete-orphan")
1682 integrations = relationship('Integration', cascade="all, delete-orphan")
1683 1683
1684 1684 scoped_tokens = relationship('UserApiKeys', cascade="all")
1685 1685
@@ -2551,7 +2551,7 b' class RepoGroup(Base, BaseModel):'
2551 2551 users_group_to_perm = relationship('UserGroupRepoGroupToPerm', cascade='all')
2552 2552 parent_group = relationship('RepoGroup', remote_side=group_id)
2553 2553 user = relationship('User')
2554 integrations = relationship('Integration', cascade="all, delete, delete-orphan")
2554 integrations = relationship('Integration', cascade="all, delete-orphan")
2555 2555
2556 2556 def __init__(self, group_name='', parent_group=None):
2557 2557 self.group_name = group_name
@@ -3270,7 +3270,7 b' class UserRepoToPerm(Base, BaseModel):'
3270 3270 repository = relationship('Repository')
3271 3271 permission = relationship('Permission')
3272 3272
3273 branch_perm_entry = relationship('UserToRepoBranchPermission', cascade="all, delete, delete-orphan", lazy='joined')
3273 branch_perm_entry = relationship('UserToRepoBranchPermission', cascade="all, delete-orphan", lazy='joined')
3274 3274
3275 3275 @classmethod
3276 3276 def create(cls, user, repository, permission):
@@ -3646,7 +3646,7 b' class ChangesetComment(Base, BaseModel):'
3646 3646
3647 3647 author = relationship('User', lazy='joined')
3648 3648 repo = relationship('Repository')
3649 status_change = relationship('ChangesetStatus', cascade="all, delete, delete-orphan", lazy='joined')
3649 status_change = relationship('ChangesetStatus', cascade="all, delete-orphan", lazy='joined')
3650 3650 pull_request = relationship('PullRequest', lazy='joined')
3651 3651 pull_request_version = relationship('PullRequestVersion')
3652 3652
@@ -4120,13 +4120,13 b' class PullRequest(Base, _PullRequestBase'
4120 4120 return '<DB:PullRequest at %#x>' % id(self)
4121 4121
4122 4122 reviewers = relationship('PullRequestReviewers',
4123 cascade="all, delete, delete-orphan")
4123 cascade="all, delete-orphan")
4124 4124 statuses = relationship('ChangesetStatus',
4125 cascade="all, delete, delete-orphan")
4125 cascade="all, delete-orphan")
4126 4126 comments = relationship('ChangesetComment',
4127 cascade="all, delete, delete-orphan")
4127 cascade="all, delete-orphan")
4128 4128 versions = relationship('PullRequestVersion',
4129 cascade="all, delete, delete-orphan",
4129 cascade="all, delete-orphan",
4130 4130 lazy='dynamic')
4131 4131
4132 4132 @classmethod
@@ -4341,7 +4341,7 b' class Notification(Base, BaseModel):'
4341 4341
4342 4342 created_by_user = relationship('User')
4343 4343 notifications_to_users = relationship('UserNotification', lazy='joined',
4344 cascade="all, delete, delete-orphan")
4344 cascade="all, delete-orphan")
4345 4345
4346 4346 @property
4347 4347 def recipients(self):
@@ -510,8 +510,7 b' class UserModel(BaseModel):'
510 510 from rhodecode.lib.hooks_base import log_delete_user
511 511
512 512 if not cur_user:
513 cur_user = getattr(
514 get_current_rhodecode_user(), 'username', None)
513 cur_user = getattr(get_current_rhodecode_user(), 'username', None)
515 514 user = self._get_user(user)
516 515
517 516 try:
@@ -27,7 +27,7 b' from mock import patch'
27 27 from rhodecode.lib import auth
28 28 from rhodecode.lib.utils2 import md5
29 29 from rhodecode.model.auth_token import AuthTokenModel
30 from rhodecode.model.db import User
30 from rhodecode.model.db import Session, User
31 31 from rhodecode.model.repo import RepoModel
32 32 from rhodecode.model.user import UserModel
33 33 from rhodecode.model.user_group import UserGroupModel
@@ -93,6 +93,7 b' def test_cached_perms_data_user_group_gl'
93 93
94 94 granted_permission = 'repository.write'
95 95 UserGroupModel().grant_perm(user_group, granted_permission)
96 Session().commit()
96 97
97 98 permissions = get_permissions(user)
98 99 assert granted_permission in permissions['global']
@@ -104,6 +105,7 b' def test_cached_perms_data_user_group_gl'
104 105
105 106 granted_permission = 'repository.write'
106 107 UserGroupModel().grant_perm(user_group, granted_permission)
108 Session().commit()
107 109
108 110 permissions = get_permissions(user)
109 111 assert granted_permission in permissions['global']
@@ -112,6 +114,7 b' def test_cached_perms_data_user_group_gl'
112 114 def test_cached_perms_data_user_global_permissions(user_util):
113 115 user = user_util.create_user()
114 116 UserModel().grant_perm(user, 'repository.none')
117 Session().commit()
115 118
116 119 permissions = get_permissions(user, user_inherit_default_permissions=True)
117 120 assert 'repository.read' in permissions['global']
@@ -127,6 +130,7 b' def test_cached_perms_data_repository_pe'
127 130 granted_permission = 'repository.write'
128 131 RepoModel().grant_user_group_permission(
129 132 repo, user_group.users_group_name, granted_permission)
133 Session().commit()
130 134
131 135 permissions = get_permissions(user)
132 136 assert permissions['repositories'][repo.repo_name] == granted_permission
@@ -153,6 +157,7 b' def test_cached_perms_data_repository_pe'
153 157
154 158 # Don't inherit default object permissions
155 159 UserModel().grant_perm(user, 'hg.inherit_default_perms.false')
160 Session().commit()
156 161
157 162 permissions = get_permissions(user)
158 163 assert permissions['repositories'][repo.repo_name] == 'repository.none'
@@ -203,6 +208,7 b' def test_cached_perms_data_default_permi'
203 208 # Don't inherit default object permissions
204 209 user = user_util.create_user()
205 210 UserModel().grant_perm(user, 'hg.inherit_default_perms.false')
211 Session().commit()
206 212
207 213 permissions = get_permissions(user)
208 214 assert permissions['repositories_groups'][repo_group.group_name] == \
@@ -224,6 +230,7 b' def test_cached_perms_data_repository_pe'
224 230 repo, user_group.users_group_name, 'repository.read')
225 231 RepoModel().grant_user_group_permission(
226 232 repo, user_group2.users_group_name, 'repository.write')
233 Session().commit()
227 234
228 235 permissions = get_permissions(user)
229 236 assert permissions['repositories'][repo.repo_name] == 'repository.write'
@@ -238,6 +245,7 b' def test_cached_perms_data_repository_pe'
238 245
239 246 RepoModel().grant_user_group_permission(
240 247 repo, user_group.users_group_name, 'repository.write')
248 Session().commit()
241 249
242 250 permissions = get_permissions(user)
243 251 assert permissions['repositories'][repo.repo_name] == 'repository.admin'
@@ -249,6 +257,7 b' def test_cached_perms_data_user_reposito'
249 257 repo = backend_random.create_repo()
250 258 granted_permission = 'repository.write'
251 259 RepoModel().grant_user_permission(repo, user, granted_permission)
260 Session().commit()
252 261
253 262 permissions = get_permissions(user)
254 263 assert permissions['repositories'][repo.repo_name] == granted_permission
@@ -260,6 +269,7 b' def test_cached_perms_data_user_reposito'
260 269 repo = backend_random.create_repo()
261 270 granted_permission = 'repository.none'
262 271 RepoModel().grant_user_permission(repo, user, granted_permission)
272 Session().commit()
263 273
264 274 permissions = get_permissions(user, explicit=True)
265 275 assert permissions['repositories'][repo.repo_name] == granted_permission
@@ -271,6 +281,7 b' def test_cached_perms_data_user_reposito'
271 281 repo = backend_random.create_repo()
272 282 repo.user_id = user.user_id
273 283 RepoModel().grant_user_permission(repo, user, 'repository.write')
284 Session().commit()
274 285
275 286 permissions = get_permissions(user)
276 287 assert permissions['repositories'][repo.repo_name] == 'repository.admin'
@@ -380,6 +391,7 b' def test_cached_perms_data_user_group_pe'
380 391 user = user_util.create_user()
381 392 user_group = user_util.create_user_group()
382 393 UserGroupModel().grant_user_permission(user_group, user, 'usergroup.write')
394 Session().commit()
383 395
384 396 permissions = get_permissions(user)
385 397 assert permissions['user_groups'][user_group.users_group_name] == \
@@ -391,6 +403,7 b' def test_cached_perms_data_user_group_pe'
391 403 user = user_util.create_user()
392 404 user_group = user_util.create_user_group()
393 405 UserGroupModel().grant_user_permission(user_group, user, 'usergroup.none')
406 Session().commit()
394 407
395 408 permissions = get_permissions(user, explicit=True)
396 409 assert permissions['user_groups'][user_group.users_group_name] == \
@@ -404,6 +417,7 b' def test_cached_perms_data_user_group_pe'
404 417
405 418 # Don't inherit default object permissions
406 419 UserModel().grant_perm(user, 'hg.inherit_default_perms.false')
420 Session().commit()
407 421
408 422 permissions = get_permissions(user)
409 423 assert permissions['user_groups'][user_group.users_group_name] == \
@@ -447,6 +461,7 b' def test_permission_calculator_repositor'
447 461
448 462 RepoModel().grant_user_permission(
449 463 backend_random.repo, user, 'repository.write')
464 Session().commit()
450 465
451 466 calculator = auth.PermissionCalculator(
452 467 user.user_id, {}, False, False, False, 'higherwin')
@@ -610,7 +625,7 b' def test_auth_by_token(test_token, test_'
610 625 user = user_util.create_user()
611 626 user_id = user.user_id
612 627 for token, role, expires in expected_tokens:
613 new_token = AuthTokenModel().create(user_id, 'test-token', expires, role)
628 new_token = AuthTokenModel().create(user_id, u'test-token', expires, role)
614 629 new_token.api_key = token # inject known name for testing...
615 630
616 631 assert auth_result == user.authenticate_by_token(
@@ -277,6 +277,8 b' class TestCreateOrUpdateRepoHookSettings'
277 277
278 278 with pytest.raises(ValueError) as exc_info:
279 279 model.create_or_update_repo_hook_settings(data)
280 Session().commit()
281
280 282 msg = 'The given data does not contain {} key'.format(deleted_key)
281 283 assert str(exc_info.value) == msg
282 284
@@ -286,6 +288,8 b' class TestCreateOrUpdateRepoHookSettings'
286 288 settings_util.create_repo_rhodecode_ui(
287 289 repo_stub, section, None, key=key, active=False)
288 290 model.create_or_update_repo_hook_settings(HOOKS_FORM_DATA)
291 Session().commit()
292
289 293 for section, key in model.HOOKS_SETTINGS:
290 294 ui = model.repo_settings.get_ui_by_section_and_key(section, key)
291 295 assert ui.ui_active is True
@@ -297,6 +301,7 b' class TestCreateOrUpdateRepoHookSettings'
297 301 with global_patch as global_mock:
298 302 global_mock.get_ui_by_section_and_key.return_value = global_setting
299 303 model.create_or_update_repo_hook_settings(HOOKS_FORM_DATA)
304 Session().commit()
300 305
301 306
302 307 class TestUpdateGlobalHookSettings(object):
@@ -309,6 +314,8 b' class TestUpdateGlobalHookSettings(objec'
309 314
310 315 with pytest.raises(ValueError) as exc_info:
311 316 model.update_global_hook_settings(data)
317 Session().commit()
318
312 319 msg = 'The given data does not contain {} key'.format(deleted_key)
313 320 assert str(exc_info.value) == msg
314 321
@@ -322,6 +329,8 b' class TestUpdateGlobalHookSettings(objec'
322 329 session_patcher = mock.patch('rhodecode.model.settings.Session')
323 330 with get_settings_patcher as get_settings_mock, session_patcher:
324 331 model.update_global_hook_settings(HOOKS_FORM_DATA)
332 Session().commit()
333
325 334 assert setting_mock.ui_active is True
326 335 assert get_settings_mock.call_count == 3
327 336
@@ -333,6 +342,8 b' class TestCreateOrUpdateRepoGeneralSetti'
333 342 model, '_create_or_update_general_settings')
334 343 with create_patch as create_mock:
335 344 model.create_or_update_repo_pr_settings(GENERAL_FORM_DATA)
345 Session().commit()
346
336 347 create_mock.assert_called_once_with(
337 348 model.repo_settings, GENERAL_FORM_DATA)
338 349
@@ -380,6 +391,7 b' class TestCreateOrUpdateGeneralSettings('
380 391
381 392 with pytest.raises(ValueError) as exc_info:
382 393 model._create_or_update_general_settings(model.repo_settings, data)
394 Session().commit()
383 395
384 396 msg = 'The given data does not contain {} key'.format(deleted_key)
385 397 assert str(exc_info.value) == msg
@@ -392,6 +404,7 b' class TestCreateOrUpdateGeneralSettings('
392 404
393 405 model._create_or_update_general_settings(
394 406 model.repo_settings, GENERAL_FORM_DATA)
407 Session().commit()
395 408
396 409 for name in model.GENERAL_SETTINGS:
397 410 setting = model.repo_settings.get_setting_by_name(name)
@@ -403,12 +416,16 b' class TestCreateRepoSvnSettings(object):'
403 416 model = VcsSettingsModel(repo=repo_stub.repo_name)
404 417 with mock.patch.object(model, '_create_svn_settings') as create_mock:
405 418 model.create_repo_svn_settings(SVN_FORM_DATA)
419 Session().commit()
420
406 421 create_mock.assert_called_once_with(model.repo_settings, SVN_FORM_DATA)
407 422
408 423 def test_raises_exception_when_repository_is_not_specified(self):
409 424 model = VcsSettingsModel()
410 425 with pytest.raises(Exception) as exc_info:
411 426 model.create_repo_svn_settings(SVN_FORM_DATA)
427 Session().commit()
428
412 429 assert str(exc_info.value) == 'Repository is not specified'
413 430
414 431
@@ -547,6 +564,8 b' class TestCreateOrUpdateRepoHgSettings(o'
547 564 data.pop(field_to_remove)
548 565 with pytest.raises(ValueError) as exc_info:
549 566 model.create_or_update_repo_hg_settings(data)
567 Session().commit()
568
550 569 expected_message = 'The given data does not contain {} key'.format(
551 570 field_to_remove)
552 571 assert str(exc_info.value) == expected_message
@@ -555,6 +574,8 b' class TestCreateOrUpdateRepoHgSettings(o'
555 574 model = VcsSettingsModel()
556 575 with pytest.raises(Exception) as exc_info:
557 576 model.create_or_update_repo_hg_settings(self.FORM_DATA)
577 Session().commit()
578
558 579 assert str(exc_info.value) == 'Repository is not specified'
559 580
560 581
@@ -563,6 +584,8 b' class TestUpdateGlobalSslSetting(object)'
563 584 model = VcsSettingsModel()
564 585 with mock.patch.object(model, '_create_or_update_ui') as create_mock:
565 586 model.update_global_ssl_setting('False')
587 Session().commit()
588
566 589 create_mock.assert_called_once_with(
567 590 model.global_settings, 'web', 'push_ssl', value='False')
568 591
@@ -572,6 +595,8 b' class TestUpdateGlobalPathSetting(object'
572 595 model = VcsSettingsModel()
573 596 with mock.patch.object(model, '_create_or_update_ui') as create_mock:
574 597 model.update_global_path_setting('False')
598 Session().commit()
599
575 600 create_mock.assert_called_once_with(
576 601 model.global_settings, 'paths', '/', value='False')
577 602
@@ -589,6 +614,8 b' class TestCreateOrUpdateGlobalHgSettings'
589 614 model = VcsSettingsModel()
590 615 with mock.patch.object(model, '_create_or_update_ui') as create_mock:
591 616 model.create_or_update_global_hg_settings(self.FORM_DATA)
617 Session().commit()
618
592 619 expected_calls = [
593 620 mock.call(model.global_settings, 'extensions', 'largefiles', active=False, value=''),
594 621 mock.call(model.global_settings, 'largefiles', 'usercache', value='/example/largefiles-store'),
@@ -609,6 +636,8 b' class TestCreateOrUpdateGlobalHgSettings'
609 636 data.pop(field_to_remove)
610 637 with pytest.raises(Exception) as exc_info:
611 638 model.create_or_update_global_hg_settings(data)
639 Session().commit()
640
612 641 expected_message = 'The given data does not contain {} key'.format(
613 642 field_to_remove)
614 643 assert str(exc_info.value) == expected_message
@@ -624,6 +653,8 b' class TestCreateOrUpdateGlobalGitSetting'
624 653 model = VcsSettingsModel()
625 654 with mock.patch.object(model, '_create_or_update_ui') as create_mock:
626 655 model.create_or_update_global_git_settings(self.FORM_DATA)
656 Session().commit()
657
627 658 expected_calls = [
628 659 mock.call(model.global_settings, 'vcs_git_lfs', 'enabled', active=False, value=False),
629 660 mock.call(model.global_settings, 'vcs_git_lfs', 'store_location', value='/example/lfs-store'),
@@ -649,6 +680,8 b' class TestDeleteRepoSvnPattern(object):'
649 680 delete_ui_patch = mock.patch.object(model.repo_settings, 'delete_ui')
650 681 with delete_ui_patch as delete_ui_mock:
651 682 model.delete_repo_svn_pattern(123)
683 Session().commit()
684
652 685 delete_ui_mock.assert_called_once_with(-1)
653 686
654 687 def test_raises_exception_when_repository_is_not_specified(self):
@@ -748,6 +781,8 b' class TestGetRepoUiSettings(object):'
748 781 for section in svn_sections:
749 782 settings_util.create_rhodecode_ui(
750 783 section, 'repo', key='deadbeef' + section, active=False)
784 Session().commit()
785
751 786 model = VcsSettingsModel(repo=repo_stub.repo_name)
752 787 result = model.get_repo_ui_settings()
753 788 for setting in result:
@@ -795,6 +830,8 b' class TestGetRepoGeneralSettings(object)'
795 830 for key in VcsSettingsModel.GENERAL_SETTINGS:
796 831 settings_util.create_repo_rhodecode_setting(
797 832 repo_stub, key, 'abcde', type_='unicode')
833 Session().commit()
834
798 835 model = VcsSettingsModel(repo=repo_stub.repo_name)
799 836 result = model.get_repo_ui_settings()
800 837 for key in result:
@@ -820,6 +857,8 b' class TestGetGlobalGeneralSettings(objec'
820 857 for key in VcsSettingsModel.GENERAL_SETTINGS:
821 858 settings_util.create_repo_rhodecode_setting(
822 859 repo_stub, key, 'abcde', type_='unicode')
860 Session().commit()
861
823 862 model = VcsSettingsModel(repo=repo_stub.repo_name)
824 863 result = model.get_global_general_settings()
825 864 expected_result = model.global_settings.get_all_settings()
@@ -838,6 +877,8 b' class TestGetGlobalUiSettings(object):'
838 877 for section, key in VcsSettingsModel.HOOKS_SETTINGS:
839 878 settings_util.create_repo_rhodecode_ui(
840 879 repo_stub, section, 'repo', key=key, active=False)
880 Session().commit()
881
841 882 model = VcsSettingsModel(repo=repo_stub.repo_name)
842 883 result = model.get_global_ui_settings()
843 884 expected_result = model.global_settings.get_ui()
@@ -868,6 +909,8 b' class TestGetGeneralSettings(object):'
868 909 for key in VcsSettingsModel.GENERAL_SETTINGS:
869 910 settings_util.create_repo_rhodecode_setting(
870 911 repo_stub, key, 'abcde', type_='unicode')
912 Session().commit()
913
871 914 result = model.get_general_settings()
872 915 expected_result = model.get_global_general_settings()
873 916 assert sorted(result) == sorted(expected_result)
@@ -879,6 +922,8 b' class TestGetGeneralSettings(object):'
879 922 for key in VcsSettingsModel.GENERAL_SETTINGS:
880 923 settings_util.create_repo_rhodecode_setting(
881 924 repo_stub, key, 'abcde', type_='unicode')
925 Session().commit()
926
882 927 result = model.get_general_settings()
883 928 expected_result = model.get_repo_general_settings()
884 929 assert sorted(result) == sorted(expected_result)
@@ -898,6 +943,8 b' class TestGetUiSettings(object):'
898 943 for section, key in VcsSettingsModel.HOOKS_SETTINGS:
899 944 settings_util.create_repo_rhodecode_ui(
900 945 repo_stub, section, 'repo', key=key, active=True)
946 Session().commit()
947
901 948 result = model.get_ui_settings()
902 949 expected_result = model.get_global_ui_settings()
903 950 assert sorted(result) == sorted(expected_result)
@@ -909,6 +956,8 b' class TestGetUiSettings(object):'
909 956 for section, key in VcsSettingsModel.HOOKS_SETTINGS:
910 957 settings_util.create_repo_rhodecode_ui(
911 958 repo_stub, section, 'repo', key=key, active=True)
959 Session().commit()
960
912 961 result = model.get_ui_settings()
913 962 expected_result = model.get_repo_ui_settings()
914 963 assert sorted(result) == sorted(expected_result)
@@ -916,9 +965,12 b' class TestGetUiSettings(object):'
916 965 def test_repo_settings_filtered_by_section_and_key(self, repo_stub):
917 966 model = VcsSettingsModel(repo=repo_stub.repo_name)
918 967 model.inherit_global_settings = False
968
919 969 args = ('section', 'key')
920 970 with mock.patch.object(model, 'get_repo_ui_settings') as settings_mock:
921 971 model.get_ui_settings(*args)
972 Session().commit()
973
922 974 settings_mock.assert_called_once_with(*args)
923 975
924 976 def test_global_settings_filtered_by_section_and_key(self):
@@ -942,6 +994,8 b' class TestGetSvnPatterns(object):'
942 994 args = ('section', )
943 995 with mock.patch.object(model, 'get_repo_ui_settings') as settings_mock:
944 996 model.get_svn_patterns(*args)
997
998 Session().commit()
945 999 settings_mock.assert_called_once_with(*args)
946 1000
947 1001 def test_global_settings_filtered_by_section_and_key(self):
@@ -990,6 +1044,8 b' class TestCreateOrUpdateRepoSettings(obj'
990 1044 model = VcsSettingsModel()
991 1045 with pytest.raises(Exception) as exc_info:
992 1046 model.create_or_update_repo_settings(data=self.FORM_DATA)
1047 Session().commit()
1048
993 1049 assert str(exc_info.value) == 'Repository is not specified'
994 1050
995 1051 def test_only_svn_settings_are_updated_when_type_is_svn(self, backend_svn):
@@ -998,6 +1054,8 b' class TestCreateOrUpdateRepoSettings(obj'
998 1054 with self._patch_model(model) as mocks:
999 1055 model.create_or_update_repo_settings(
1000 1056 data=self.FORM_DATA, inherit_global_settings=False)
1057 Session().commit()
1058
1001 1059 mocks['create_repo_svn_settings'].assert_called_once_with(
1002 1060 self.FORM_DATA)
1003 1061 non_called_methods = (
@@ -1013,6 +1071,7 b' class TestCreateOrUpdateRepoSettings(obj'
1013 1071 with self._patch_model(model) as mocks:
1014 1072 model.create_or_update_repo_settings(
1015 1073 data=self.FORM_DATA, inherit_global_settings=False)
1074 Session().commit()
1016 1075
1017 1076 assert mocks['create_repo_svn_settings'].call_count == 0
1018 1077 called_methods = (
@@ -1060,6 +1119,8 b' class TestCreateOrUpdateRepoSettings(obj'
1060 1119 with invalidation_patcher as invalidation_mock:
1061 1120 model.create_or_update_repo_settings(
1062 1121 data=self.FORM_DATA, inherit_global_settings=True)
1122 Session().commit()
1123
1063 1124 invalidation_mock.assert_called_once_with(
1064 1125 repo_stub.repo_name, delete=True)
1065 1126
@@ -1069,6 +1130,8 b' class TestCreateOrUpdateRepoSettings(obj'
1069 1130 with self._patch_model(model):
1070 1131 model.create_or_update_repo_settings(
1071 1132 data=self.FORM_DATA, inherit_global_settings=False)
1133 Session().commit()
1134
1072 1135 assert model.inherit_global_settings is False
1073 1136
1074 1137 def _patch_model(self, model):
@@ -79,21 +79,23 b' class TestPermissions(object):'
79 79 def cleanup(self):
80 80 if hasattr(self, 'test_repo'):
81 81 RepoModel().delete(repo=self.test_repo)
82 Session().commit()
82 83
83 84 if hasattr(self, 'g1'):
84 85 RepoGroupModel().delete(self.g1.group_id)
85 86 if hasattr(self, 'g2'):
86 87 RepoGroupModel().delete(self.g2.group_id)
88 Session().commit()
87 89
88 UserModel().delete(self.u1)
89 UserModel().delete(self.u2)
90 UserModel().delete(self.u3)
91 UserModel().delete(self.a1)
90 UserModel().delete(self.u1, handle_repos='delete', handle_repo_groups='delete')
91 UserModel().delete(self.u2, handle_repos='delete', handle_repo_groups='delete')
92 UserModel().delete(self.u3, handle_repos='delete', handle_repo_groups='delete')
93 UserModel().delete(self.a1, handle_repos='delete', handle_repo_groups='delete')
94 Session().commit()
92 95
93 96 if hasattr(self, 'ug1'):
94 97 UserGroupModel().delete(self.ug1, force=True)
95
96 Session().commit()
98 Session().commit()
97 99
98 100 def test_default_perms_set(self, repo_name):
99 101 assert repo_perms(self.u1)[repo_name] == 'repository.read'
@@ -183,6 +185,7 b' class TestPermissions(object):'
183 185 new_perm_gr = 'repository.write'
184 186 RepoModel().grant_user_group_permission(
185 187 repo=repo_name, group_name=self.ug1, perm=new_perm_gr)
188 Session().commit()
186 189
187 190 assert repo_perms(self.u1)[repo_name] == new_perm
188 191 assert group_perms(self.u1) == {}
@@ -197,6 +200,7 b' class TestPermissions(object):'
197 200 new_perm_gr = 'repository.write'
198 201 RepoModel().grant_user_group_permission(
199 202 repo=repo_name, group_name=self.ug1, perm=new_perm_gr)
203 Session().commit()
200 204
201 205 assert repo_perms(self.u3)[repo_name] == new_perm_gr
202 206 assert group_perms(self.u3) == {}
@@ -220,6 +224,7 b' class TestPermissions(object):'
220 224 new_perm_l = 'repository.read'
221 225 RepoModel().grant_user_group_permission(
222 226 repo=repo_name, group_name=self.ug1, perm=new_perm_l)
227 Session().commit()
223 228
224 229 assert repo_perms(self.u1)[repo_name] == new_perm_h
225 230 assert group_perms(self.u1) == {}
@@ -281,6 +286,8 b' class TestPermissions(object):'
281 286 # set default permission to none
282 287 RepoGroupModel().grant_user_permission(
283 288 repo_group=self.g1, user=self.anon, perm='group.none')
289 Session().commit()
290
284 291 # make group
285 292 self.ug1 = fixture.create_user_group('G1')
286 293 # add user to group
@@ -501,6 +508,7 b' class TestPermissions(object):'
501 508 UserGroupModel().add_user_to_group(self.ug1, self.u1)
502 509 RepoGroupModel().grant_user_group_permission(
503 510 repo_group=self.g1, group_name=self.ug1, perm='group.write')
511 Session().commit()
504 512
505 513 # Verify that user does not get any special permission if he is not
506 514 # owner
@@ -515,6 +523,7 b' class TestPermissions(object):'
515 523 self.g1 = fixture.create_repo_group('test1')
516 524 RepoGroupModel().grant_user_permission(
517 525 repo_group=self.g1, user=self.u1, perm='group.write')
526 Session().commit()
518 527
519 528 # Verify that user does not get any special permission if he is not
520 529 # owner
@@ -524,7 +533,7 b' class TestPermissions(object):'
524 533 self.g1.user = self.u1
525 534 assert group_perms(self.u1) == {u'test1': 'group.admin'}
526 535
527 def _test_def_user_perm_equal(
536 def assert_user_perm_equal(
528 537 self, user, change_factor=0, compare_keys=None):
529 538 perms = UserToPerm.query().filter(UserToPerm.user == user).all()
530 539 assert len(perms) == \
@@ -533,7 +542,7 b' class TestPermissions(object):'
533 542 assert set(
534 543 x.permissions.permission_name for x in perms) == compare_keys
535 544
536 def _test_def_user_group_perm_equal(
545 def assert_def_user_group_perm_equal(
537 546 self, user_group, change_factor=0, compare_keys=None):
538 547 perms = UserGroupToPerm.query().filter(
539 548 UserGroupToPerm.users_group == user_group).all()
@@ -545,21 +554,21 b' class TestPermissions(object):'
545 554
546 555 def test_set_default_permissions(self):
547 556 PermissionModel().create_default_user_permissions(user=self.u1)
548 self._test_def_user_perm_equal(user=self.u1)
557 self.assert_user_perm_equal(user=self.u1)
549 558
550 559 def test_set_default_permissions_after_one_is_missing(self):
551 560 PermissionModel().create_default_user_permissions(user=self.u1)
552 self._test_def_user_perm_equal(user=self.u1)
561 self.assert_user_perm_equal(user=self.u1)
553 562 # now we delete one, it should be re-created after another call
554 563 perms = UserToPerm.query().filter(UserToPerm.user == self.u1).all()
555 564 Session().delete(perms[0])
556 565 Session().commit()
557 566
558 self._test_def_user_perm_equal(user=self.u1, change_factor=-1)
567 self.assert_user_perm_equal(user=self.u1, change_factor=-1)
559 568
560 569 # create missing one !
561 570 PermissionModel().create_default_user_permissions(user=self.u1)
562 self._test_def_user_perm_equal(user=self.u1)
571 self.assert_user_perm_equal(user=self.u1)
563 572
564 573 @pytest.mark.parametrize("perm, modify_to", [
565 574 ('repository.read', 'repository.none'),
@@ -571,7 +580,7 b' class TestPermissions(object):'
571 580 ])
572 581 def test_set_default_permissions_after_modification(self, perm, modify_to):
573 582 PermissionModel().create_default_user_permissions(user=self.u1)
574 self._test_def_user_perm_equal(user=self.u1)
583 self.assert_user_perm_equal(user=self.u1)
575 584
576 585 old = Permission.get_by_key(perm)
577 586 new = Permission.get_by_key(modify_to)
@@ -587,28 +596,28 b' class TestPermissions(object):'
587 596 Session().commit()
588 597
589 598 PermissionModel().create_default_user_permissions(user=self.u1)
590 self._test_def_user_perm_equal(user=self.u1)
599 self.assert_user_perm_equal(user=self.u1)
591 600
592 601 def test_clear_user_perms(self):
593 602 PermissionModel().create_default_user_permissions(user=self.u1)
594 self._test_def_user_perm_equal(user=self.u1)
603 self.assert_user_perm_equal(user=self.u1)
595 604
596 605 # now clear permissions
597 606 cleared = PermissionModel()._clear_user_perms(self.u1.user_id)
598 self._test_def_user_perm_equal(user=self.u1,
599 change_factor=len(cleared)*-1)
607 self.assert_user_perm_equal(user=self.u1,
608 change_factor=len(cleared)*-1)
600 609
601 610 def test_clear_user_group_perms(self):
602 611 self.ug1 = fixture.create_user_group('G1')
603 612 PermissionModel().create_default_user_group_permissions(
604 613 user_group=self.ug1)
605 self._test_def_user_group_perm_equal(user_group=self.ug1)
614 self.assert_def_user_group_perm_equal(user_group=self.ug1)
606 615
607 616 # now clear permissions
608 617 cleared = PermissionModel()._clear_user_group_perms(
609 618 self.ug1.users_group_id)
610 self._test_def_user_group_perm_equal(user_group=self.ug1,
611 change_factor=len(cleared)*-1)
619 self.assert_def_user_group_perm_equal(user_group=self.ug1,
620 change_factor=len(cleared)*-1)
612 621
613 622 @pytest.mark.parametrize("form_result", [
614 623 {},
@@ -626,7 +635,7 b' class TestPermissions(object):'
626 635 Session().commit()
627 636 change_factor = -1 * (len(Permission.DEFAULT_USER_PERMISSIONS)
628 637 - len(form_result.keys()))
629 self._test_def_user_perm_equal(
638 self.assert_user_perm_equal(
630 639 self.u1, change_factor=change_factor)
631 640
632 641 @pytest.mark.parametrize("form_result", [
@@ -646,7 +655,7 b' class TestPermissions(object):'
646 655 Session().commit()
647 656 change_factor = -1 * (len(Permission.DEFAULT_USER_PERMISSIONS)
648 657 - len(form_result.keys()))
649 self._test_def_user_group_perm_equal(
658 self.assert_def_user_group_perm_equal(
650 659 self.ug1, change_factor=change_factor)
651 660
652 661 @pytest.mark.parametrize("group_active, expected_perm", [
@@ -124,6 +124,8 b' class TestPullRequestModel(object):'
124 124 PullRequestModel().update_reviewers(
125 125 pull_request, [(pull_request.author, ['author'], False, [])],
126 126 pull_request.author)
127 Session().commit()
128
127 129 prs = PullRequestModel().get_awaiting_my_review(
128 130 pull_request.target_repo, user_id=pull_request.author.user_id)
129 131 assert isinstance(prs, list)
@@ -133,6 +135,8 b' class TestPullRequestModel(object):'
133 135 PullRequestModel().update_reviewers(
134 136 pull_request, [(pull_request.author, ['author'], False, [])],
135 137 pull_request.author)
138 Session().commit()
139
136 140 pr_count = PullRequestModel().count_awaiting_my_review(
137 141 pull_request.target_repo, user_id=pull_request.author.user_id)
138 142 assert pr_count == 1
@@ -140,6 +144,7 b' class TestPullRequestModel(object):'
140 144 def test_delete_calls_cleanup_merge(self, pull_request):
141 145 repo_id = pull_request.target_repo.repo_id
142 146 PullRequestModel().delete(pull_request, pull_request.author)
147 Session().commit()
143 148
144 149 self.workspace_remove_mock.assert_called_once_with(
145 150 repo_id, self.workspace_id)
@@ -147,6 +152,8 b' class TestPullRequestModel(object):'
147 152 def test_close_calls_cleanup_and_hook(self, pull_request):
148 153 PullRequestModel().close_pull_request(
149 154 pull_request, pull_request.author)
155 Session().commit()
156
150 157 repo_id = pull_request.target_repo.repo_id
151 158
152 159 self.workspace_remove_mock.assert_called_once_with(
@@ -286,6 +293,7 b' class TestPullRequestModel(object):'
286 293 merge_extras['repository'] = pull_request.target_repo.repo_name
287 294 PullRequestModel().merge_repo(
288 295 pull_request, pull_request.author, extras=merge_extras)
296 Session().commit()
289 297
290 298 message = (
291 299 u'Merge pull request #{pr_id} from {source_repo} {source_ref_name}'
@@ -327,6 +335,7 b' class TestPullRequestModel(object):'
327 335 assert pull_request.pull_request_state == PullRequest.STATE_UPDATING
328 336 PullRequestModel().merge_repo(
329 337 pull_request, pull_request.author, extras=merge_extras)
338 Session().commit()
330 339
331 340 assert pull_request.pull_request_state == PullRequest.STATE_CREATED
332 341
@@ -367,6 +376,7 b' class TestPullRequestModel(object):'
367 376 merge_extras['repository'] = pull_request.target_repo.repo_name
368 377 PullRequestModel().merge_repo(
369 378 pull_request, pull_request.author, extras=merge_extras)
379 Session().commit()
370 380
371 381 message = (
372 382 u'Merge pull request #{pr_id} from {source_repo} {source_ref_name}'
@@ -442,6 +452,7 b' class TestIntegrationMerge(object):'
442 452 with mock.patch.dict(rhodecode.CONFIG, extra_config, clear=False):
443 453 merge_state = PullRequestModel().merge_repo(
444 454 pull_request, user_admin, extras=merge_extras)
455 Session().commit()
445 456
446 457 assert merge_state.executed
447 458 assert '_pre_push_hook' in capture_rcextensions
@@ -459,6 +470,7 b' class TestIntegrationMerge(object):'
459 470 pre_pull.side_effect = RepositoryError("Disallow push!")
460 471 merge_status = PullRequestModel().merge_repo(
461 472 pull_request, user_admin, extras=merge_extras)
473 Session().commit()
462 474
463 475 assert not merge_status.executed
464 476 assert 'pre_push' not in capture_rcextensions
@@ -479,6 +491,8 b' class TestIntegrationMerge(object):'
479 491 Session().commit()
480 492 merge_status = PullRequestModel().merge_repo(
481 493 pull_request, user_regular, extras=merge_extras)
494 Session().commit()
495
482 496 assert not merge_status.executed
483 497
484 498
@@ -889,6 +903,7 b' def test_link_comments_to_version_only_u'
889 903 version2 = pr_util.create_version_of_pull_request()
890 904
891 905 PullRequestModel()._link_comments_to_version(version2)
906 Session().commit()
892 907
893 908 # Expect that only the new comment is linked to version2
894 909 assert (
@@ -395,7 +395,7 b' class TestVCSOperations(object):'
395 395
396 396 user = user_util.create_user()
397 397 auth_token = AuthTokenModel().create(
398 user.user_id, 'test-token', -10, AuthTokenModel.cls.ROLE_VCS)
398 user.user_id, u'test-token', -10, AuthTokenModel.cls.ROLE_VCS)
399 399 token = auth_token.api_key
400 400
401 401 clone_url = rc_web_server.repo_clone_url(
@@ -412,7 +412,7 b' class TestVCSOperations(object):'
412 412
413 413 user = user_util.create_user()
414 414 auth_token = AuthTokenModel().create(
415 user.user_id, 'test-token', -1, AuthTokenModel.cls.ROLE_API)
415 user.user_id, u'test-token', -1, AuthTokenModel.cls.ROLE_API)
416 416 token = auth_token.api_key
417 417
418 418 clone_url = rc_web_server.repo_clone_url(
@@ -445,7 +445,7 b' class TestVCSOperations(object):'
445 445 'egg:rhodecode-enterprise-ce#rhodecode'])
446 446 user = user_util.create_user()
447 447 auth_token = AuthTokenModel().create(
448 user.user_id, 'test-token', -1, AuthTokenModel.cls.ROLE_VCS)
448 user.user_id, u'test-token', -1, AuthTokenModel.cls.ROLE_VCS)
449 449 token = auth_token.api_key
450 450
451 451 # manually set scope
@@ -466,7 +466,7 b' class TestVCSOperations(object):'
466 466 'egg:rhodecode-enterprise-ce#rhodecode'])
467 467 user = user_util.create_user()
468 468 auth_token = AuthTokenModel().create(
469 user.user_id, 'test-token', -1, AuthTokenModel.cls.ROLE_VCS)
469 user.user_id, u'test-token', -1, AuthTokenModel.cls.ROLE_VCS)
470 470 token = auth_token.api_key
471 471
472 472 # manually set scope
General Comments 0
You need to be logged in to leave comments. Login now