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