Show More
@@ -60,8 +60,7 b' log = logging.getLogger(__name__)' | |||||
60 | 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', |
|
60 | 'TEST_USER_REGULAR2_PASS', 'TEST_USER_REGULAR2_EMAIL', 'TEST_HG_REPO', | |
61 | 'TEST_HG_REPO_CLONE', 'TEST_HG_REPO_PULL', 'TEST_GIT_REPO', |
|
61 | 'TEST_HG_REPO_CLONE', 'TEST_HG_REPO_PULL', 'TEST_GIT_REPO', | |
62 | 'TEST_GIT_REPO_CLONE', 'TEST_GIT_REPO_PULL', 'HG_REMOTE_REPO', |
|
62 | 'TEST_GIT_REPO_CLONE', 'TEST_GIT_REPO_PULL', 'HG_REMOTE_REPO', | |
63 |
'GIT_REMOTE_REPO', 'SCM_TESTS', |
|
63 | 'GIT_REMOTE_REPO', 'SCM_TESTS', | |
64 | '_get_group_create_params' |
|
|||
65 | ] |
|
64 | ] | |
66 |
|
65 | |||
67 | # Invoke websetup with the current config file |
|
66 | # Invoke websetup with the current config file | |
@@ -174,37 +173,3 b' class TestController(TestCase):' | |||||
174 | msg = u'msg `%s` not found in session flash: got `%s` instead' % ( |
|
173 | msg = u'msg `%s` not found in session flash: got `%s` instead' % ( | |
175 | msg, response.session['flash'][0][1]) |
|
174 | msg, response.session['flash'][0][1]) | |
176 | self.fail(safe_str(msg)) |
|
175 | self.fail(safe_str(msg)) | |
177 |
|
||||
178 |
|
||||
179 | ## HELPERS ## |
|
|||
180 |
|
||||
181 | def _get_repo_create_params(**custom): |
|
|||
182 | defs = { |
|
|||
183 | 'repo_name': None, |
|
|||
184 | 'repo_type': 'hg', |
|
|||
185 | 'clone_uri': '', |
|
|||
186 | 'repo_group': '', |
|
|||
187 | 'repo_description': 'DESC', |
|
|||
188 | 'repo_private': False, |
|
|||
189 | 'repo_landing_rev': 'tip' |
|
|||
190 | } |
|
|||
191 | defs.update(custom) |
|
|||
192 | if 'repo_name_full' not in custom: |
|
|||
193 | defs.update({'repo_name_full': defs['repo_name']}) |
|
|||
194 |
|
||||
195 | return defs |
|
|||
196 |
|
||||
197 |
|
||||
198 | def _get_group_create_params(**custom): |
|
|||
199 | defs = dict( |
|
|||
200 | group_name=None, |
|
|||
201 | group_description='DESC', |
|
|||
202 | group_parent_id=None, |
|
|||
203 | perms_updates=[], |
|
|||
204 | perms_new=[], |
|
|||
205 | enable_locking=False, |
|
|||
206 | recursive=False |
|
|||
207 | ) |
|
|||
208 | defs.update(custom) |
|
|||
209 |
|
||||
210 | return defs |
|
@@ -3,6 +3,7 b' import random' | |||||
3 | import mock |
|
3 | import mock | |
4 |
|
4 | |||
5 | from rhodecode.tests import * |
|
5 | from rhodecode.tests import * | |
|
6 | from rhodecode.tests.fixture import Fixture | |||
6 | from rhodecode.lib.compat import json |
|
7 | from rhodecode.lib.compat import json | |
7 | from rhodecode.lib.auth import AuthUser |
|
8 | from rhodecode.lib.auth import AuthUser | |
8 | from rhodecode.model.user import UserModel |
|
9 | from rhodecode.model.user import UserModel | |
@@ -12,7 +13,11 b' from rhodecode.model.meta import Session' | |||||
12 | from rhodecode.model.scm import ScmModel |
|
13 | from rhodecode.model.scm import ScmModel | |
13 | from rhodecode.model.db import Repository |
|
14 | from rhodecode.model.db import Repository | |
14 |
|
15 | |||
|
16 | ||||
15 | API_URL = '/_admin/api' |
|
17 | API_URL = '/_admin/api' | |
|
18 | TEST_USER_GROUP = 'test_users_group' | |||
|
19 | ||||
|
20 | fixture = Fixture() | |||
16 |
|
21 | |||
17 |
|
22 | |||
18 | def _build_data(apikey, method, **kw): |
|
23 | def _build_data(apikey, method, **kw): | |
@@ -43,9 +48,7 b' def api_call(test_obj, params):' | |||||
43 | return response |
|
48 | return response | |
44 |
|
49 | |||
45 |
|
50 | |||
46 | TEST_USER_GROUP = 'test_users_group' |
|
51 | ## helpers | |
47 |
|
||||
48 |
|
||||
49 | def make_users_group(name=TEST_USER_GROUP): |
|
52 | def make_users_group(name=TEST_USER_GROUP): | |
50 | gr = UserGroupModel().create(name=name) |
|
53 | gr = UserGroupModel().create(name=name) | |
51 | UserGroupModel().add_user_to_group(users_group=gr, |
|
54 | UserGroupModel().add_user_to_group(users_group=gr, | |
@@ -59,32 +62,6 b' def destroy_users_group(name=TEST_USER_G' | |||||
59 | Session().commit() |
|
62 | Session().commit() | |
60 |
|
63 | |||
61 |
|
64 | |||
62 | def create_repo(repo_name, repo_type, owner=None): |
|
|||
63 | # create new repo |
|
|||
64 | form_data = _get_repo_create_params( |
|
|||
65 | repo_name_full=repo_name, |
|
|||
66 | repo_description='description %s' % repo_name, |
|
|||
67 | ) |
|
|||
68 | cur_user = UserModel().get_by_username(owner or TEST_USER_ADMIN_LOGIN) |
|
|||
69 | r = RepoModel().create(form_data, cur_user) |
|
|||
70 | Session().commit() |
|
|||
71 | return r |
|
|||
72 |
|
||||
73 |
|
||||
74 | def create_fork(fork_name, fork_type, fork_of): |
|
|||
75 | fork = RepoModel(Session())._get_repo(fork_of) |
|
|||
76 | r = create_repo(fork_name, fork_type) |
|
|||
77 | r.fork = fork |
|
|||
78 | Session().add(r) |
|
|||
79 | Session().commit() |
|
|||
80 | return r |
|
|||
81 |
|
||||
82 |
|
||||
83 | def destroy_repo(repo_name): |
|
|||
84 | RepoModel().delete(repo_name) |
|
|||
85 | Session().commit() |
|
|||
86 |
|
||||
87 |
|
||||
88 | class BaseTestApi(object): |
|
65 | class BaseTestApi(object): | |
89 | REPO = None |
|
66 | REPO = None | |
90 | REPO_TYPE = None |
|
67 | REPO_TYPE = None | |
@@ -248,7 +225,7 b' class BaseTestApi(object):' | |||||
248 | pass |
|
225 | pass | |
249 |
|
226 | |||
250 | # repo_name = 'test_pull' |
|
227 | # repo_name = 'test_pull' | |
251 | # r = create_repo(repo_name, self.REPO_TYPE) |
|
228 | # r = fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
252 | # r.clone_uri = TEST_self.REPO |
|
229 | # r.clone_uri = TEST_self.REPO | |
253 | # Session.add(r) |
|
230 | # Session.add(r) | |
254 | # Session.commit() |
|
231 | # Session.commit() | |
@@ -261,7 +238,7 b' class BaseTestApi(object):' | |||||
261 | # expected = 'Pulled from `%s`' % repo_name |
|
238 | # expected = 'Pulled from `%s`' % repo_name | |
262 | # self._compare_ok(id_, expected, given=response.body) |
|
239 | # self._compare_ok(id_, expected, given=response.body) | |
263 | # |
|
240 | # | |
264 | # destroy_repo(repo_name) |
|
241 | # fixture.destroy_repo(repo_name) | |
265 |
|
242 | |||
266 | def test_api_pull_error(self): |
|
243 | def test_api_pull_error(self): | |
267 | id_, params = _build_data(self.apikey, 'pull', |
|
244 | id_, params = _build_data(self.apikey, 'pull', | |
@@ -317,7 +294,8 b' class BaseTestApi(object):' | |||||
317 |
|
294 | |||
318 | def test_api_lock_repo_lock_aquire_by_non_admin(self): |
|
295 | def test_api_lock_repo_lock_aquire_by_non_admin(self): | |
319 | repo_name = 'api_delete_me' |
|
296 | repo_name = 'api_delete_me' | |
320 |
create_repo(repo_name, self.REPO_TYPE, |
|
297 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE, | |
|
298 | cur_user=self.TEST_USER_LOGIN) | |||
321 | try: |
|
299 | try: | |
322 | id_, params = _build_data(self.apikey_regular, 'lock', |
|
300 | id_, params = _build_data(self.apikey_regular, 'lock', | |
323 | repoid=repo_name, |
|
301 | repoid=repo_name, | |
@@ -327,11 +305,12 b' class BaseTestApi(object):' | |||||
327 | % (self.TEST_USER_LOGIN, repo_name, True)) |
|
305 | % (self.TEST_USER_LOGIN, repo_name, True)) | |
328 | self._compare_ok(id_, expected, given=response.body) |
|
306 | self._compare_ok(id_, expected, given=response.body) | |
329 | finally: |
|
307 | finally: | |
330 | destroy_repo(repo_name) |
|
308 | fixture.destroy_repo(repo_name) | |
331 |
|
309 | |||
332 | def test_api_lock_repo_lock_aquire_non_admin_with_userid(self): |
|
310 | def test_api_lock_repo_lock_aquire_non_admin_with_userid(self): | |
333 | repo_name = 'api_delete_me' |
|
311 | repo_name = 'api_delete_me' | |
334 |
create_repo(repo_name, self.REPO_TYPE, |
|
312 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE, | |
|
313 | cur_user=self.TEST_USER_LOGIN) | |||
335 | try: |
|
314 | try: | |
336 | id_, params = _build_data(self.apikey_regular, 'lock', |
|
315 | id_, params = _build_data(self.apikey_regular, 'lock', | |
337 | userid=TEST_USER_ADMIN_LOGIN, |
|
316 | userid=TEST_USER_ADMIN_LOGIN, | |
@@ -341,7 +320,7 b' class BaseTestApi(object):' | |||||
341 | expected = 'userid is not the same as your user' |
|
320 | expected = 'userid is not the same as your user' | |
342 | self._compare_error(id_, expected, given=response.body) |
|
321 | self._compare_error(id_, expected, given=response.body) | |
343 | finally: |
|
322 | finally: | |
344 | destroy_repo(repo_name) |
|
323 | fixture.destroy_repo(repo_name) | |
345 |
|
324 | |||
346 | def test_api_lock_repo_lock_aquire_non_admin_not_his_repo(self): |
|
325 | def test_api_lock_repo_lock_aquire_non_admin_not_his_repo(self): | |
347 | id_, params = _build_data(self.apikey_regular, 'lock', |
|
326 | id_, params = _build_data(self.apikey_regular, 'lock', | |
@@ -770,7 +749,7 b' class BaseTestApi(object):' | |||||
770 | } |
|
749 | } | |
771 | expected = ret |
|
750 | expected = ret | |
772 | self._compare_ok(id_, expected, given=response.body) |
|
751 | self._compare_ok(id_, expected, given=response.body) | |
773 | destroy_repo(repo_name) |
|
752 | fixture.destroy_repo(repo_name) | |
774 |
|
753 | |||
775 | def test_api_create_repo_unknown_owner(self): |
|
754 | def test_api_create_repo_unknown_owner(self): | |
776 | repo_name = 'api-repo' |
|
755 | repo_name = 'api-repo' | |
@@ -800,7 +779,7 b' class BaseTestApi(object):' | |||||
800 | } |
|
779 | } | |
801 | expected = ret |
|
780 | expected = ret | |
802 | self._compare_ok(id_, expected, given=response.body) |
|
781 | self._compare_ok(id_, expected, given=response.body) | |
803 | destroy_repo(repo_name) |
|
782 | fixture.destroy_repo(repo_name) | |
804 |
|
783 | |||
805 | def test_api_create_repo_by_non_admin(self): |
|
784 | def test_api_create_repo_by_non_admin(self): | |
806 | repo_name = 'api-repo' |
|
785 | repo_name = 'api-repo' | |
@@ -818,7 +797,7 b' class BaseTestApi(object):' | |||||
818 | } |
|
797 | } | |
819 | expected = ret |
|
798 | expected = ret | |
820 | self._compare_ok(id_, expected, given=response.body) |
|
799 | self._compare_ok(id_, expected, given=response.body) | |
821 | destroy_repo(repo_name) |
|
800 | fixture.destroy_repo(repo_name) | |
822 |
|
801 | |||
823 | def test_api_create_repo_by_non_admin_specify_owner(self): |
|
802 | def test_api_create_repo_by_non_admin_specify_owner(self): | |
824 | repo_name = 'api-repo' |
|
803 | repo_name = 'api-repo' | |
@@ -832,7 +811,7 b' class BaseTestApi(object):' | |||||
832 |
|
811 | |||
833 | expected = 'Only RhodeCode admin can specify `owner` param' |
|
812 | expected = 'Only RhodeCode admin can specify `owner` param' | |
834 | self._compare_error(id_, expected, given=response.body) |
|
813 | self._compare_error(id_, expected, given=response.body) | |
835 | destroy_repo(repo_name) |
|
814 | fixture.destroy_repo(repo_name) | |
836 |
|
815 | |||
837 | def test_api_create_repo_exists(self): |
|
816 | def test_api_create_repo_exists(self): | |
838 | repo_name = self.REPO |
|
817 | repo_name = self.REPO | |
@@ -859,7 +838,7 b' class BaseTestApi(object):' | |||||
859 |
|
838 | |||
860 | def test_api_delete_repo(self): |
|
839 | def test_api_delete_repo(self): | |
861 | repo_name = 'api_delete_me' |
|
840 | repo_name = 'api_delete_me' | |
862 | create_repo(repo_name, self.REPO_TYPE) |
|
841 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
863 |
|
842 | |||
864 | id_, params = _build_data(self.apikey, 'delete_repo', |
|
843 | id_, params = _build_data(self.apikey, 'delete_repo', | |
865 | repoid=repo_name,) |
|
844 | repoid=repo_name,) | |
@@ -874,7 +853,8 b' class BaseTestApi(object):' | |||||
874 |
|
853 | |||
875 | def test_api_delete_repo_by_non_admin(self): |
|
854 | def test_api_delete_repo_by_non_admin(self): | |
876 | repo_name = 'api_delete_me' |
|
855 | repo_name = 'api_delete_me' | |
877 |
create_repo(repo_name, self.REPO_TYPE, |
|
856 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE, | |
|
857 | cur_user=self.TEST_USER_LOGIN) | |||
878 | try: |
|
858 | try: | |
879 | id_, params = _build_data(self.apikey_regular, 'delete_repo', |
|
859 | id_, params = _build_data(self.apikey_regular, 'delete_repo', | |
880 | repoid=repo_name,) |
|
860 | repoid=repo_name,) | |
@@ -887,11 +867,11 b' class BaseTestApi(object):' | |||||
887 | expected = ret |
|
867 | expected = ret | |
888 | self._compare_ok(id_, expected, given=response.body) |
|
868 | self._compare_ok(id_, expected, given=response.body) | |
889 | finally: |
|
869 | finally: | |
890 | destroy_repo(repo_name) |
|
870 | fixture.destroy_repo(repo_name) | |
891 |
|
871 | |||
892 | def test_api_delete_repo_by_non_admin_no_permission(self): |
|
872 | def test_api_delete_repo_by_non_admin_no_permission(self): | |
893 | repo_name = 'api_delete_me' |
|
873 | repo_name = 'api_delete_me' | |
894 | create_repo(repo_name, self.REPO_TYPE) |
|
874 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
895 | try: |
|
875 | try: | |
896 | id_, params = _build_data(self.apikey_regular, 'delete_repo', |
|
876 | id_, params = _build_data(self.apikey_regular, 'delete_repo', | |
897 | repoid=repo_name,) |
|
877 | repoid=repo_name,) | |
@@ -899,11 +879,11 b' class BaseTestApi(object):' | |||||
899 | expected = 'repository `%s` does not exist' % (repo_name) |
|
879 | expected = 'repository `%s` does not exist' % (repo_name) | |
900 | self._compare_error(id_, expected, given=response.body) |
|
880 | self._compare_error(id_, expected, given=response.body) | |
901 | finally: |
|
881 | finally: | |
902 | destroy_repo(repo_name) |
|
882 | fixture.destroy_repo(repo_name) | |
903 |
|
883 | |||
904 | def test_api_delete_repo_exception_occurred(self): |
|
884 | def test_api_delete_repo_exception_occurred(self): | |
905 | repo_name = 'api_delete_me' |
|
885 | repo_name = 'api_delete_me' | |
906 | create_repo(repo_name, self.REPO_TYPE) |
|
886 | fixture.create_repo(repo_name, repo_type=self.REPO_TYPE) | |
907 | try: |
|
887 | try: | |
908 | with mock.patch.object(RepoModel, 'delete', crash): |
|
888 | with mock.patch.object(RepoModel, 'delete', crash): | |
909 | id_, params = _build_data(self.apikey, 'delete_repo', |
|
889 | id_, params = _build_data(self.apikey, 'delete_repo', | |
@@ -913,7 +893,7 b' class BaseTestApi(object):' | |||||
913 | expected = 'failed to delete repository `%s`' % repo_name |
|
893 | expected = 'failed to delete repository `%s`' % repo_name | |
914 | self._compare_error(id_, expected, given=response.body) |
|
894 | self._compare_error(id_, expected, given=response.body) | |
915 | finally: |
|
895 | finally: | |
916 | destroy_repo(repo_name) |
|
896 | fixture.destroy_repo(repo_name) | |
917 |
|
897 | |||
918 | def test_api_fork_repo(self): |
|
898 | def test_api_fork_repo(self): | |
919 | fork_name = 'api-repo-fork' |
|
899 | fork_name = 'api-repo-fork' | |
@@ -931,7 +911,7 b' class BaseTestApi(object):' | |||||
931 | } |
|
911 | } | |
932 | expected = ret |
|
912 | expected = ret | |
933 | self._compare_ok(id_, expected, given=response.body) |
|
913 | self._compare_ok(id_, expected, given=response.body) | |
934 | destroy_repo(fork_name) |
|
914 | fixture.destroy_repo(fork_name) | |
935 |
|
915 | |||
936 | def test_api_fork_repo_non_admin(self): |
|
916 | def test_api_fork_repo_non_admin(self): | |
937 | fork_name = 'api-repo-fork' |
|
917 | fork_name = 'api-repo-fork' | |
@@ -948,7 +928,7 b' class BaseTestApi(object):' | |||||
948 | } |
|
928 | } | |
949 | expected = ret |
|
929 | expected = ret | |
950 | self._compare_ok(id_, expected, given=response.body) |
|
930 | self._compare_ok(id_, expected, given=response.body) | |
951 | destroy_repo(fork_name) |
|
931 | fixture.destroy_repo(fork_name) | |
952 |
|
932 | |||
953 | def test_api_fork_repo_non_admin_specify_owner(self): |
|
933 | def test_api_fork_repo_non_admin_specify_owner(self): | |
954 | fork_name = 'api-repo-fork' |
|
934 | fork_name = 'api-repo-fork' | |
@@ -960,7 +940,7 b' class BaseTestApi(object):' | |||||
960 | response = api_call(self, params) |
|
940 | response = api_call(self, params) | |
961 | expected = 'Only RhodeCode admin can specify `owner` param' |
|
941 | expected = 'Only RhodeCode admin can specify `owner` param' | |
962 | self._compare_error(id_, expected, given=response.body) |
|
942 | self._compare_error(id_, expected, given=response.body) | |
963 | destroy_repo(fork_name) |
|
943 | fixture.destroy_repo(fork_name) | |
964 |
|
944 | |||
965 | def test_api_fork_repo_non_admin_no_permission_to_fork(self): |
|
945 | def test_api_fork_repo_non_admin_no_permission_to_fork(self): | |
966 | RepoModel().grant_user_permission(repo=self.REPO, |
|
946 | RepoModel().grant_user_permission(repo=self.REPO, | |
@@ -974,7 +954,7 b' class BaseTestApi(object):' | |||||
974 | response = api_call(self, params) |
|
954 | response = api_call(self, params) | |
975 | expected = 'repository `%s` does not exist' % (self.REPO) |
|
955 | expected = 'repository `%s` does not exist' % (self.REPO) | |
976 | self._compare_error(id_, expected, given=response.body) |
|
956 | self._compare_error(id_, expected, given=response.body) | |
977 | destroy_repo(fork_name) |
|
957 | fixture.destroy_repo(fork_name) | |
978 |
|
958 | |||
979 | def test_api_fork_repo_unknown_owner(self): |
|
959 | def test_api_fork_repo_unknown_owner(self): | |
980 | fork_name = 'api-repo-fork' |
|
960 | fork_name = 'api-repo-fork' | |
@@ -990,7 +970,7 b' class BaseTestApi(object):' | |||||
990 |
|
970 | |||
991 | def test_api_fork_repo_fork_exists(self): |
|
971 | def test_api_fork_repo_fork_exists(self): | |
992 | fork_name = 'api-repo-fork' |
|
972 | fork_name = 'api-repo-fork' | |
993 | create_fork(fork_name, self.REPO_TYPE, self.REPO) |
|
973 | fixture.create_fork(self.REPO, fork_name) | |
994 |
|
974 | |||
995 | try: |
|
975 | try: | |
996 | fork_name = 'api-repo-fork' |
|
976 | fork_name = 'api-repo-fork' | |
@@ -1005,7 +985,7 b' class BaseTestApi(object):' | |||||
1005 | expected = "fork `%s` already exist" % fork_name |
|
985 | expected = "fork `%s` already exist" % fork_name | |
1006 | self._compare_error(id_, expected, given=response.body) |
|
986 | self._compare_error(id_, expected, given=response.body) | |
1007 | finally: |
|
987 | finally: | |
1008 | destroy_repo(fork_name) |
|
988 | fixture.destroy_repo(fork_name) | |
1009 |
|
989 | |||
1010 | def test_api_fork_repo_repo_exists(self): |
|
990 | def test_api_fork_repo_repo_exists(self): | |
1011 | fork_name = self.REPO |
|
991 | fork_name = self.REPO |
@@ -1,12 +1,11 b'' | |||||
1 | """ |
|
1 | """ | |
2 | Helpers for fixture generation |
|
2 | Helpers for fixture generation | |
3 | """ |
|
3 | """ | |
4 | import os |
|
|||
5 | import unittest |
|
|||
6 | from rhodecode.tests import * |
|
4 | from rhodecode.tests import * | |
7 | from rhodecode.model.db import Repository, User |
|
5 | from rhodecode.model.db import Repository, User, RepoGroup | |
8 | from rhodecode.model.meta import Session |
|
6 | from rhodecode.model.meta import Session | |
9 | from rhodecode.model.repo import RepoModel |
|
7 | from rhodecode.model.repo import RepoModel | |
|
8 | from rhodecode.model.repos_group import ReposGroupModel | |||
10 |
|
9 | |||
11 |
|
10 | |||
12 | class Fixture(object): |
|
11 | class Fixture(object): | |
@@ -14,30 +13,90 b' class Fixture(object):' | |||||
14 | def __init__(self): |
|
13 | def __init__(self): | |
15 | pass |
|
14 | pass | |
16 |
|
15 | |||
|
16 | def _get_repo_create_params(self, **custom): | |||
|
17 | defs = dict( | |||
|
18 | repo_name=None, | |||
|
19 | repo_type='hg', | |||
|
20 | clone_uri='', | |||
|
21 | repo_group='', | |||
|
22 | repo_description='DESC', | |||
|
23 | repo_private=False, | |||
|
24 | repo_landing_rev='tip' | |||
|
25 | ) | |||
|
26 | defs.update(custom) | |||
|
27 | if 'repo_name_full' not in custom: | |||
|
28 | defs.update({'repo_name_full': defs['repo_name']}) | |||
|
29 | ||||
|
30 | return defs | |||
|
31 | ||||
|
32 | def _get_group_create_params(self, **custom): | |||
|
33 | defs = dict( | |||
|
34 | group_name=None, | |||
|
35 | group_description='DESC', | |||
|
36 | group_parent_id=None, | |||
|
37 | perms_updates=[], | |||
|
38 | perms_new=[], | |||
|
39 | enable_locking=False, | |||
|
40 | recursive=False | |||
|
41 | ) | |||
|
42 | defs.update(custom) | |||
|
43 | ||||
|
44 | return defs | |||
|
45 | ||||
17 | def create_repo(self, name, **kwargs): |
|
46 | def create_repo(self, name, **kwargs): | |
18 | form_data = _get_repo_create_params(repo_name=name, **kwargs) |
|
47 | if 'skip_if_exists' in kwargs: | |
19 | cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
48 | del kwargs['skip_if_exists'] | |
|
49 | r = Repository.get_by_repo_name(name) | |||
|
50 | if r: | |||
|
51 | return r | |||
|
52 | ||||
|
53 | if isinstance(kwargs.get('repos_group'), RepoGroup): | |||
|
54 | #TODO: rename the repos_group ! | |||
|
55 | kwargs['repo_group'] = kwargs['repos_group'].group_id | |||
|
56 | del kwargs['repos_group'] | |||
|
57 | ||||
|
58 | form_data = self._get_repo_create_params(repo_name=name, **kwargs) | |||
|
59 | cur_user = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |||
20 | RepoModel().create(form_data, cur_user) |
|
60 | RepoModel().create(form_data, cur_user) | |
|
61 | Session().commit() | |||
21 | return Repository.get_by_repo_name(name) |
|
62 | return Repository.get_by_repo_name(name) | |
22 |
|
63 | |||
23 | def create_fork(self, repo_to_fork, fork_name, **kwargs): |
|
64 | def create_fork(self, repo_to_fork, fork_name, **kwargs): | |
24 | repo_to_fork = Repository.get_by_repo_name(repo_to_fork) |
|
65 | repo_to_fork = Repository.get_by_repo_name(repo_to_fork) | |
25 | vcs_type = repo_to_fork.repo_type |
|
66 | ||
|
67 | form_data = self._get_repo_create_params(repo_name=fork_name, | |||
|
68 | fork_parent_id=repo_to_fork, | |||
|
69 | repo_type=repo_to_fork.repo_type, | |||
|
70 | **kwargs) | |||
|
71 | form_data['update_after_clone'] = False | |||
|
72 | ||||
|
73 | #TODO: fix it !! | |||
|
74 | form_data['description'] = form_data['repo_description'] | |||
|
75 | form_data['private'] = form_data['repo_private'] | |||
|
76 | form_data['landing_rev'] = form_data['repo_landing_rev'] | |||
|
77 | ||||
|
78 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |||
|
79 | RepoModel().create_fork(form_data, cur_user=owner) | |||
|
80 | Session().commit() | |||
|
81 | r = Repository.get_by_repo_name(fork_name) | |||
|
82 | assert r | |||
|
83 | return r | |||
26 |
|
84 | |||
27 | form_data = dict( |
|
85 | def destroy_repo(self, repo_name): | |
28 | repo_name=fork_name, |
|
86 | RepoModel().delete(repo_name) | |
29 | repo_name_full=fork_name, |
|
87 | Session().commit() | |
30 | repo_group=None, |
|
|||
31 | repo_type=vcs_type, |
|
|||
32 | description='', |
|
|||
33 | private=False, |
|
|||
34 | copy_permissions=False, |
|
|||
35 | landing_rev='tip', |
|
|||
36 | update_after_clone=False, |
|
|||
37 | fork_parent_id=repo_to_fork, |
|
|||
38 | ) |
|
|||
39 | cur_user = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) |
|
|||
40 | RepoModel().create_fork(form_data, cur_user=cur_user) |
|
|||
41 |
|
88 | |||
|
89 | def create_group(self, name, **kwargs): | |||
|
90 | if 'skip_if_exists' in kwargs: | |||
|
91 | del kwargs['skip_if_exists'] | |||
|
92 | gr = RepoGroup.get_by_group_name(group_name=name) | |||
|
93 | if gr: | |||
|
94 | return gr | |||
|
95 | form_data = self._get_group_create_params(group_name=name, **kwargs) | |||
|
96 | owner = kwargs.get('cur_user', TEST_USER_ADMIN_LOGIN) | |||
|
97 | gr = ReposGroupModel().create(group_name=form_data['group_name'], | |||
|
98 | group_description=form_data['group_name'], | |||
|
99 | owner=owner, parent=form_data['group_parent_id']) | |||
42 | Session().commit() |
|
100 | Session().commit() | |
43 |
|
|
101 | gr = RepoGroup.get_by_group_name(gr.group_name) | |
|
102 | return gr |
@@ -10,6 +10,9 b' from rhodecode.tests import *' | |||||
10 | from rhodecode.model.repos_group import ReposGroupModel |
|
10 | from rhodecode.model.repos_group import ReposGroupModel | |
11 | from rhodecode.model.repo import RepoModel |
|
11 | from rhodecode.model.repo import RepoModel | |
12 | from rhodecode.model.meta import Session |
|
12 | from rhodecode.model.meta import Session | |
|
13 | from rhodecode.tests.fixture import Fixture | |||
|
14 | ||||
|
15 | fixture = Fixture() | |||
13 |
|
16 | |||
14 |
|
17 | |||
15 | def _get_permission_for_user(user, repo): |
|
18 | def _get_permission_for_user(user, repo): | |
@@ -36,7 +39,7 b' class TestAdminReposController(TestContr' | |||||
36 | repo_name = NEW_HG_REPO |
|
39 | repo_name = NEW_HG_REPO | |
37 | description = 'description for newly created repo' |
|
40 | description = 'description for newly created repo' | |
38 | response = self.app.post(url('repos'), |
|
41 | response = self.app.post(url('repos'), | |
39 | _get_repo_create_params(repo_private=False, |
|
42 | fixture._get_repo_create_params(repo_private=False, | |
40 | repo_name=repo_name, |
|
43 | repo_name=repo_name, | |
41 | repo_description=description)) |
|
44 | repo_description=description)) | |
42 | self.checkSessionFlash(response, |
|
45 | self.checkSessionFlash(response, | |
@@ -70,7 +73,7 b' class TestAdminReposController(TestContr' | |||||
70 | description_unicode = description.decode('utf8') |
|
73 | description_unicode = description.decode('utf8') | |
71 | private = False |
|
74 | private = False | |
72 | response = self.app.post(url('repos'), |
|
75 | response = self.app.post(url('repos'), | |
73 | _get_repo_create_params(repo_private=False, |
|
76 | fixture._get_repo_create_params(repo_private=False, | |
74 | repo_name=repo_name, |
|
77 | repo_name=repo_name, | |
75 | repo_description=description)) |
|
78 | repo_description=description)) | |
76 | self.checkSessionFlash(response, |
|
79 | self.checkSessionFlash(response, | |
@@ -108,7 +111,7 b' class TestAdminReposController(TestContr' | |||||
108 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) |
|
111 | repo_name_full = RepoGroup.url_sep().join([group_name, repo_name]) | |
109 | description = 'description for newly created repo' |
|
112 | description = 'description for newly created repo' | |
110 | response = self.app.post(url('repos'), |
|
113 | response = self.app.post(url('repos'), | |
111 | _get_repo_create_params(repo_private=False, |
|
114 | fixture._get_repo_create_params(repo_private=False, | |
112 | repo_name=repo_name, |
|
115 | repo_name=repo_name, | |
113 | repo_description=description, |
|
116 | repo_description=description, | |
114 | repo_group=gr.group_id,)) |
|
117 | repo_group=gr.group_id,)) | |
@@ -146,7 +149,7 b' class TestAdminReposController(TestContr' | |||||
146 | description = 'description for newly created repo' |
|
149 | description = 'description for newly created repo' | |
147 |
|
150 | |||
148 | response = self.app.post(url('repos'), |
|
151 | response = self.app.post(url('repos'), | |
149 | _get_repo_create_params(repo_private=False, |
|
152 | fixture._get_repo_create_params(repo_private=False, | |
150 | repo_type='git', |
|
153 | repo_type='git', | |
151 | repo_name=repo_name, |
|
154 | repo_name=repo_name, | |
152 | repo_description=description)) |
|
155 | repo_description=description)) | |
@@ -181,7 +184,7 b' class TestAdminReposController(TestContr' | |||||
181 | description_unicode = description.decode('utf8') |
|
184 | description_unicode = description.decode('utf8') | |
182 | private = False |
|
185 | private = False | |
183 | response = self.app.post(url('repos'), |
|
186 | response = self.app.post(url('repos'), | |
184 | _get_repo_create_params(repo_private=False, |
|
187 | fixture._get_repo_create_params(repo_private=False, | |
185 | repo_type='git', |
|
188 | repo_type='git', | |
186 | repo_name=repo_name, |
|
189 | repo_name=repo_name, | |
187 | repo_description=description)) |
|
190 | repo_description=description)) | |
@@ -220,7 +223,7 b' class TestAdminReposController(TestContr' | |||||
220 | repo_name = 'vcs_test_new_to_delete' |
|
223 | repo_name = 'vcs_test_new_to_delete' | |
221 | description = 'description for newly created repo' |
|
224 | description = 'description for newly created repo' | |
222 | response = self.app.post(url('repos'), |
|
225 | response = self.app.post(url('repos'), | |
223 | _get_repo_create_params(repo_private=False, |
|
226 | fixture._get_repo_create_params(repo_private=False, | |
224 | repo_type='hg', |
|
227 | repo_type='hg', | |
225 | repo_name=repo_name, |
|
228 | repo_name=repo_name, | |
226 | repo_description=description)) |
|
229 | repo_description=description)) | |
@@ -267,7 +270,7 b' class TestAdminReposController(TestContr' | |||||
267 | description = 'description for newly created repo' |
|
270 | description = 'description for newly created repo' | |
268 | private = False |
|
271 | private = False | |
269 | response = self.app.post(url('repos'), |
|
272 | response = self.app.post(url('repos'), | |
270 | _get_repo_create_params(repo_private=False, |
|
273 | fixture._get_repo_create_params(repo_private=False, | |
271 | repo_type='git', |
|
274 | repo_type='git', | |
272 | repo_name=repo_name, |
|
275 | repo_name=repo_name, | |
273 | repo_description=description)) |
|
276 | repo_description=description)) | |
@@ -337,7 +340,7 b' class TestAdminReposController(TestContr' | |||||
337 | self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) |
|
340 | self.assertEqual(Repository.get_by_repo_name(HG_REPO).private, False) | |
338 |
|
341 | |||
339 | response = self.app.put(url('repo', repo_name=HG_REPO), |
|
342 | response = self.app.put(url('repo', repo_name=HG_REPO), | |
340 | _get_repo_create_params(repo_private=1, |
|
343 | fixture._get_repo_create_params(repo_private=1, | |
341 | repo_name=HG_REPO, |
|
344 | repo_name=HG_REPO, | |
342 | user=TEST_USER_ADMIN_LOGIN)) |
|
345 | user=TEST_USER_ADMIN_LOGIN)) | |
343 | self.checkSessionFlash(response, |
|
346 | self.checkSessionFlash(response, | |
@@ -350,7 +353,7 b' class TestAdminReposController(TestContr' | |||||
350 | self.assertEqual(perm[0].permission.permission_name, 'repository.none') |
|
353 | self.assertEqual(perm[0].permission.permission_name, 'repository.none') | |
351 |
|
354 | |||
352 | response = self.app.put(url('repo', repo_name=HG_REPO), |
|
355 | response = self.app.put(url('repo', repo_name=HG_REPO), | |
353 | _get_repo_create_params(repo_private=False, |
|
356 | fixture._get_repo_create_params(repo_private=False, | |
354 | repo_name=HG_REPO, |
|
357 | repo_name=HG_REPO, | |
355 | user=TEST_USER_ADMIN_LOGIN)) |
|
358 | user=TEST_USER_ADMIN_LOGIN)) | |
356 | self.checkSessionFlash(response, |
|
359 | self.checkSessionFlash(response, |
@@ -52,10 +52,9 b' class TestCompareController(TestControll' | |||||
52 |
|
52 | |||
53 | def test_compare_forks_on_branch_extra_commits_hg(self): |
|
53 | def test_compare_forks_on_branch_extra_commits_hg(self): | |
54 | self.log_user() |
|
54 | self.log_user() | |
55 |
repo1 = |
|
55 | repo1 = fixture.create_repo('one', repo_type='hg', | |
56 |
|
|
56 | repo_description='diff-test', | |
57 |
|
|
57 | cur_user=TEST_USER_ADMIN_LOGIN) | |
58 | Session().commit() |
|
|||
59 | self.r1_id = repo1.repo_id |
|
58 | self.r1_id = repo1.repo_id | |
60 | #commit something ! |
|
59 | #commit something ! | |
61 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', |
|
60 | cs0 = _commit_change(repo1.repo_name, filename='file1', content='line1\n', | |
@@ -102,10 +101,10 b' class TestCompareController(TestControll' | |||||
102 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): |
|
101 | def test_compare_forks_on_branch_extra_commits_origin_has_incomming_hg(self): | |
103 | self.log_user() |
|
102 | self.log_user() | |
104 |
|
103 | |||
105 |
repo1 = |
|
104 | repo1 = fixture.create_repo('one', repo_type='hg', | |
106 |
|
|
105 | repo_description='diff-test', | |
107 |
|
|
106 | cur_user=TEST_USER_ADMIN_LOGIN) | |
108 | Session().commit() |
|
107 | ||
109 | self.r1_id = repo1.repo_id |
|
108 | self.r1_id = repo1.repo_id | |
110 |
|
109 | |||
111 | #commit something ! |
|
110 | #commit something ! | |
@@ -168,10 +167,9 b' class TestCompareController(TestControll' | |||||
168 | #make repo1, and cs1+cs2 |
|
167 | #make repo1, and cs1+cs2 | |
169 | self.log_user() |
|
168 | self.log_user() | |
170 |
|
169 | |||
171 |
repo1 = |
|
170 | repo1 = fixture.create_repo('repo1', repo_type='hg', | |
172 |
|
|
171 | repo_description='diff-test', | |
173 |
|
|
172 | cur_user=TEST_USER_ADMIN_LOGIN) | |
174 | Session().commit() |
|
|||
175 | self.r1_id = repo1.repo_id |
|
173 | self.r1_id = repo1.repo_id | |
176 |
|
174 | |||
177 | #commit something ! |
|
175 | #commit something ! | |
@@ -196,7 +194,7 b' class TestCompareController(TestControll' | |||||
196 | response = self.app.get(url(controller='compare', action='index', |
|
194 | response = self.app.get(url(controller='compare', action='index', | |
197 | repo_name=repo2.repo_name, |
|
195 | repo_name=repo2.repo_name, | |
198 | org_ref_type="rev", |
|
196 | org_ref_type="rev", | |
199 | org_ref=cs1.short_id, # parent of cs2, in repo2 |
|
197 | org_ref=cs1.short_id, # parent of cs2, in repo2 | |
200 | other_repo=repo1.repo_name, |
|
198 | other_repo=repo1.repo_name, | |
201 | other_ref_type="rev", |
|
199 | other_ref_type="rev", | |
202 | other_ref=cs4.short_id, |
|
200 | other_ref=cs4.short_id, | |
@@ -230,10 +228,9 b' class TestCompareController(TestControll' | |||||
230 | # |
|
228 | # | |
231 | #make repo1, and cs1+cs2 |
|
229 | #make repo1, and cs1+cs2 | |
232 | self.log_user() |
|
230 | self.log_user() | |
233 |
repo1 = |
|
231 | repo1 = fixture.create_repo('repo1', repo_type='hg', | |
234 |
|
|
232 | repo_description='diff-test', | |
235 |
|
|
233 | cur_user=TEST_USER_ADMIN_LOGIN) | |
236 | Session().commit() |
|
|||
237 | self.r1_id = repo1.repo_id |
|
234 | self.r1_id = repo1.repo_id | |
238 |
|
235 | |||
239 | #commit something ! |
|
236 | #commit something ! | |
@@ -278,9 +275,6 b' class TestCompareController(TestControll' | |||||
278 | response.mustcontain("""#C--826e8142e6ba">file1</a>""") |
|
275 | response.mustcontain("""#C--826e8142e6ba">file1</a>""") | |
279 |
|
276 | |||
280 | def test_compare_cherry_pick_changeset_mixed_branches(self): |
|
277 | def test_compare_cherry_pick_changeset_mixed_branches(self): | |
281 | """ |
|
|||
282 |
|
||||
283 | """ |
|
|||
284 | pass |
|
278 | pass | |
285 | #TODO write this tastecase |
|
279 | #TODO write this tastecase | |
286 |
|
280 | |||
@@ -316,11 +310,10 b' class TestCompareController(TestControll' | |||||
316 | def test_org_repo_new_commits_after_forking_simple_diff(self): |
|
310 | def test_org_repo_new_commits_after_forking_simple_diff(self): | |
317 | self.log_user() |
|
311 | self.log_user() | |
318 |
|
312 | |||
319 |
repo1 = |
|
313 | repo1 = fixture.create_repo('one', repo_type='hg', | |
320 |
|
|
314 | repo_description='diff-test', | |
321 |
|
|
315 | cur_user=TEST_USER_ADMIN_LOGIN) | |
322 |
|
316 | |||
323 | Session().commit() |
|
|||
324 | self.r1_id = repo1.repo_id |
|
317 | self.r1_id = repo1.repo_id | |
325 | r1_name = repo1.repo_name |
|
318 | r1_name = repo1.repo_name | |
326 |
|
319 | |||
@@ -336,10 +329,11 b' class TestCompareController(TestControll' | |||||
336 | Session().commit() |
|
329 | Session().commit() | |
337 | self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) |
|
330 | self.assertEqual(repo1.scm_instance.revisions, [cs0.raw_id]) | |
338 | #fork the repo1 |
|
331 | #fork the repo1 | |
339 |
repo2 = |
|
332 | repo2 = fixture.create_repo('one-fork', repo_type='hg', | |
340 |
description=' |
|
333 | repo_description='diff-test', | |
341 |
|
|
334 | cur_user=TEST_USER_ADMIN_LOGIN, | |
342 | owner=TEST_USER_ADMIN_LOGIN, fork_of='one') |
|
335 | clone_uri=repo1.repo_full_path, | |
|
336 | fork_of='one') | |||
343 | Session().commit() |
|
337 | Session().commit() | |
344 | self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) |
|
338 | self.assertEqual(repo2.scm_instance.revisions, [cs0.raw_id]) | |
345 | self.r2_id = repo2.repo_id |
|
339 | self.r2_id = repo2.repo_id |
@@ -1,13 +1,15 b'' | |||||
1 | import time |
|
1 | import time | |
2 | from rhodecode.tests import * |
|
2 | from rhodecode.tests import * | |
|
3 | from rhodecode.tests.fixture import Fixture | |||
3 | from rhodecode.model.meta import Session |
|
4 | from rhodecode.model.meta import Session | |
4 |
from rhodecode.model.db import User, |
|
5 | from rhodecode.model.db import User, Repository | |
5 | from rhodecode.lib.utils import set_rhodecode_config |
|
|||
6 | from rhodecode.tests.models.common import _make_repo, _make_group |
|
|||
7 | from rhodecode.model.repo import RepoModel |
|
6 | from rhodecode.model.repo import RepoModel | |
8 | from rhodecode.model.repos_group import ReposGroupModel |
|
7 | from rhodecode.model.repos_group import ReposGroupModel | |
9 |
|
8 | |||
10 |
|
9 | |||
|
10 | fixture = Fixture() | |||
|
11 | ||||
|
12 | ||||
11 | class TestHomeController(TestController): |
|
13 | class TestHomeController(TestController): | |
12 |
|
14 | |||
13 | def test_index(self): |
|
15 | def test_index(self): | |
@@ -75,18 +77,19 b' merge" class="tooltip" href="/vcs_test_h' | |||||
75 |
|
77 | |||
76 | try: |
|
78 | try: | |
77 | response = self.app.get(url(controller='home', action='index')) |
|
79 | response = self.app.get(url(controller='home', action='index')) | |
78 |
response.mustcontain("""var data = {"totalRecords": %s""" |
|
80 | response.mustcontain("""var data = {"totalRecords": %s""" | |
|
81 | % len(Repository.getAll())) | |||
79 | finally: |
|
82 | finally: | |
80 | self._set_l_dash(False) |
|
83 | self._set_l_dash(False) | |
81 |
|
84 | |||
82 | def test_index_page_on_groups(self): |
|
85 | def test_index_page_on_groups(self): | |
83 | self.log_user() |
|
86 | self.log_user() | |
84 | _make_repo(name='gr1/repo_in_group', repos_group=_make_group('gr1')) |
|
87 | gr = fixture.create_group('gr1') | |
85 | Session().commit() |
|
88 | fixture.create_repo(name='gr1/repo_in_group', repos_group=gr) | |
86 | response = self.app.get(url('repos_group_home', group_name='gr1')) |
|
89 | response = self.app.get(url('repos_group_home', group_name='gr1')) | |
87 |
|
90 | |||
88 | try: |
|
91 | try: | |
89 |
response.mustcontain(" |
|
92 | response.mustcontain("gr1/repo_in_group") | |
90 | finally: |
|
93 | finally: | |
91 | RepoModel().delete('gr1/repo_in_group') |
|
94 | RepoModel().delete('gr1/repo_in_group') | |
92 | ReposGroupModel().delete(repos_group='gr1', force_delete=True) |
|
95 | ReposGroupModel().delete(repos_group='gr1', force_delete=True) | |
@@ -95,8 +98,8 b' merge" class="tooltip" href="/vcs_test_h' | |||||
95 | def test_index_page_on_groups_with_lightweight_dashboard(self): |
|
98 | def test_index_page_on_groups_with_lightweight_dashboard(self): | |
96 | self.log_user() |
|
99 | self.log_user() | |
97 | self._set_l_dash(True) |
|
100 | self._set_l_dash(True) | |
98 |
|
|
101 | fixture.create_repo(name='gr1/repo_in_group', | |
99 | Session().commit() |
|
102 | repos_group=fixture.create_group('gr1')) | |
100 | response = self.app.get(url('repos_group_home', group_name='gr1')) |
|
103 | response = self.app.get(url('repos_group_home', group_name='gr1')) | |
101 |
|
104 | |||
102 | try: |
|
105 | try: |
@@ -1,10 +1,12 b'' | |||||
1 | from rhodecode.tests import * |
|
1 | from rhodecode.tests import * | |
|
2 | from rhodecode.tests.fixture import Fixture | |||
2 | from rhodecode.model.db import Repository |
|
3 | from rhodecode.model.db import Repository | |
3 | from rhodecode.lib.utils import invalidate_cache |
|
4 | from rhodecode.lib.utils import invalidate_cache | |
4 | from rhodecode.model.repo import RepoModel |
|
5 | from rhodecode.model.repo import RepoModel | |
5 | from rhodecode.tests.models.common import _make_repo |
|
|||
6 | from rhodecode.model.meta import Session |
|
6 | from rhodecode.model.meta import Session | |
7 |
|
7 | |||
|
8 | fixture = Fixture() | |||
|
9 | ||||
8 |
|
10 | |||
9 | class TestSummaryController(TestController): |
|
11 | class TestSummaryController(TestController): | |
10 |
|
12 | |||
@@ -87,14 +89,13 b' class TestSummaryController(TestControll' | |||||
87 |
|
89 | |||
88 | def test_index_by_repo_having_id_path_in_name_hg(self): |
|
90 | def test_index_by_repo_having_id_path_in_name_hg(self): | |
89 | self.log_user() |
|
91 | self.log_user() | |
90 |
|
|
92 | fixture.create_repo(name='repo_1') | |
91 | Session().commit() |
|
|||
92 | response = self.app.get(url(controller='summary', |
|
93 | response = self.app.get(url(controller='summary', | |
93 | action='index', |
|
94 | action='index', | |
94 | repo_name='repo_1')) |
|
95 | repo_name='repo_1')) | |
95 |
|
96 | |||
96 | try: |
|
97 | try: | |
97 |
response.mustcontain(" |
|
98 | response.mustcontain("repo_1") | |
98 | finally: |
|
99 | finally: | |
99 | RepoModel().delete(Repository.get_by_repo_name('repo_1')) |
|
100 | RepoModel().delete(Repository.get_by_repo_name('repo_1')) | |
100 | Session().commit() |
|
101 | Session().commit() |
@@ -2,7 +2,7 b' import os' | |||||
2 | import unittest |
|
2 | import unittest | |
3 | import functools |
|
3 | import functools | |
4 | from rhodecode.tests import * |
|
4 | from rhodecode.tests import * | |
5 |
|
5 | from rhodecode.tests.fixture import Fixture | ||
6 |
|
6 | |||
7 | from rhodecode.model.repos_group import ReposGroupModel |
|
7 | from rhodecode.model.repos_group import ReposGroupModel | |
8 | from rhodecode.model.repo import RepoModel |
|
8 | from rhodecode.model.repo import RepoModel | |
@@ -13,23 +13,7 b' from rhodecode.lib.auth import AuthUser' | |||||
13 | from rhodecode.model.meta import Session |
|
13 | from rhodecode.model.meta import Session | |
14 |
|
14 | |||
15 |
|
15 | |||
16 | def _make_group(path, desc='desc', parent_id=None, |
|
16 | fixture = Fixture() | |
17 | skip_if_exists=False): |
|
|||
18 |
|
||||
19 | gr = RepoGroup.get_by_group_name(path) |
|
|||
20 | if gr and skip_if_exists: |
|
|||
21 | return gr |
|
|||
22 | if isinstance(parent_id, RepoGroup): |
|
|||
23 | parent_id = parent_id.group_id |
|
|||
24 | gr = ReposGroupModel().create(path, desc, TEST_USER_ADMIN_LOGIN, parent_id) |
|
|||
25 | return gr |
|
|||
26 |
|
||||
27 |
|
||||
28 | def _make_repo(name, repos_group=None, repo_type='hg', private=False): |
|
|||
29 | return RepoModel().create_repo(name, repo_type, 'desc', |
|
|||
30 | TEST_USER_ADMIN_LOGIN, |
|
|||
31 | repos_group=repos_group, |
|
|||
32 | private=private) |
|
|||
33 |
|
17 | |||
34 |
|
18 | |||
35 | def _destroy_project_tree(test_u1_id): |
|
19 | def _destroy_project_tree(test_u1_id): | |
@@ -75,19 +59,19 b' def _create_project_tree():' | |||||
75 | username=u'test_u1', password=u'qweqwe', |
|
59 | username=u'test_u1', password=u'qweqwe', | |
76 | email=u'test_u1@rhodecode.org', firstname=u'test_u1', lastname=u'test_u1' |
|
60 | email=u'test_u1@rhodecode.org', firstname=u'test_u1', lastname=u'test_u1' | |
77 | ) |
|
61 | ) | |
78 |
g0 = |
|
62 | g0 = fixture.create_group('g0') | |
79 |
g0_1 = |
|
63 | g0_1 = fixture.create_group('g0_1', group_parent_id=g0) | |
80 |
g0_1_1 = |
|
64 | g0_1_1 = fixture.create_group('g0_1_1', group_parent_id=g0_1) | |
81 |
g0_1_1_r1 = |
|
65 | g0_1_1_r1 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r1', repos_group=g0_1_1) | |
82 |
g0_1_1_r2 = |
|
66 | g0_1_1_r2 = fixture.create_repo('g0/g0_1/g0_1_1/g0_1_1_r2', repos_group=g0_1_1) | |
83 |
g0_1_r1 = |
|
67 | g0_1_r1 = fixture.create_repo('g0/g0_1/g0_1_r1', repos_group=g0_1) | |
84 |
g0_2 = |
|
68 | g0_2 = fixture.create_group('g0_2', group_parent_id=g0) | |
85 |
g0_2_r1 = |
|
69 | g0_2_r1 = fixture.create_repo('g0/g0_2/g0_2_r1', repos_group=g0_2) | |
86 |
g0_2_r2 = |
|
70 | g0_2_r2 = fixture.create_repo('g0/g0_2/g0_2_r2', repos_group=g0_2) | |
87 |
g0_3 = |
|
71 | g0_3 = fixture.create_group('g0_3', group_parent_id=g0) | |
88 |
g0_3_r1 = |
|
72 | g0_3_r1 = fixture.create_repo('g0/g0_3/g0_3_r1', repos_group=g0_3) | |
89 |
g0_3_r2_private = |
|
73 | g0_3_r2_private = fixture.create_repo('g0/g0_3/g0_3_r1_private', | |
90 | private=True) |
|
74 | repos_group=g0_3, repo_private=True) | |
91 | return test_u1 |
|
75 | return test_u1 | |
92 |
|
76 | |||
93 |
|
77 |
@@ -1,7 +1,7 b'' | |||||
1 | import os |
|
1 | import os | |
2 | import unittest |
|
2 | import unittest | |
3 | from rhodecode.tests import * |
|
3 | from rhodecode.tests import * | |
4 |
from rhodecode.tests. |
|
4 | from rhodecode.tests.fixture import Fixture | |
5 | from rhodecode.model.repos_group import ReposGroupModel |
|
5 | from rhodecode.model.repos_group import ReposGroupModel | |
6 | from rhodecode.model.repo import RepoModel |
|
6 | from rhodecode.model.repo import RepoModel | |
7 | from rhodecode.model.db import RepoGroup, User, UserGroupRepoGroupToPerm |
|
7 | from rhodecode.model.db import RepoGroup, User, UserGroupRepoGroupToPerm | |
@@ -10,7 +10,9 b' from rhodecode.model.user import UserMod' | |||||
10 | from rhodecode.model.meta import Session |
|
10 | from rhodecode.model.meta import Session | |
11 | from rhodecode.model.users_group import UserGroupModel |
|
11 | from rhodecode.model.users_group import UserGroupModel | |
12 | from rhodecode.lib.auth import AuthUser |
|
12 | from rhodecode.lib.auth import AuthUser | |
13 | from rhodecode.tests.api.api_base import create_repo |
|
13 | ||
|
14 | ||||
|
15 | fixture = Fixture() | |||
14 |
|
16 | |||
15 |
|
17 | |||
16 | class TestPermissions(unittest.TestCase): |
|
18 | class TestPermissions(unittest.TestCase): | |
@@ -94,8 +96,8 b' class TestPermissions(unittest.TestCase)' | |||||
94 | perms['repositories'][HG_REPO]) |
|
96 | perms['repositories'][HG_REPO]) | |
95 |
|
97 | |||
96 | def test_default_group_perms(self): |
|
98 | def test_default_group_perms(self): | |
97 |
self.g1 = |
|
99 | self.g1 = fixture.create_group('test1', skip_if_exists=True) | |
98 |
self.g2 = |
|
100 | self.g2 = fixture.create_group('test2', skip_if_exists=True) | |
99 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
101 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
100 | perms = { |
|
102 | perms = { | |
101 | 'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'}, |
|
103 | 'repositories_groups': {u'test1': 'group.read', u'test2': 'group.read'}, | |
@@ -108,8 +110,8 b' class TestPermissions(unittest.TestCase)' | |||||
108 | perms['repositories_groups']) |
|
110 | perms['repositories_groups']) | |
109 |
|
111 | |||
110 | def test_default_admin_group_perms(self): |
|
112 | def test_default_admin_group_perms(self): | |
111 |
self.g1 = |
|
113 | self.g1 = fixture.create_group('test1', skip_if_exists=True) | |
112 |
self.g2 = |
|
114 | self.g2 = fixture.create_group('test2', skip_if_exists=True) | |
113 | a1_auth = AuthUser(user_id=self.a1.user_id) |
|
115 | a1_auth = AuthUser(user_id=self.a1.user_id) | |
114 | perms = { |
|
116 | perms = { | |
115 | 'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'}, |
|
117 | 'repositories_groups': {u'test1': 'group.admin', u'test2': 'group.admin'}, | |
@@ -216,9 +218,8 b' class TestPermissions(unittest.TestCase)' | |||||
216 | perms['repositories_groups']) |
|
218 | perms['repositories_groups']) | |
217 |
|
219 | |||
218 | def test_repo_in_group_permissions(self): |
|
220 | def test_repo_in_group_permissions(self): | |
219 |
self.g1 = |
|
221 | self.g1 = fixture.create_group('group1', skip_if_exists=True) | |
220 |
self.g2 = |
|
222 | self.g2 = fixture.create_group('group2', skip_if_exists=True) | |
221 | Session().commit() |
|
|||
222 | # both perms should be read ! |
|
223 | # both perms should be read ! | |
223 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
224 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
224 | self.assertEqual(u1_auth.permissions['repositories_groups'], |
|
225 | self.assertEqual(u1_auth.permissions['repositories_groups'], | |
@@ -246,14 +247,10 b' class TestPermissions(unittest.TestCase)' | |||||
246 |
|
247 | |||
247 | # add repo to group |
|
248 | # add repo to group | |
248 | name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm']) |
|
249 | name = RepoGroup.url_sep().join([self.g1.group_name, 'test_perm']) | |
249 |
self.test_repo = |
|
250 | self.test_repo = fixture.create_repo(name=name, | |
250 | repo_name=name, |
|
251 | repo_type='hg', | |
251 | repo_type='hg', |
|
252 | repos_group=self.g1, | |
252 | description='', |
|
253 | cur_user=self.u1,) | |
253 | repos_group=self.g1, |
|
|||
254 | owner=self.u1, |
|
|||
255 | ) |
|
|||
256 | Session().commit() |
|
|||
257 |
|
254 | |||
258 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
255 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
259 | self.assertEqual(u1_auth.permissions['repositories_groups'], |
|
256 | self.assertEqual(u1_auth.permissions['repositories_groups'], | |
@@ -287,8 +284,7 b' class TestPermissions(unittest.TestCase)' | |||||
287 |
|
284 | |||
288 | def test_repo_group_user_as_user_group_member(self): |
|
285 | def test_repo_group_user_as_user_group_member(self): | |
289 | # create Group1 |
|
286 | # create Group1 | |
290 |
self.g1 = |
|
287 | self.g1 = fixture.create_group('group1', skip_if_exists=True) | |
291 | Session().commit() |
|
|||
292 | a1_auth = AuthUser(user_id=self.anon.user_id) |
|
288 | a1_auth = AuthUser(user_id=self.anon.user_id) | |
293 |
|
289 | |||
294 | self.assertEqual(a1_auth.permissions['repositories_groups'], |
|
290 | self.assertEqual(a1_auth.permissions['repositories_groups'], | |
@@ -429,12 +425,10 b' class TestPermissions(unittest.TestCase)' | |||||
429 |
|
425 | |||
430 | def test_owner_permissions_doesnot_get_overwritten_by_group(self): |
|
426 | def test_owner_permissions_doesnot_get_overwritten_by_group(self): | |
431 | #create repo as USER, |
|
427 | #create repo as USER, | |
432 |
self.test_repo = re |
|
428 | self.test_repo = fixture.create_repo(name='myownrepo', | |
433 | repo_type='hg', |
|
429 | repo_type='hg', | |
434 |
|
|
430 | cur_user=self.u1) | |
435 | owner=self.u1) |
|
|||
436 |
|
431 | |||
437 | Session().commit() |
|
|||
438 | #he has permissions of admin as owner |
|
432 | #he has permissions of admin as owner | |
439 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
433 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
440 | self.assertEqual(u1_auth.permissions['repositories']['myownrepo'], |
|
434 | self.assertEqual(u1_auth.permissions['repositories']['myownrepo'], | |
@@ -443,7 +437,8 b' class TestPermissions(unittest.TestCase)' | |||||
443 | self.ug1 = UserGroupModel().create('G1') |
|
437 | self.ug1 = UserGroupModel().create('G1') | |
444 | # add user to group |
|
438 | # add user to group | |
445 | UserGroupModel().add_user_to_group(self.ug1, self.u1) |
|
439 | UserGroupModel().add_user_to_group(self.ug1, self.u1) | |
446 |
RepoModel().grant_users_group_permission( |
|
440 | RepoModel().grant_users_group_permission(self.test_repo, | |
|
441 | group_name=self.ug1, | |||
447 | perm='repository.none') |
|
442 | perm='repository.none') | |
448 |
|
443 | |||
449 | Session().commit() |
|
444 | Session().commit() | |
@@ -453,18 +448,16 b' class TestPermissions(unittest.TestCase)' | |||||
453 |
|
448 | |||
454 | def test_owner_permissions_doesnot_get_overwritten_by_others(self): |
|
449 | def test_owner_permissions_doesnot_get_overwritten_by_others(self): | |
455 | #create repo as USER, |
|
450 | #create repo as USER, | |
456 |
self.test_repo = re |
|
451 | self.test_repo = fixture.create_repo(name='myownrepo', | |
457 | repo_type='hg', |
|
452 | repo_type='hg', | |
458 |
|
|
453 | cur_user=self.u1) | |
459 | owner=self.u1) |
|
|||
460 |
|
454 | |||
461 | Session().commit() |
|
|||
462 | #he has permissions of admin as owner |
|
455 | #he has permissions of admin as owner | |
463 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
456 | u1_auth = AuthUser(user_id=self.u1.user_id) | |
464 | self.assertEqual(u1_auth.permissions['repositories']['myownrepo'], |
|
457 | self.assertEqual(u1_auth.permissions['repositories']['myownrepo'], | |
465 | 'repository.admin') |
|
458 | 'repository.admin') | |
466 | #set his permission as user, he should still be admin |
|
459 | #set his permission as user, he should still be admin | |
467 | RepoModel().grant_user_permission(repo, user=self.u1, |
|
460 | RepoModel().grant_user_permission(self.test_repo, user=self.u1, | |
468 | perm='repository.none') |
|
461 | perm='repository.none') | |
469 | Session().commit() |
|
462 | Session().commit() | |
470 | u1_auth = AuthUser(user_id=self.u1.user_id) |
|
463 | u1_auth = AuthUser(user_id=self.u1.user_id) |
@@ -1,43 +1,29 b'' | |||||
1 | import os |
|
1 | import os | |
2 | import unittest |
|
2 | import unittest | |
|
3 | from sqlalchemy.exc import IntegrityError | |||
|
4 | ||||
3 | from rhodecode.tests import * |
|
5 | from rhodecode.tests import * | |
|
6 | from rhodecode.tests.fixture import Fixture | |||
4 |
|
7 | |||
5 | from rhodecode.model.repos_group import ReposGroupModel |
|
8 | from rhodecode.model.repos_group import ReposGroupModel | |
6 | from rhodecode.model.repo import RepoModel |
|
9 | from rhodecode.model.repo import RepoModel | |
7 |
from rhodecode.model.db import RepoGroup |
|
10 | from rhodecode.model.db import RepoGroup | |
8 | from rhodecode.model.meta import Session |
|
11 | from rhodecode.model.meta import Session | |
9 | from sqlalchemy.exc import IntegrityError |
|
|||
10 |
|
12 | |||
11 |
|
13 | |||
12 | def _make_group(path, desc='desc', parent_id=None, |
|
14 | fixture = Fixture() | |
13 | skip_if_exists=False): |
|
|||
14 |
|
||||
15 | gr = RepoGroup.get_by_group_name(path) |
|
|||
16 | if gr and skip_if_exists: |
|
|||
17 | return gr |
|
|||
18 | if isinstance(parent_id, RepoGroup): |
|
|||
19 | parent_id = parent_id.group_id |
|
|||
20 | gr = ReposGroupModel().create(path, desc, TEST_USER_ADMIN_LOGIN, parent_id) |
|
|||
21 | return gr |
|
|||
22 |
|
15 | |||
23 |
|
16 | |||
24 | def _update_group(id_, group_name, desc='desc', parent_id=None): |
|
17 | def _update_group(id_, group_name, desc='desc', parent_id=None): | |
25 | form_data = _get_group_create_params(group_name=group_name, |
|
18 | form_data = fixture._get_group_create_params(group_name=group_name, | |
26 | group_desc=desc, |
|
19 | group_desc=desc, | |
27 | group_parent_id=parent_id) |
|
20 | group_parent_id=parent_id) | |
28 | gr = ReposGroupModel().update(id_, form_data) |
|
21 | gr = ReposGroupModel().update(id_, form_data) | |
29 | return gr |
|
22 | return gr | |
30 |
|
23 | |||
31 |
|
24 | |||
32 | def _make_repo(name, **kwargs): |
|
|||
33 | form_data = _get_repo_create_params(repo_name=name, **kwargs) |
|
|||
34 | cur_user = User.get_by_username(TEST_USER_ADMIN_LOGIN) |
|
|||
35 | r = RepoModel().create(form_data, cur_user) |
|
|||
36 | return r |
|
|||
37 |
|
||||
38 |
|
||||
39 | def _update_repo(name, **kwargs): |
|
25 | def _update_repo(name, **kwargs): | |
40 | form_data = _get_repo_create_params(**kwargs) |
|
26 | form_data = fixture._get_repo_create_params(**kwargs) | |
41 | if not 'repo_name' in kwargs: |
|
27 | if not 'repo_name' in kwargs: | |
42 | form_data['repo_name'] = name |
|
28 | form_data['repo_name'] = name | |
43 | if not 'perms_new' in kwargs: |
|
29 | if not 'perms_new' in kwargs: | |
@@ -51,12 +37,9 b' def _update_repo(name, **kwargs):' | |||||
51 | class TestReposGroups(unittest.TestCase): |
|
37 | class TestReposGroups(unittest.TestCase): | |
52 |
|
38 | |||
53 | def setUp(self): |
|
39 | def setUp(self): | |
54 |
self.g1 = |
|
40 | self.g1 = fixture.create_group('test1', skip_if_exists=True) | |
55 | Session().commit() |
|
41 | self.g2 = fixture.create_group('test2', skip_if_exists=True) | |
56 |
self.g |
|
42 | self.g3 = fixture.create_group('test3', skip_if_exists=True) | |
57 | Session().commit() |
|
|||
58 | self.g3 = _make_group('test3', skip_if_exists=True) |
|
|||
59 | Session().commit() |
|
|||
60 |
|
43 | |||
61 | def tearDown(self): |
|
44 | def tearDown(self): | |
62 | Session.remove() |
|
45 | Session.remove() | |
@@ -76,47 +59,42 b' class TestReposGroups(unittest.TestCase)' | |||||
76 | ReposGroupModel().delete(id_) |
|
59 | ReposGroupModel().delete(id_) | |
77 |
|
60 | |||
78 | def test_create_group(self): |
|
61 | def test_create_group(self): | |
79 |
g = |
|
62 | g = fixture.create_group('newGroup') | |
80 | Session().commit() |
|
63 | Session().commit() | |
81 | self.assertEqual(g.full_path, 'newGroup') |
|
64 | self.assertEqual(g.full_path, 'newGroup') | |
82 |
|
65 | |||
83 | self.assertTrue(self.__check_path('newGroup')) |
|
66 | self.assertTrue(self.__check_path('newGroup')) | |
84 |
|
67 | |||
85 | def test_create_same_name_group(self): |
|
68 | def test_create_same_name_group(self): | |
86 |
self.assertRaises(IntegrityError, lambda: |
|
69 | self.assertRaises(IntegrityError, lambda: fixture.create_group('newGroup')) | |
87 | Session().rollback() |
|
70 | Session().rollback() | |
88 |
|
71 | |||
89 | def test_same_subgroup(self): |
|
72 | def test_same_subgroup(self): | |
90 |
sg1 = |
|
73 | sg1 = fixture.create_group('sub1', group_parent_id=self.g1.group_id) | |
91 | Session().commit() |
|
|||
92 | self.assertEqual(sg1.parent_group, self.g1) |
|
74 | self.assertEqual(sg1.parent_group, self.g1) | |
93 | self.assertEqual(sg1.full_path, 'test1/sub1') |
|
75 | self.assertEqual(sg1.full_path, 'test1/sub1') | |
94 | self.assertTrue(self.__check_path('test1', 'sub1')) |
|
76 | self.assertTrue(self.__check_path('test1', 'sub1')) | |
95 |
|
77 | |||
96 |
ssg1 = |
|
78 | ssg1 = fixture.create_group('subsub1', group_parent_id=sg1.group_id) | |
97 | Session().commit() |
|
|||
98 | self.assertEqual(ssg1.parent_group, sg1) |
|
79 | self.assertEqual(ssg1.parent_group, sg1) | |
99 | self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1') |
|
80 | self.assertEqual(ssg1.full_path, 'test1/sub1/subsub1') | |
100 | self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1')) |
|
81 | self.assertTrue(self.__check_path('test1', 'sub1', 'subsub1')) | |
101 |
|
82 | |||
102 | def test_remove_group(self): |
|
83 | def test_remove_group(self): | |
103 |
sg1 = |
|
84 | sg1 = fixture.create_group('deleteme') | |
104 | Session().commit() |
|
|||
105 | self.__delete_group(sg1.group_id) |
|
85 | self.__delete_group(sg1.group_id) | |
106 |
|
86 | |||
107 | self.assertEqual(RepoGroup.get(sg1.group_id), None) |
|
87 | self.assertEqual(RepoGroup.get(sg1.group_id), None) | |
108 | self.assertFalse(self.__check_path('deteteme')) |
|
88 | self.assertFalse(self.__check_path('deteteme')) | |
109 |
|
89 | |||
110 |
sg1 = |
|
90 | sg1 = fixture.create_group('deleteme', group_parent_id=self.g1.group_id) | |
111 | Session().commit() |
|
|||
112 | self.__delete_group(sg1.group_id) |
|
91 | self.__delete_group(sg1.group_id) | |
113 |
|
92 | |||
114 | self.assertEqual(RepoGroup.get(sg1.group_id), None) |
|
93 | self.assertEqual(RepoGroup.get(sg1.group_id), None) | |
115 | self.assertFalse(self.__check_path('test1', 'deteteme')) |
|
94 | self.assertFalse(self.__check_path('test1', 'deteteme')) | |
116 |
|
95 | |||
117 | def test_rename_single_group(self): |
|
96 | def test_rename_single_group(self): | |
118 |
sg1 = |
|
97 | sg1 = fixture.create_group('initial') | |
119 | Session().commit() |
|
|||
120 |
|
98 | |||
121 | new_sg1 = _update_group(sg1.group_id, 'after') |
|
99 | new_sg1 = _update_group(sg1.group_id, 'after') | |
122 | self.assertTrue(self.__check_path('after')) |
|
100 | self.assertTrue(self.__check_path('after')) | |
@@ -124,8 +102,7 b' class TestReposGroups(unittest.TestCase)' | |||||
124 |
|
102 | |||
125 | def test_update_group_parent(self): |
|
103 | def test_update_group_parent(self): | |
126 |
|
104 | |||
127 |
sg1 = |
|
105 | sg1 = fixture.create_group('initial', group_parent_id=self.g1.group_id) | |
128 | Session().commit() |
|
|||
129 |
|
106 | |||
130 | new_sg1 = _update_group(sg1.group_id, 'after', parent_id=self.g1.group_id) |
|
107 | new_sg1 = _update_group(sg1.group_id, 'after', parent_id=self.g1.group_id) | |
131 | self.assertTrue(self.__check_path('test1', 'after')) |
|
108 | self.assertTrue(self.__check_path('test1', 'after')) | |
@@ -142,12 +119,11 b' class TestReposGroups(unittest.TestCase)' | |||||
142 |
|
119 | |||
143 | def test_subgrouping_with_repo(self): |
|
120 | def test_subgrouping_with_repo(self): | |
144 |
|
121 | |||
145 |
g1 = |
|
122 | g1 = fixture.create_group('g1') | |
146 |
g2 = |
|
123 | g2 = fixture.create_group('g2') | |
147 | Session().commit() |
|
|||
148 | # create new repo |
|
124 | # create new repo | |
149 |
r = |
|
125 | r = fixture.create_repo('john') | |
150 | Session().commit() |
|
126 | ||
151 | self.assertEqual(r.repo_name, 'john') |
|
127 | self.assertEqual(r.repo_name, 'john') | |
152 | # put repo into group |
|
128 | # put repo into group | |
153 | r = _update_repo('john', repo_group=g1.group_id) |
|
129 | r = _update_repo('john', repo_group=g1.group_id) | |
@@ -162,10 +138,8 b' class TestReposGroups(unittest.TestCase)' | |||||
162 | r.just_name])) |
|
138 | r.just_name])) | |
163 |
|
139 | |||
164 | def test_move_to_root(self): |
|
140 | def test_move_to_root(self): | |
165 |
g1 = |
|
141 | g1 = fixture.create_group('t11') | |
166 | Session().commit() |
|
142 | g2 = fixture.create_group('t22', group_parent_id=g1.group_id) | |
167 | g2 = _make_group('t22', parent_id=g1.group_id) |
|
|||
168 | Session().commit() |
|
|||
169 |
|
143 | |||
170 | self.assertEqual(g2.full_path, 't11/t22') |
|
144 | self.assertEqual(g2.full_path, 't11/t22') | |
171 | self.assertTrue(self.__check_path('t11', 't22')) |
|
145 | self.assertTrue(self.__check_path('t11', 't22')) | |
@@ -180,15 +154,11 b' class TestReposGroups(unittest.TestCase)' | |||||
180 | self.assertTrue(self.__check_path('g22')) |
|
154 | self.assertTrue(self.__check_path('g22')) | |
181 |
|
155 | |||
182 | def test_rename_top_level_group_in_nested_setup(self): |
|
156 | def test_rename_top_level_group_in_nested_setup(self): | |
183 |
g1 = |
|
157 | g1 = fixture.create_group('L1') | |
184 | Session().commit() |
|
158 | g2 = fixture.create_group('L2', group_parent_id=g1.group_id) | |
185 |
g |
|
159 | g3 = fixture.create_group('L3', group_parent_id=g2.group_id) | |
186 | Session().commit() |
|
|||
187 | g3 = _make_group('L3', parent_id=g2.group_id) |
|
|||
188 | Session().commit() |
|
|||
189 |
|
160 | |||
190 |
r = |
|
161 | r = fixture.create_repo('L1/L2/L3/L3_REPO', repo_group=g3.group_id) | |
191 | Session().commit() |
|
|||
192 |
|
162 | |||
193 | ##rename L1 all groups should be now changed |
|
163 | ##rename L1 all groups should be now changed | |
194 | _update_group(g1.group_id, 'L1_NEW') |
|
164 | _update_group(g1.group_id, 'L1_NEW') | |
@@ -199,18 +169,12 b' class TestReposGroups(unittest.TestCase)' | |||||
199 | self.assertEqual(r.repo_name, 'L1_NEW/L2/L3/L3_REPO') |
|
169 | self.assertEqual(r.repo_name, 'L1_NEW/L2/L3/L3_REPO') | |
200 |
|
170 | |||
201 | def test_change_parent_of_top_level_group_in_nested_setup(self): |
|
171 | def test_change_parent_of_top_level_group_in_nested_setup(self): | |
202 |
g1 = |
|
172 | g1 = fixture.create_group('R1') | |
203 | Session().commit() |
|
173 | g2 = fixture.create_group('R2', group_parent_id=g1.group_id) | |
204 |
g |
|
174 | g3 = fixture.create_group('R3', group_parent_id=g2.group_id) | |
205 | Session().commit() |
|
175 | g4 = fixture.create_group('R1_NEW') | |
206 | g3 = _make_group('R3', parent_id=g2.group_id) |
|
|||
207 | Session().commit() |
|
|||
208 |
|
176 | |||
209 | g4 = _make_group('R1_NEW') |
|
177 | r = fixture.create_repo('R1/R2/R3/R3_REPO', repo_group=g3.group_id) | |
210 | Session().commit() |
|
|||
211 |
|
||||
212 | r = _make_repo('R1/R2/R3/R3_REPO', repo_group=g3.group_id) |
|
|||
213 | Session().commit() |
|
|||
214 | ##rename L1 all groups should be now changed |
|
178 | ##rename L1 all groups should be now changed | |
215 | _update_group(g1.group_id, 'R1', parent_id=g4.group_id) |
|
179 | _update_group(g1.group_id, 'R1', parent_id=g4.group_id) | |
216 | Session().commit() |
|
180 | Session().commit() | |
@@ -220,18 +184,12 b' class TestReposGroups(unittest.TestCase)' | |||||
220 | self.assertEqual(r.repo_name, 'R1_NEW/R1/R2/R3/R3_REPO') |
|
184 | self.assertEqual(r.repo_name, 'R1_NEW/R1/R2/R3/R3_REPO') | |
221 |
|
185 | |||
222 | def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self): |
|
186 | def test_change_parent_of_top_level_group_in_nested_setup_with_rename(self): | |
223 |
g1 = |
|
187 | g1 = fixture.create_group('X1') | |
224 | Session().commit() |
|
188 | g2 = fixture.create_group('X2', group_parent_id=g1.group_id) | |
225 |
g |
|
189 | g3 = fixture.create_group('X3', group_parent_id=g2.group_id) | |
226 | Session().commit() |
|
190 | g4 = fixture.create_group('X1_NEW') | |
227 | g3 = _make_group('X3', parent_id=g2.group_id) |
|
|||
228 | Session().commit() |
|
|||
229 |
|
191 | |||
230 | g4 = _make_group('X1_NEW') |
|
192 | r = fixture.create_repo('X1/X2/X3/X3_REPO', repo_group=g3.group_id) | |
231 | Session().commit() |
|
|||
232 |
|
||||
233 | r = _make_repo('X1/X2/X3/X3_REPO', repo_group=g3.group_id) |
|
|||
234 | Session().commit() |
|
|||
235 |
|
193 | |||
236 | ##rename L1 all groups should be now changed |
|
194 | ##rename L1 all groups should be now changed | |
237 | _update_group(g1.group_id, 'X1_PRIM', parent_id=g4.group_id) |
|
195 | _update_group(g1.group_id, 'X1_PRIM', parent_id=g4.group_id) |
@@ -14,6 +14,9 b' class TestUser(unittest.TestCase):' | |||||
14 | Session.remove() |
|
14 | Session.remove() | |
15 | super(TestUser, self).__init__(methodName=methodName) |
|
15 | super(TestUser, self).__init__(methodName=methodName) | |
16 |
|
16 | |||
|
17 | def tearDown(self): | |||
|
18 | Session.remove() | |||
|
19 | ||||
17 | def test_create_and_remove(self): |
|
20 | def test_create_and_remove(self): | |
18 | usr = UserModel().create_or_update(username=u'test_user', |
|
21 | usr = UserModel().create_or_update(username=u'test_user', | |
19 | password=u'qweqwe', |
|
22 | password=u'qweqwe', | |
@@ -99,6 +102,7 b' class TestUsers(unittest.TestCase):' | |||||
99 |
|
102 | |||
100 | UserModel().delete(self.u1) |
|
103 | UserModel().delete(self.u1) | |
101 | Session().commit() |
|
104 | Session().commit() | |
|
105 | Session.remove() | |||
102 |
|
106 | |||
103 | def test_add_perm(self): |
|
107 | def test_add_perm(self): | |
104 | perm = Permission.query().all()[0] |
|
108 | perm = Permission.query().all()[0] |
@@ -12,7 +12,6 b' from rhodecode.model.repos_group import ' | |||||
12 | from rhodecode.config.routing import ADMIN_PREFIX |
|
12 | from rhodecode.config.routing import ADMIN_PREFIX | |
13 | from rhodecode.model.db import ChangesetStatus, Repository |
|
13 | from rhodecode.model.db import ChangesetStatus, Repository | |
14 | from rhodecode.model.changeset_status import ChangesetStatusModel |
|
14 | from rhodecode.model.changeset_status import ChangesetStatusModel | |
15 | from rhodecode.model.comment import ChangesetCommentsModel |
|
|||
16 |
|
15 | |||
17 |
|
16 | |||
18 | class TestReposGroups(unittest.TestCase): |
|
17 | class TestReposGroups(unittest.TestCase): | |
@@ -21,7 +20,7 b' class TestReposGroups(unittest.TestCase)' | |||||
21 | pass |
|
20 | pass | |
22 |
|
21 | |||
23 | def tearDown(self): |
|
22 | def tearDown(self): | |
24 | pass |
|
23 | Session.remove() | |
25 |
|
24 | |||
26 | def test_Message_extractor(self): |
|
25 | def test_Message_extractor(self): | |
27 | validator = v.ValidUsername() |
|
26 | validator = v.ValidUsername() |
General Comments 0
You need to be logged in to leave comments.
Login now