##// END OF EJS Templates
codingstyle: replace upper-case variable names with lower-case ones...
Lars Kruse -
r6790:94bbb7eb default
parent child Browse files
Show More
@@ -39,10 +39,11 b' class TestChangeSetCommentsController(Te'
39
39
40 notification = Notification.query().all()[0]
40 notification = Notification.query().all()[0]
41
41
42 ID = ChangesetComment.query().first().comment_id
42 commit_id = ChangesetComment.query().first().comment_id
43 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
43 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
44 sbj = (u'/%s/changeset/'
44 sbj = (u'/%s/changeset/'
45 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % (HG_REPO, ID))
45 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
46 % (HG_REPO, commit_id))
46 print "%s vs %s" % (sbj, notification.subject)
47 print "%s vs %s" % (sbj, notification.subject)
47 assert sbj in notification.subject
48 assert sbj in notification.subject
48
49
@@ -78,10 +79,11 b' class TestChangeSetCommentsController(Te'
78 assert ChangesetComment.query().count() == 1
79 assert ChangesetComment.query().count() == 1
79
80
80 notification = Notification.query().all()[0]
81 notification = Notification.query().all()[0]
81 ID = ChangesetComment.query().first().comment_id
82 commit_id = ChangesetComment.query().first().comment_id
82 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
83 assert notification.type_ == Notification.TYPE_CHANGESET_COMMENT
83 sbj = (u'/%s/changeset/'
84 sbj = (u'/%s/changeset/'
84 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s' % (HG_REPO, ID))
85 '27cd5cce30c96924232dffcd24178a07ffeb5dfc#comment-%s'
86 % (HG_REPO, commit_id))
85 print "%s vs %s" % (sbj, notification.subject)
87 print "%s vs %s" % (sbj, notification.subject)
86 assert sbj in notification.subject
88 assert sbj in notification.subject
87
89
@@ -297,12 +297,12 b' class TestLibs(TestController):'
297 """
297 """
298 import re
298 import re
299 # quickly change expected url[] into a link
299 # quickly change expected url[] into a link
300 URL_PAT = re.compile(r'(?:url\[)(.+?)(?:\])')
300 url_pattern = re.compile(r'(?:url\[)(.+?)(?:\])')
301
301
302 def url_func(match_obj):
302 def url_func(match_obj):
303 _url = match_obj.groups()[0]
303 _url = match_obj.groups()[0]
304 return tmpl % (url_ or '/repo_name/changeset/%s' % _url, _url)
304 return tmpl % (url_ or '/repo_name/changeset/%s' % _url, _url)
305 return URL_PAT.sub(url_func, text)
305 return url_pattern.sub(url_func, text)
306
306
307 @parametrize('sample,expected', [
307 @parametrize('sample,expected', [
308 ("",
308 ("",
@@ -83,17 +83,17 b" def _get_tmp_dir(prefix='vcs_operations-"
83 return tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix=prefix, suffix=suffix)
83 return tempfile.mkdtemp(dir=TESTS_TMP_PATH, prefix=prefix, suffix=suffix)
84
84
85
85
86 def _add_files_and_push(webserver, vcs, DEST, ignoreReturnCode=False, files_no=3,
86 def _add_files_and_push(webserver, vcs, dest_dir, ignoreReturnCode=False, files_no=3,
87 clone_url=None, username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS):
87 clone_url=None, username=TEST_USER_ADMIN_LOGIN, password=TEST_USER_ADMIN_PASS):
88 """
88 """
89 Generate some files, add it to DEST repo and push back
89 Generate some files, add it to dest_dir repo and push back
90 vcs is git or hg and defines what VCS we want to make those files for
90 vcs is git or hg and defines what VCS we want to make those files for
91
91
92 :param vcs:
92 :param vcs:
93 :param DEST:
93 :param dest_dir:
94 """
94 """
95 # commit some stuff into this repo
95 # commit some stuff into this repo
96 cwd = os.path.join(DEST)
96 cwd = os.path.join(dest_dir)
97 #added_file = '%ssetupążźć.py' % _RandomNameSequence().next()
97 #added_file = '%ssetupążźć.py' % _RandomNameSequence().next()
98 added_file = '%ssetup.py' % _RandomNameSequence().next()
98 added_file = '%ssetup.py' % _RandomNameSequence().next()
99 open(os.path.join(cwd, added_file), 'a').close()
99 open(os.path.join(cwd, added_file), 'a').close()
@@ -227,29 +227,29 b' class TestVCSOperations(TestController):'
227 assert 'not found' in stderr
227 assert 'not found' in stderr
228
228
229 def test_push_new_file_hg(self, webserver):
229 def test_push_new_file_hg(self, webserver):
230 DEST = _get_tmp_dir()
230 dest_dir = _get_tmp_dir()
231 clone_url = webserver.repo_url(HG_REPO)
231 clone_url = webserver.repo_url(HG_REPO)
232 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
232 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
233
233
234 fork_name = '%s_fork%s' % (HG_REPO, _RandomNameSequence().next())
234 fork_name = '%s_fork%s' % (HG_REPO, _RandomNameSequence().next())
235 fixture.create_fork(HG_REPO, fork_name)
235 fixture.create_fork(HG_REPO, fork_name)
236 clone_url = webserver.repo_url(fork_name)
236 clone_url = webserver.repo_url(fork_name)
237 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST, clone_url=clone_url)
237 stdout, stderr = _add_files_and_push(webserver, 'hg', dest_dir, clone_url=clone_url)
238
238
239 assert 'pushing to' in stdout
239 assert 'pushing to' in stdout
240 assert 'Repository size' in stdout
240 assert 'Repository size' in stdout
241 assert 'Last revision is now' in stdout
241 assert 'Last revision is now' in stdout
242
242
243 def test_push_new_file_git(self, webserver):
243 def test_push_new_file_git(self, webserver):
244 DEST = _get_tmp_dir()
244 dest_dir = _get_tmp_dir()
245 clone_url = webserver.repo_url(GIT_REPO)
245 clone_url = webserver.repo_url(GIT_REPO)
246 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
246 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
247
247
248 # commit some stuff into this repo
248 # commit some stuff into this repo
249 fork_name = '%s_fork%s' % (GIT_REPO, _RandomNameSequence().next())
249 fork_name = '%s_fork%s' % (GIT_REPO, _RandomNameSequence().next())
250 fixture.create_fork(GIT_REPO, fork_name)
250 fixture.create_fork(GIT_REPO, fork_name)
251 clone_url = webserver.repo_url(fork_name)
251 clone_url = webserver.repo_url(fork_name)
252 stdout, stderr = _add_files_and_push(webserver, 'git', DEST, clone_url=clone_url)
252 stdout, stderr = _add_files_and_push(webserver, 'git', dest_dir, clone_url=clone_url)
253 print [(x.repo_full_path,x.repo_path) for x in Repository.query()] # TODO: what is this for
253 print [(x.repo_full_path,x.repo_path) for x in Repository.query()] # TODO: what is this for
254 _check_proper_git_push(stdout, stderr)
254 _check_proper_git_push(stdout, stderr)
255
255
@@ -263,14 +263,14 b' class TestVCSOperations(TestController):'
263 key.cache_active = True
263 key.cache_active = True
264 Session().commit()
264 Session().commit()
265
265
266 DEST = _get_tmp_dir()
266 dest_dir = _get_tmp_dir()
267 clone_url = webserver.repo_url(HG_REPO)
267 clone_url = webserver.repo_url(HG_REPO)
268 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
268 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
269
269
270 fork_name = '%s_fork%s' % (HG_REPO, _RandomNameSequence().next())
270 fork_name = '%s_fork%s' % (HG_REPO, _RandomNameSequence().next())
271 fixture.create_fork(HG_REPO, fork_name)
271 fixture.create_fork(HG_REPO, fork_name)
272 clone_url = webserver.repo_url(fork_name)
272 clone_url = webserver.repo_url(fork_name)
273 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST, files_no=1, clone_url=clone_url)
273 stdout, stderr = _add_files_and_push(webserver, 'hg', dest_dir, files_no=1, clone_url=clone_url)
274
274
275 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
275 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
276 == fork_name).all()
276 == fork_name).all()
@@ -286,15 +286,15 b' class TestVCSOperations(TestController):'
286 key.cache_active = True
286 key.cache_active = True
287 Session().commit()
287 Session().commit()
288
288
289 DEST = _get_tmp_dir()
289 dest_dir = _get_tmp_dir()
290 clone_url = webserver.repo_url(GIT_REPO)
290 clone_url = webserver.repo_url(GIT_REPO)
291 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
291 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
292
292
293 # commit some stuff into this repo
293 # commit some stuff into this repo
294 fork_name = '%s_fork%s' % (GIT_REPO, _RandomNameSequence().next())
294 fork_name = '%s_fork%s' % (GIT_REPO, _RandomNameSequence().next())
295 fixture.create_fork(GIT_REPO, fork_name)
295 fixture.create_fork(GIT_REPO, fork_name)
296 clone_url = webserver.repo_url(fork_name)
296 clone_url = webserver.repo_url(fork_name)
297 stdout, stderr = _add_files_and_push(webserver, 'git', DEST, files_no=1, clone_url=clone_url)
297 stdout, stderr = _add_files_and_push(webserver, 'git', dest_dir, files_no=1, clone_url=clone_url)
298 _check_proper_git_push(stdout, stderr)
298 _check_proper_git_push(stdout, stderr)
299
299
300 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
300 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
@@ -302,44 +302,46 b' class TestVCSOperations(TestController):'
302 assert key == []
302 assert key == []
303
303
304 def test_push_wrong_credentials_hg(self, webserver):
304 def test_push_wrong_credentials_hg(self, webserver):
305 DEST = _get_tmp_dir()
305 dest_dir = _get_tmp_dir()
306 clone_url = webserver.repo_url(HG_REPO)
306 clone_url = webserver.repo_url(HG_REPO)
307 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
307 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
308
308
309 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST, username='bad',
309 stdout, stderr = _add_files_and_push(webserver, 'hg', dest_dir, username='bad',
310 password='name', ignoreReturnCode=True)
310 password='name', ignoreReturnCode=True)
311
311
312 assert 'abort: authorization failed' in stderr
312 assert 'abort: authorization failed' in stderr
313
313
314 def test_push_wrong_credentials_git(self, webserver):
314 def test_push_wrong_credentials_git(self, webserver):
315 DEST = _get_tmp_dir()
315 dest_dir = _get_tmp_dir()
316 clone_url = webserver.repo_url(GIT_REPO)
316 clone_url = webserver.repo_url(GIT_REPO)
317 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
317 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
318
318
319 stdout, stderr = _add_files_and_push(webserver, 'git', DEST, username='bad',
319 stdout, stderr = _add_files_and_push(webserver, 'git', dest_dir, username='bad',
320 password='name', ignoreReturnCode=True)
320 password='name', ignoreReturnCode=True)
321
321
322 assert 'fatal: Authentication failed' in stderr
322 assert 'fatal: Authentication failed' in stderr
323
323
324 def test_push_back_to_wrong_url_hg(self, webserver):
324 def test_push_back_to_wrong_url_hg(self, webserver):
325 DEST = _get_tmp_dir()
325 dest_dir = _get_tmp_dir()
326 clone_url = webserver.repo_url(HG_REPO)
326 clone_url = webserver.repo_url(HG_REPO)
327 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
327 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
328
328
329 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST,
329 stdout, stderr = _add_files_and_push(
330 clone_url='http://%s:%s/tmp' % (webserver.server_address[0], webserver.server_address[1]),
330 webserver, 'hg', dest_dir, clone_url='http://%s:%s/tmp' % (
331 ignoreReturnCode = True)
331 webserver.server_address[0], webserver.server_address[1]),
332 ignoreReturnCode=True)
332
333
333 assert 'HTTP Error 404: Not Found' in stderr
334 assert 'HTTP Error 404: Not Found' in stderr
334
335
335 def test_push_back_to_wrong_url_git(self, webserver):
336 def test_push_back_to_wrong_url_git(self, webserver):
336 DEST = _get_tmp_dir()
337 dest_dir = _get_tmp_dir()
337 clone_url = webserver.repo_url(GIT_REPO)
338 clone_url = webserver.repo_url(GIT_REPO)
338 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
339 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
339
340
340 stdout, stderr = _add_files_and_push(webserver, 'git', DEST,
341 stdout, stderr = _add_files_and_push(
341 clone_url='http://%s:%s/tmp' % (webserver.server_address[0], webserver.server_address[1]),
342 webserver, 'git', dest_dir, clone_url='http://%s:%s/tmp' % (
342 ignoreReturnCode = True)
343 webserver.server_address[0], webserver.server_address[1]),
344 ignoreReturnCode=True)
343
345
344 assert 'not found' in stderr
346 assert 'not found' in stderr
345
347
@@ -392,9 +394,9 b' class TestVCSOperations(TestController):'
392
394
393 def test_push_on_locked_repo_by_other_user_hg(self, webserver):
395 def test_push_on_locked_repo_by_other_user_hg(self, webserver):
394 # clone some temp
396 # clone some temp
395 DEST = _get_tmp_dir()
397 dest_dir = _get_tmp_dir()
396 clone_url = webserver.repo_url(HG_REPO)
398 clone_url = webserver.repo_url(HG_REPO)
397 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
399 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
398
400
399 # lock repo
401 # lock repo
400 r = Repository.get_by_repo_name(HG_REPO)
402 r = Repository.get_by_repo_name(HG_REPO)
@@ -405,7 +407,7 b' class TestVCSOperations(TestController):'
405 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id)
407 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id)
406
408
407 # push fails repo is locked by other user !
409 # push fails repo is locked by other user !
408 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST,
410 stdout, stderr = _add_files_and_push(webserver, 'hg', dest_dir,
409 username=TEST_USER_REGULAR_LOGIN,
411 username=TEST_USER_REGULAR_LOGIN,
410 password=TEST_USER_REGULAR_PASS,
412 password=TEST_USER_REGULAR_PASS,
411 ignoreReturnCode=True)
413 ignoreReturnCode=True)
@@ -418,9 +420,9 b' class TestVCSOperations(TestController):'
418 # for example on Linux if /tmp is mounted noexec.
420 # for example on Linux if /tmp is mounted noexec.
419
421
420 # clone some temp
422 # clone some temp
421 DEST = _get_tmp_dir()
423 dest_dir = _get_tmp_dir()
422 clone_url = webserver.repo_url(GIT_REPO)
424 clone_url = webserver.repo_url(GIT_REPO)
423 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
425 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
424
426
425 # lock repo
427 # lock repo
426 r = Repository.get_by_repo_name(GIT_REPO)
428 r = Repository.get_by_repo_name(GIT_REPO)
@@ -431,7 +433,7 b' class TestVCSOperations(TestController):'
431 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id)
433 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id)
432
434
433 # push fails repo is locked by other user !
435 # push fails repo is locked by other user !
434 stdout, stderr = _add_files_and_push(webserver, 'git', DEST,
436 stdout, stderr = _add_files_and_push(webserver, 'git', dest_dir,
435 username=TEST_USER_REGULAR_LOGIN,
437 username=TEST_USER_REGULAR_LOGIN,
436 password=TEST_USER_REGULAR_PASS,
438 password=TEST_USER_REGULAR_PASS,
437 ignoreReturnCode=True)
439 ignoreReturnCode=True)
@@ -454,9 +456,9 b' class TestVCSOperations(TestController):'
454 r.enable_locking = True
456 r.enable_locking = True
455 Session().commit()
457 Session().commit()
456 # clone some temp
458 # clone some temp
457 DEST = _get_tmp_dir()
459 dest_dir = _get_tmp_dir()
458 clone_url = webserver.repo_url(fork_name)
460 clone_url = webserver.repo_url(fork_name)
459 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, DEST)
461 stdout, stderr = Command(TESTS_TMP_PATH).execute('hg clone', clone_url, dest_dir)
460
462
461 # check for lock repo after clone
463 # check for lock repo after clone
462 r = Repository.get_by_repo_name(fork_name)
464 r = Repository.get_by_repo_name(fork_name)
@@ -464,7 +466,7 b' class TestVCSOperations(TestController):'
464 assert r.locked[0] == uid
466 assert r.locked[0] == uid
465
467
466 # push is ok and repo is now unlocked
468 # push is ok and repo is now unlocked
467 stdout, stderr = _add_files_and_push(webserver, 'hg', DEST, clone_url=clone_url)
469 stdout, stderr = _add_files_and_push(webserver, 'hg', dest_dir, clone_url=clone_url)
468 assert str('remote: Released lock on repo `%s`' % fork_name) in stdout
470 assert str('remote: Released lock on repo `%s`' % fork_name) in stdout
469 # we need to cleanup the Session Here !
471 # we need to cleanup the Session Here !
470 Session.remove()
472 Session.remove()
@@ -480,16 +482,16 b' class TestVCSOperations(TestController):'
480 r.enable_locking = True
482 r.enable_locking = True
481 Session().commit()
483 Session().commit()
482 # clone some temp
484 # clone some temp
483 DEST = _get_tmp_dir()
485 dest_dir = _get_tmp_dir()
484 clone_url = webserver.repo_url(fork_name)
486 clone_url = webserver.repo_url(fork_name)
485 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, DEST)
487 stdout, stderr = Command(TESTS_TMP_PATH).execute('git clone', clone_url, dest_dir)
486
488
487 # check for lock repo after clone
489 # check for lock repo after clone
488 r = Repository.get_by_repo_name(fork_name)
490 r = Repository.get_by_repo_name(fork_name)
489 assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id
491 assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id
490
492
491 # push is ok and repo is now unlocked
493 # push is ok and repo is now unlocked
492 stdout, stderr = _add_files_and_push(webserver, 'git', DEST, clone_url=clone_url)
494 stdout, stderr = _add_files_and_push(webserver, 'git', dest_dir, clone_url=clone_url)
493 _check_proper_git_push(stdout, stderr)
495 _check_proper_git_push(stdout, stderr)
494
496
495 assert ('remote: Released lock on repo `%s`' % fork_name) in stderr
497 assert ('remote: Released lock on repo `%s`' % fork_name) in stderr
@@ -236,7 +236,7 b' class GitRepositoryTest(unittest.TestCas'
236 def test_changeset10(self):
236 def test_changeset10(self):
237
237
238 chset10 = self.repo.get_changeset(self.repo.revisions[9])
238 chset10 = self.repo.get_changeset(self.repo.revisions[9])
239 README = """===
239 readme = """===
240 VCS
240 VCS
241 ===
241 ===
242
242
@@ -250,7 +250,7 b' TODO: To be written...'
250 """
250 """
251 node = chset10.get_node('README.rst')
251 node = chset10.get_node('README.rst')
252 self.assertEqual(node.kind, NodeKind.FILE)
252 self.assertEqual(node.kind, NodeKind.FILE)
253 self.assertEqual(node.content, README)
253 self.assertEqual(node.content, readme)
254
254
255
255
256 class GitChangesetTest(unittest.TestCase):
256 class GitChangesetTest(unittest.TestCase):
@@ -218,7 +218,7 b' class MercurialRepositoryTest(unittest.T'
218 def test_changeset10(self):
218 def test_changeset10(self):
219
219
220 chset10 = self.repo.get_changeset(10)
220 chset10 = self.repo.get_changeset(10)
221 README = """===
221 readme = """===
222 VCS
222 VCS
223 ===
223 ===
224
224
@@ -232,7 +232,7 b' TODO: To be written...'
232 """
232 """
233 node = chset10.get_node('README.rst')
233 node = chset10.get_node('README.rst')
234 self.assertEqual(node.kind, NodeKind.FILE)
234 self.assertEqual(node.kind, NodeKind.FILE)
235 self.assertEqual(node.content, README)
235 self.assertEqual(node.content, readme)
236
236
237
237
238 class MercurialChangesetTest(unittest.TestCase):
238 class MercurialChangesetTest(unittest.TestCase):
General Comments 0
You need to be logged in to leave comments. Login now