##// END OF EJS Templates
Added sql session into test hg script...
marcink -
r930:f9016563 beta
parent child Browse files
Show More
@@ -194,8 +194,7 b" ui_sections = ['alias', 'auth',"
194 'ui', 'web', ]
194 'ui', 'web', ]
195
195
196 def make_ui(read_from='file', path=None, checkpaths=True):
196 def make_ui(read_from='file', path=None, checkpaths=True):
197 """
197 """A function that will read python rc files or database
198 A function that will read python rc files or database
199 and make an mercurial ui object from read options
198 and make an mercurial ui object from read options
200
199
201 :param path: path to mercurial config file
200 :param path: path to mercurial config file
@@ -13,12 +13,28 b''
13 import os
13 import os
14 import shutil
14 import shutil
15 import logging
15 import logging
16 from os.path import join as jn
16
17
18 from tempfile import _RandomNameSequence
17 from subprocess import Popen, PIPE
19 from subprocess import Popen, PIPE
18
20
19 from os.path import join as jn
21 from paste.deploy import appconfig
22 from pylons import config
23 from sqlalchemy import engine_from_config
24
25 from rhodecode.lib.utils import add_cache
26 from rhodecode.model import init_model
27 from rhodecode.model import meta
28 from rhodecode.model.db import User
29 from rhodecode.lib.auth import get_crypt_password
20
30
21 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
31 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
32 from rhodecode.config.environment import load_environment
33
34 conf = appconfig('config:development.ini', relative_to='./../../')
35 load_environment(conf.global_conf, conf.local_conf)
36
37 add_cache(conf)
22
38
23 USER = 'test_admin'
39 USER = 'test_admin'
24 PASS = 'test12'
40 PASS = 'test12'
@@ -46,6 +62,32 b' class Command(object):'
46 print stdout, stderr
62 print stdout, stderr
47 return stdout, stderr
63 return stdout, stderr
48
64
65 def get_session():
66 engine = engine_from_config(conf, 'sqlalchemy.db1.')
67 init_model(engine)
68 sa = meta.Session()
69 return sa
70
71
72 def create_test_user(force=True):
73 sa = get_session()
74
75 user = sa.query(User).filter(User.username == USER).scalar()
76 if force:
77 sa.delete(user)
78 sa.commit()
79
80 if user is None or force:
81 new_usr = User()
82 new_usr.username = USER
83 new_usr.password = get_crypt_password(PASS)
84 new_usr.active = True
85
86 sa.add(new_usr)
87 sa.commit()
88
89
90
49
91
50 #==============================================================================
92 #==============================================================================
51 # TESTS
93 # TESTS
@@ -136,18 +178,18 b' def test_push():'
136
178
137 Command(cwd).execute('hg push %s' % jn(TESTS_TMP_PATH, HG_REPO))
179 Command(cwd).execute('hg push %s' % jn(TESTS_TMP_PATH, HG_REPO))
138
180
139 def test_push_new_file():
181 def test_push_new_file(commits=15):
140
182
141 test_clone()
183 test_clone()
142
184
143 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
185 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
144 added_file = jn(path, 'setup.py')
186 added_file = jn(path, '%ssetup.py' % _RandomNameSequence().next())
145
187
146 Command(cwd).execute('touch %s' % added_file)
188 Command(cwd).execute('touch %s' % added_file)
147
189
148 Command(cwd).execute('hg add %s' % added_file)
190 Command(cwd).execute('hg add %s' % added_file)
149
191
150 for i in xrange(15):
192 for i in xrange(commits):
151 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
193 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
152 Command(cwd).execute(cmd)
194 Command(cwd).execute(cmd)
153
195
@@ -161,7 +203,7 b' def test_push_new_file():'
161 'cloned_repo':HG_REPO,
203 'cloned_repo':HG_REPO,
162 'dest':jn(TESTS_TMP_PATH, HG_REPO)}
204 'dest':jn(TESTS_TMP_PATH, HG_REPO)}
163
205
164 Command(cwd).execute('hg push %s' % push_url)
206 Command(cwd).execute('hg push --verbose --debug %s' % push_url)
165
207
166 def test_push_wrong_credentials():
208 def test_push_wrong_credentials():
167
209
@@ -216,12 +258,13 b' def test_push_wrong_path():'
216
258
217
259
218 if __name__ == '__main__':
260 if __name__ == '__main__':
219 test_clone()
261 create_test_user()
262 #test_clone()
220
263
221 #test_clone_wrong_credentials()
264 #test_clone_wrong_credentials()
222 ##test_clone_anonymous_ok()
265 ##test_clone_anonymous_ok()
223 test_pull()
266 #test_pull()
224 #test_push_new_file()
267 test_push_new_file(3)
225 #test_push_wrong_path()
268 #test_push_wrong_path()
226 #test_push_wrong_credentials()
269 #test_push_wrong_credentials()
227
270
General Comments 0
You need to be logged in to leave comments. Login now