Mercurial > kallithea
comparison rhodecode/tests/test_hg_operations.py @ 1047:15b60f83420c beta
tests update
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Tue, 15 Feb 2011 01:36:50 +0100 |
parents | a9421a8a874f |
children | 51076a2a2b64 |
comparison
equal
deleted
inserted
replaced
1046:9e93cad9357b | 1047:15b60f83420c |
---|---|
75 | 75 |
76 user = sa.query(User).filter(User.username == USER).scalar() | 76 user = sa.query(User).filter(User.username == USER).scalar() |
77 | 77 |
78 if force and user is not None: | 78 if force and user is not None: |
79 print 'removing current user' | 79 print 'removing current user' |
80 for repo in sa.query(Repository).filter(Repository.user == user).all(): | |
81 sa.delete(repo) | |
80 sa.delete(user) | 82 sa.delete(user) |
81 sa.commit() | 83 sa.commit() |
82 | 84 |
83 if user is None or force: | 85 if user is None or force: |
84 print 'creating new one' | 86 print 'creating new one' |
115 'private':False, } | 117 'private':False, } |
116 rm = RepoModel(sa) | 118 rm = RepoModel(sa) |
117 rm.base_path = '/home/hg' | 119 rm.base_path = '/home/hg' |
118 rm.create(form_data, user) | 120 rm.create(form_data, user) |
119 | 121 |
122 | |
123 def set_anonymous_access(enable=True): | |
124 sa = get_session() | |
125 user = sa.query(User).filter(User.username == 'default').one() | |
126 user.active = enable | |
127 sa.add(user) | |
128 sa.commit() | |
129 | |
130 def get_anonymous_access(): | |
131 sa = get_session() | |
132 return sa.query(User).filter(User.username == 'default').one().active | |
133 | |
134 | |
120 #============================================================================== | 135 #============================================================================== |
121 # TESTS | 136 # TESTS |
122 #============================================================================== | 137 #============================================================================== |
123 def test_clone(no_errors=False): | 138 def test_clone(no_errors=False): |
124 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) | 139 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
155 #print 'made dirs %s' % jn(path) | 170 #print 'made dirs %s' % jn(path) |
156 except OSError: | 171 except OSError: |
157 raise | 172 raise |
158 | 173 |
159 | 174 |
175 print 'checking if anonymous access is enabled' | |
176 anonymous_access = get_anonymous_access() | |
177 if not anonymous_access: | |
178 print 'not enabled, enabling it ' | |
179 set_anonymous_access(enable=True) | |
180 | |
160 clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \ | 181 clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \ |
161 {'user':USER, | 182 {'user':USER, |
162 'pass':PASS, | 183 'pass':PASS, |
163 'host':HOST, | 184 'host':HOST, |
164 'cloned_repo':HG_REPO, | 185 'cloned_repo':HG_REPO, |
165 'dest':path} | 186 'dest':path} |
166 | 187 |
167 stdout, stderr = Command(cwd).execute('hg clone', clone_url) | 188 stdout, stderr = Command(cwd).execute('hg clone', clone_url) |
168 print stdout, stderr | 189 print stdout, stderr |
190 | |
191 | |
169 assert """adding file changes""" in stdout, 'no messages about cloning' | 192 assert """adding file changes""" in stdout, 'no messages about cloning' |
170 assert """abort""" not in stderr , 'got error from clone' | 193 assert """abort""" not in stderr , 'got error from clone' |
194 | |
195 #disable if it was enabled | |
196 if not anonymous_access: | |
197 print 'disabling anonymous access' | |
198 set_anonymous_access(enable=False) | |
199 | |
171 | 200 |
172 def test_clone_wrong_credentials(): | 201 def test_clone_wrong_credentials(): |
173 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) | 202 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
174 | 203 |
175 try: | 204 try: |
294 #test_clone_anonymous_ok() | 323 #test_clone_anonymous_ok() |
295 | 324 |
296 #test_clone_wrong_credentials() | 325 #test_clone_wrong_credentials() |
297 | 326 |
298 #test_pull() | 327 #test_pull() |
299 test_push_new_file(commits=3) | 328 test_push_new_file(commits=2) |
300 #test_push_wrong_path() | 329 #test_push_wrong_path() |
301 #test_push_wrong_credentials() | 330 #test_push_wrong_credentials() |
302 | 331 |
303 | 332 |