##// END OF EJS Templates
updated testing script for hg operations
marcink -
r1008:a9421a8a beta
parent child Browse files
Show More
@@ -25,7 +25,7 from sqlalchemy import engine_from_confi
25 25 from rhodecode.lib.utils import add_cache
26 26 from rhodecode.model import init_model
27 27 from rhodecode.model import meta
28 from rhodecode.model.db import User
28 from rhodecode.model.db import User, Repository
29 29 from rhodecode.lib.auth import get_crypt_password
30 30
31 31 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
@@ -70,15 +70,18 def get_session():
70 70
71 71
72 72 def create_test_user(force=True):
73 print 'creating test user'
73 74 sa = get_session()
74 75
75 76 user = sa.query(User).filter(User.username == USER).scalar()
76 77
77 if force and user:
78 if force and user is not None:
79 print 'removing current user'
78 80 sa.delete(user)
79 81 sa.commit()
80 82
81 83 if user is None or force:
84 print 'creating new one'
82 85 new_usr = User()
83 86 new_usr.username = USER
84 87 new_usr.password = get_crypt_password(PASS)
@@ -86,17 +89,38 def create_test_user(force=True):
86 89 new_usr.name = 'test'
87 90 new_usr.lastname = 'lasttestname'
88 91 new_usr.active = True
89
92 new_usr.admin = True
90 93 sa.add(new_usr)
91 94 sa.commit()
92 95
96 print 'done'
97
98
99 def create_test_repo(force=True):
100 from rhodecode.model.repo import RepoModel
101 sa = get_session()
102
103 user = sa.query(User).filter(User.username == USER).scalar()
104 if user is None:
105 raise Exception('user not found')
93 106
94 107
108 repo = sa.query(Repository).filter(Repository.repo_name == HG_REPO).scalar()
109
110 if repo is None:
111 print 'repo not found creating'
112
113 form_data = {'repo_name':HG_REPO,
114 'repo_type':'hg',
115 'private':False, }
116 rm = RepoModel(sa)
117 rm.base_path = '/home/hg'
118 rm.create(form_data, user)
95 119
96 120 #==============================================================================
97 121 # TESTS
98 122 #==============================================================================
99 def test_clone():
123 def test_clone(no_errors=False):
100 124 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
101 125
102 126 try:
@@ -116,6 +140,7 def test_clone():
116 140
117 141 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
118 142
143 if no_errors is False:
119 144 assert """adding file changes""" in stdout, 'no messages about cloning'
120 145 assert """abort""" not in stderr , 'got error from clone'
121 146
@@ -170,9 +195,9 def test_clone_wrong_credentials():
170 195 def test_pull():
171 196 pass
172 197
173 def test_push():
174
175 modified_file = jn(TESTS_TMP_PATH, HG_REPO, 'setup.py')
198 def test_push_modify_file(f_name='setup.py'):
199 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
200 modified_file = jn(TESTS_TMP_PATH, HG_REPO, f_name)
176 201 for i in xrange(5):
177 202 cmd = """echo 'added_line%s' >> %s""" % (i, modified_file)
178 203 Command(cwd).execute(cmd)
@@ -184,7 +209,7 def test_push():
184 209
185 210 def test_push_new_file(commits=15):
186 211
187 test_clone()
212 test_clone(no_errors=True)
188 213
189 214 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
190 215 added_file = jn(path, '%ssetup.py' % _RandomNameSequence().next())
@@ -210,7 +235,7 def test_push_new_file(commits=15):
210 235 Command(cwd).execute('hg push --verbose --debug %s' % push_url)
211 236
212 237 def test_push_wrong_credentials():
213
238 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
214 239 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
215 240 {'user':USER + 'xxx',
216 241 'pass':PASS,
@@ -262,14 +287,16 def test_push_wrong_path():
262 287
263 288
264 289 if __name__ == '__main__':
265 #create_test_user()
266 test_clone()
267 test_clone_anonymous_ok()
290 create_test_user(force=False)
291 create_test_repo()
292 #test_push_modify_file()
293 #test_clone()
294 #test_clone_anonymous_ok()
268 295
269 296 #test_clone_wrong_credentials()
270 297
271 298 #test_pull()
272 #test_push_new_file(3)
299 test_push_new_file(commits=3)
273 300 #test_push_wrong_path()
274 301 #test_push_wrong_credentials()
275 302
General Comments 0
You need to be logged in to leave comments. Login now