comparison rhodecode/tests/test_concurency.py @ 1532:2afe9320d5e6 beta

updated docstrings
author Marcin Kuzminski <marcin@python-works.com>
date Sat, 08 Oct 2011 03:00:03 +0200
parents 0b268dd369ec
children
comparison
equal deleted inserted replaced
1531:7d64456775ad 1532:2afe9320d5e6
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5 5
6 Test suite for making push/pull operations 6 Test suite for making push/pull operations
7 7
8 :created_on: Dec 30, 2010 8 :created_on: Dec 30, 2010
9 :copyright: (c) 2010 by marcink. 9 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com>
10 :license: LICENSE_NAME, see LICENSE_FILE for more details. 10 :license: GPLv3, see COPYING for more details.
11 """ 11 """
12 # This program is free software: you can redistribute it and/or modify
13 # it under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
16 #
17 # This program is distributed in the hope that it will be useful,
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 # GNU General Public License for more details.
21 #
22 # You should have received a copy of the GNU General Public License
23 # along with this program. If not, see <http://www.gnu.org/licenses/>.
12 24
13 import os 25 import os
14 import sys 26 import sys
15 import shutil 27 import shutil
16 import logging 28 import logging
121 'private':False, 133 'private':False,
122 'clone_uri':'' } 134 'clone_uri':'' }
123 rm = RepoModel(sa) 135 rm = RepoModel(sa)
124 rm.base_path = '/home/hg' 136 rm.base_path = '/home/hg'
125 rm.create(form_data, user) 137 rm.create(form_data, user)
126 138
127 print 'done' 139 print 'done'
128 140
129 def set_anonymous_access(enable=True): 141 def set_anonymous_access(enable=True):
130 sa = get_session() 142 sa = get_session()
131 user = sa.query(User).filter(User.username == 'default').one() 143 user = sa.query(User).filter(User.username == 'default').one()
139 151
140 152
141 #============================================================================== 153 #==============================================================================
142 # TESTS 154 # TESTS
143 #============================================================================== 155 #==============================================================================
144 def test_clone_with_credentials(no_errors=False,repo=HG_REPO): 156 def test_clone_with_credentials(no_errors=False, repo=HG_REPO):
145 cwd = path = jn(TESTS_TMP_PATH, repo) 157 cwd = path = jn(TESTS_TMP_PATH, repo)
146 158
147 159
148 try: 160 try:
149 shutil.rmtree(path, ignore_errors=True) 161 shutil.rmtree(path, ignore_errors=True)
150 os.makedirs(path) 162 os.makedirs(path)
151 #print 'made dirs %s' % jn(path) 163 #print 'made dirs %s' % jn(path)
152 except OSError: 164 except OSError:
156 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \ 168 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \
157 {'user':USER, 169 {'user':USER,
158 'pass':PASS, 170 'pass':PASS,
159 'host':HOST, 171 'host':HOST,
160 'cloned_repo':repo, 172 'cloned_repo':repo,
161 'dest':path+_RandomNameSequence().next()} 173 'dest':path + _RandomNameSequence().next()}
162 174
163 stdout, stderr = Command(cwd).execute('hg clone', clone_url) 175 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
164 176
165 if no_errors is False: 177 if no_errors is False:
166 assert """adding file changes""" in stdout, 'no messages about cloning' 178 assert """adding file changes""" in stdout, 'no messages about cloning'
171 create_test_user(force=False) 183 create_test_user(force=False)
172 184
173 for i in range(int(sys.argv[2])): 185 for i in range(int(sys.argv[2])):
174 test_clone_with_credentials(repo=sys.argv[1]) 186 test_clone_with_credentials(repo=sys.argv[1])
175 187
176 except Exception,e: 188 except Exception, e:
177 sys.exit('stop on %s' % e) 189 sys.exit('stop on %s' % e)