##// END OF EJS Templates
fixed test_hg_push operations
marcink -
r1596:089ef495 beta
parent child Browse files
Show More
@@ -48,7 +48,8 b' from rhodecode.tests import TESTS_TMP_PA'
48 48 from rhodecode.config.environment import load_environment
49 49
50 50 rel_path = dn(dn(dn(os.path.abspath(__file__))))
51 conf = appconfig('config:development.ini', relative_to=rel_path)
51
52 conf = appconfig('config:%s' % sys.argv[1], relative_to=rel_path)
52 53 load_environment(conf.global_conf, conf.local_conf)
53 54
54 55 add_cache(conf)
@@ -56,10 +57,13 b' add_cache(conf)'
56 57 USER = 'test_admin'
57 58 PASS = 'test12'
58 59 HOST = '127.0.0.1:5000'
59 DEBUG = True if sys.argv[1:] else False
60 DEBUG = False
60 61 print 'DEBUG:', DEBUG
61 62 log = logging.getLogger(__name__)
62 63
64 engine = engine_from_config(conf, 'sqlalchemy.db1.')
65 init_model(engine)
66 sa = meta.Session
63 67
64 68 class Command(object):
65 69
@@ -96,22 +100,15 b' def test_wrapp(func):'
96 100 return res
97 101 return __wrapp
98 102
99 def get_session():
100 engine = engine_from_config(conf, 'sqlalchemy.db1.')
101 init_model(engine)
102 sa = meta.Session
103 return sa
104
105 103
106 104 def create_test_user(force=True):
107 105 print '\tcreating test user'
108 sa = get_session()
109 106
110 user = sa.query(User).filter(User.username == USER).scalar()
107 user = User.get_by_username(USER)
111 108
112 109 if force and user is not None:
113 110 print '\tremoving current user'
114 for repo in sa.query(Repository).filter(Repository.user == user).all():
111 for repo in Repository.query().filter(Repository.user == user).all():
115 112 sa.delete(repo)
116 113 sa.delete(user)
117 114 sa.commit()
@@ -134,9 +131,8 b' def create_test_user(force=True):'
134 131
135 132 def create_test_repo(force=True):
136 133 from rhodecode.model.repo import RepoModel
137 sa = get_session()
138 134
139 user = sa.query(User).filter(User.username == USER).scalar()
135 user = User.get_by_username(USER)
140 136 if user is None:
141 137 raise Exception('user not found')
142 138
@@ -156,22 +152,17 b' def create_test_repo(force=True):'
156 152
157 153
158 154 def set_anonymous_access(enable=True):
159 sa = get_session()
160 user = sa.query(User).filter(User.username == 'default').one()
161 sa.expire(user)
155 user = User.get_by_username('default')
162 156 user.active = enable
163 157 sa.add(user)
164 158 sa.commit()
165 sa.remove()
166 import time;time.sleep(3)
167 159 print '\tanonymous access is now:', enable
168
160 if enable != User.get_by_username('default').active:
161 raise Exception('Cannot set anonymous access')
169 162
170 163 def get_anonymous_access():
171 sa = get_session()
172 obj1 = sa.query(User).filter(User.username == 'default').one()
173 sa.expire(obj1)
174 return obj1.active
164 user = User.get_by_username('default')
165 return user.active
175 166
176 167
177 168 #==============================================================================
@@ -378,16 +369,15 b' def test_push_wrong_path():'
378 369
379 370 @test_wrapp
380 371 def get_logs():
381 sa = get_session()
382 return len(sa.query(UserLog).all())
372 return UserLog.query().all()
383 373
384 374 @test_wrapp
385 375 def test_logs(initial):
386 sa = get_session()
387 logs = sa.query(UserLog).all()
388 operations = 7
389 if initial + operations != len(logs):
390 raise Exception("missing number of logs %s vs %s" % (initial, len(logs)))
376 logs = UserLog.query().all()
377 operations = 4
378 if len(initial) + operations != len(logs):
379 raise Exception("missing number of logs initial:%s vs current:%s" % \
380 (len(initial), len(logs)))
391 381
392 382
393 383 if __name__ == '__main__':
@@ -395,18 +385,17 b" if __name__ == '__main__':"
395 385 create_test_repo()
396 386
397 387 initial_logs = get_logs()
388 print 'initial activity logs: %s' % len(initial_logs)
398 389
399 # test_push_modify_file()
390 #test_push_modify_file()
400 391 test_clone_with_credentials()
401 392 test_clone_wrong_credentials()
402 393
403
404 394 test_push_new_file(commits=2, with_clone=True)
405 395
406 396 test_clone_anonymous()
407 397 test_push_wrong_path()
408 398
409
410 399 test_push_wrong_credentials()
411 400
412 401 test_logs(initial_logs)
General Comments 0
You need to be logged in to leave comments. Login now