##// END OF EJS Templates
tests update
marcink -
r1047:15b60f83 beta
parent child Browse files
Show More
@@ -62,7 +62,6 b' class TestController(TestCase):'
62 62 response = self.app.post(url(controller='login', action='index'),
63 63 {'username':username,
64 64 'password':password})
65 print response
66 65
67 66 if 'invalid user name' in response.body:
68 67 assert False, 'could not login using %s %s' % (username, password)
@@ -237,5 +237,71 b' removed extra unicode conversion in diff'
237 237 fname=fname))
238 238 assert 'Unknown revision' in response.body
239 239
240 #==========================================================================
241 # RAW FILE
242 #==========================================================================
243 def test_raw_file_ok(self):
244 self.log_user()
245 response = self.app.get(url(controller='files', action='rawfile',
246 repo_name=HG_REPO,
247 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
248 f_path='vcs/nodes.py'))
249 assert False
250 #TODO: put in more
251 def test_raw_file_wrong_cs(self):
252 self.log_user()
253 rev = u'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
254 f_path = 'vcs/nodes.py'
255
256 response = self.app.get(url(controller='files', action='rawfile',
257 repo_name=HG_REPO,
258 revision='ERRORce30c96924232dffcd24178a07ffeb5dfc',
259 f_path='vcs/nodes.py'))
260 print response.session['flash']
261 assert """Revision %r does not exist for this repository""" % (rev) in response.session['flash'][0], 'No flash message'
262 assert """%s""" % (HG_REPO) in response.session['flash'][0], 'No flash message'
263
240 264
241 265
266 def test_raw_file_wrong_f_path(self):
267 self.log_user()
268 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
269 f_path = 'vcs/ERRORnodes.py'
270 response = self.app.get(url(controller='files', action='rawfile',
271 repo_name=HG_REPO,
272 revision=rev,
273 f_path=f_path))
274 assert "There is no file nor directory at the given path %r at revision %r" % (f_path, rev) in response.session['flash'][0], 'No flash message'
275
276 #==========================================================================
277 # RAW
278 #==========================================================================
279 def test_raw_ok(self):
280 self.log_user()
281 response = self.app.get(url(controller='files', action='raw',
282 repo_name=HG_REPO,
283 revision='27cd5cce30c96924232dffcd24178a07ffeb5dfc',
284 f_path='vcs/nodes.py'))
285 assert False
286 #TODO: put in more
287 def test_raw_wrong_cs(self):
288 self.log_user()
289 rev = 'ERRORcce30c96924232dffcd24178a07ffeb5dfc'
290 f_path = 'vcs/nodes.py'
291
292 response = self.app.get(url(controller='files', action='raw',
293 repo_name=HG_REPO,
294 revision='ERRORce30c96924232dffcd24178a07ffeb5dfc',
295 f_path='vcs/nodes.py'))
296 assert "Cannot find revision %s" % rev in response.session['flash'][0], 'No flash message'
297
298 def test_raw_wrong_f_path(self):
299 self.log_user()
300 rev = '27cd5cce30c96924232dffcd24178a07ffeb5dfc'
301 f_path = 'vcs/ERRORnodes.py'
302 response = self.app.get(url(controller='files', action='raw',
303 repo_name=HG_REPO,
304 revision=rev,
305 f_path=f_path))
306 assert "There is no file nor directory at the given path %r at revision %r" % (f_path, rev) in response.session['flash'][0], 'No flash message'
307
@@ -77,6 +77,8 b' def create_test_user(force=True):'
77 77
78 78 if force and user is not None:
79 79 print 'removing current user'
80 for repo in sa.query(Repository).filter(Repository.user == user).all():
81 sa.delete(repo)
80 82 sa.delete(user)
81 83 sa.commit()
82 84
@@ -117,6 +119,19 b' def create_test_repo(force=True):'
117 119 rm.base_path = '/home/hg'
118 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 136 # TESTS
122 137 #==============================================================================
@@ -157,6 +172,12 b' def test_clone_anonymous_ok():'
157 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 181 clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \
161 182 {'user':USER,
162 183 'pass':PASS,
@@ -166,9 +187,17 b' def test_clone_anonymous_ok():'
166 187
167 188 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
168 189 print stdout, stderr
190
191
169 192 assert """adding file changes""" in stdout, 'no messages about cloning'
170 193 assert """abort""" not in stderr , 'got error from clone'
171 194
195 #disable if it was enabled
196 if not anonymous_access:
197 print 'disabling anonymous access'
198 set_anonymous_access(enable=False)
199
200
172 201 def test_clone_wrong_credentials():
173 202 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
174 203
@@ -296,7 +325,7 b" if __name__ == '__main__':"
296 325 #test_clone_wrong_credentials()
297 326
298 327 #test_pull()
299 test_push_new_file(commits=3)
328 test_push_new_file(commits=2)
300 329 #test_push_wrong_path()
301 330 #test_push_wrong_credentials()
302 331
General Comments 0
You need to be logged in to leave comments. Login now