Show More
@@ -194,8 +194,7 b" ui_sections = ['alias', 'auth'," | |||
|
194 | 194 | 'ui', 'web', ] |
|
195 | 195 | |
|
196 | 196 | def make_ui(read_from='file', path=None, checkpaths=True): |
|
197 | """ | |
|
198 | A function that will read python rc files or database | |
|
197 | """A function that will read python rc files or database | |
|
199 | 198 | and make an mercurial ui object from read options |
|
200 | 199 | |
|
201 | 200 | :param path: path to mercurial config file |
@@ -13,12 +13,28 b'' | |||
|
13 | 13 | import os |
|
14 | 14 | import shutil |
|
15 | 15 | import logging |
|
16 | from os.path import join as jn | |
|
16 | 17 | |
|
18 | from tempfile import _RandomNameSequence | |
|
17 | 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 | 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 | 39 | USER = 'test_admin' |
|
24 | 40 | PASS = 'test12' |
@@ -46,6 +62,32 b' class Command(object):' | |||
|
46 | 62 | print stdout, stderr |
|
47 | 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 | 93 | # TESTS |
@@ -136,18 +178,18 b' def test_push():' | |||
|
136 | 178 | |
|
137 | 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 | 183 | test_clone() |
|
142 | 184 | |
|
143 | 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 | 188 | Command(cwd).execute('touch %s' % added_file) |
|
147 | 189 | |
|
148 | 190 | Command(cwd).execute('hg add %s' % added_file) |
|
149 | 191 | |
|
150 |
for i in xrange( |
|
|
192 | for i in xrange(commits): | |
|
151 | 193 | cmd = """echo 'added_line%s' >> %s""" % (i, added_file) |
|
152 | 194 | Command(cwd).execute(cmd) |
|
153 | 195 | |
@@ -161,7 +203,7 b' def test_push_new_file():' | |||
|
161 | 203 | 'cloned_repo':HG_REPO, |
|
162 | 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 | 208 | def test_push_wrong_credentials(): |
|
167 | 209 | |
@@ -216,12 +258,13 b' def test_push_wrong_path():' | |||
|
216 | 258 | |
|
217 | 259 | |
|
218 | 260 | if __name__ == '__main__': |
|
219 |
|
|
|
261 | create_test_user() | |
|
262 | #test_clone() | |
|
220 | 263 | |
|
221 | 264 | #test_clone_wrong_credentials() |
|
222 | 265 | ##test_clone_anonymous_ok() |
|
223 | test_pull() | |
|
224 |
|
|
|
266 | #test_pull() | |
|
267 | test_push_new_file(3) | |
|
225 | 268 | #test_push_wrong_path() |
|
226 | 269 | #test_push_wrong_credentials() |
|
227 | 270 |
General Comments 0
You need to be logged in to leave comments.
Login now