Mercurial > kallithea
comparison rhodecode/tests/scripts/test_vcs_operations.py @ 3480:bc7fb3e8d77e beta
again they channged git return commands :/ and i need to fix the tests. Now running agains 1.8.1
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 06 Mar 2013 14:14:57 +0100 |
parents | 9f57b5624ec4 |
children | b5c3680e7c76 |
comparison
equal
deleted
inserted
replaced
3479:b45c8916644c | 3480:bc7fb3e8d77e |
---|---|
2 """ | 2 """ |
3 rhodecode.tests.test_scm_operations | 3 rhodecode.tests.test_scm_operations |
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
5 | 5 |
6 Test suite for making push/pull operations. | 6 Test suite for making push/pull operations. |
7 Run using:: | 7 Run using after doing paster serve test.ini:: |
8 | |
9 RC_WHOOSH_TEST_DISABLE=1 RC_NO_TMP_PATH=1 nosetests rhodecode/tests/scripts/test_vcs_operations.py | 8 RC_WHOOSH_TEST_DISABLE=1 RC_NO_TMP_PATH=1 nosetests rhodecode/tests/scripts/test_vcs_operations.py |
9 | |
10 You must have git > 1.8.1 for tests to work fine | |
10 | 11 |
11 :created_on: Dec 30, 2010 | 12 :created_on: Dec 30, 2010 |
12 :author: marcink | 13 :author: marcink |
13 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> | 14 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
14 :license: GPLv3, see COPYING for more details. | 15 :license: GPLv3, see COPYING for more details. |
105 Command(cwd).execute('%s add %s' % (vcs, added_file)) | 106 Command(cwd).execute('%s add %s' % (vcs, added_file)) |
106 | 107 |
107 for i in xrange(3): | 108 for i in xrange(3): |
108 cmd = """echo 'added_line%s' >> %s""" % (i, added_file) | 109 cmd = """echo 'added_line%s' >> %s""" % (i, added_file) |
109 Command(cwd).execute(cmd) | 110 Command(cwd).execute(cmd) |
111 author_str = 'Marcin Kuźminski <me@email.com>' | |
110 if vcs == 'hg': | 112 if vcs == 'hg': |
111 cmd = """hg commit -m 'commited new %s' -u '%s' %s """ % ( | 113 cmd = """hg commit -m 'commited new %s' -u '%s' %s """ % ( |
112 i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file | 114 i, author_str, added_file |
113 ) | 115 ) |
114 elif vcs == 'git': | 116 elif vcs == 'git': |
115 cmd = """git commit -m 'commited new %s' --author '%s' %s """ % ( | 117 cmd = """git commit -m 'commited new %s' --author '%s' %s """ % ( |
116 i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file | 118 i, author_str, added_file |
117 ) | 119 ) |
118 Command(cwd).execute(cmd) | 120 Command(cwd).execute(cmd) |
119 # PUSH it back | 121 # PUSH it back |
120 if vcs == 'hg': | 122 if vcs == 'hg': |
121 _REPO = HG_REPO | 123 _REPO = HG_REPO |
127 if 'clone_url' in kwargs: | 129 if 'clone_url' in kwargs: |
128 clone_url = kwargs['clone_url'] | 130 clone_url = kwargs['clone_url'] |
129 if vcs == 'hg': | 131 if vcs == 'hg': |
130 stdout, stderr = Command(cwd).execute('hg push --verbose', clone_url) | 132 stdout, stderr = Command(cwd).execute('hg push --verbose', clone_url) |
131 elif vcs == 'git': | 133 elif vcs == 'git': |
132 stdout, stderr = Command(cwd).execute('git push', clone_url + " master") | 134 stdout, stderr = Command(cwd).execute('git push --verbose', clone_url + " master") |
133 | 135 |
134 return stdout, stderr | 136 return stdout, stderr |
135 | 137 |
136 | 138 |
137 def set_anonymous_access(enable=True): | 139 def set_anonymous_access(enable=True): |
322 r = Repository.get_by_repo_name(GIT_REPO) | 324 r = Repository.get_by_repo_name(GIT_REPO) |
323 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) | 325 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) |
324 #pull fails since repo is locked | 326 #pull fails since repo is locked |
325 clone_url = _construct_url(GIT_REPO) | 327 clone_url = _construct_url(GIT_REPO) |
326 stdout, stderr = Command('/tmp').execute('git clone', clone_url) | 328 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
327 msg = ("""423 Repository `%s` locked by user `%s`""" | 329 msg = ("""The requested URL returned error: 423""") |
328 % (GIT_REPO, TEST_USER_ADMIN_LOGIN)) | |
329 assert msg in stderr | 330 assert msg in stderr |
330 | 331 |
331 def test_push_on_locked_repo_by_other_user_hg(self): | 332 def test_push_on_locked_repo_by_other_user_hg(self): |
332 #clone some temp | 333 #clone some temp |
333 DEST = _get_tmp_dir() | 334 DEST = _get_tmp_dir() |
453 try: | 454 try: |
454 user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') | 455 user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
455 Session().commit() | 456 Session().commit() |
456 clone_url = _construct_url(GIT_REPO) | 457 clone_url = _construct_url(GIT_REPO) |
457 stdout, stderr = Command('/tmp').execute('git clone', clone_url) | 458 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
458 assert 'error: The requested URL returned error: 403 Forbidden' in stderr | 459 msg = ("""The requested URL returned error: 403""") |
460 assert msg in stderr | |
459 finally: | 461 finally: |
460 #release IP restrictions | 462 #release IP restrictions |
461 for ip in UserIpMap.getAll(): | 463 for ip in UserIpMap.getAll(): |
462 UserIpMap.delete(ip.ip_id) | 464 UserIpMap.delete(ip.ip_id) |
463 Session().commit() | 465 Session().commit() |