annotate rhodecode/tests/test_concurency.py @ 1529:0b268dd369ec beta

Fixed test_hg_operations test and added concurency test
author Marcin Kuzminski <marcin@python-works.com>
date Fri, 07 Oct 2011 23:17:45 +0200
parents
children 2afe9320d5e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1529
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
1 # -*- coding: utf-8 -*-
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
2 """
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
3 rhodecode.tests.test_hg_operations
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
5
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
6 Test suite for making push/pull operations
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
7
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
8 :created_on: Dec 30, 2010
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
9 :copyright: (c) 2010 by marcink.
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
10 :license: LICENSE_NAME, see LICENSE_FILE for more details.
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
11 """
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
12
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
13 import os
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
14 import sys
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
15 import shutil
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
16 import logging
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
17 from os.path import join as jn
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
18 from os.path import dirname as dn
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
19
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
20 from tempfile import _RandomNameSequence
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
21 from subprocess import Popen, PIPE
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
22
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
23 from paste.deploy import appconfig
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
24 from pylons import config
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
25 from sqlalchemy import engine_from_config
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
26
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
27 from rhodecode.lib.utils import add_cache
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
28 from rhodecode.model import init_model
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
29 from rhodecode.model import meta
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
30 from rhodecode.model.db import User, Repository
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
31 from rhodecode.lib.auth import get_crypt_password
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
32
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
33 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
34 from rhodecode.config.environment import load_environment
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
35
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
36 rel_path = dn(dn(dn(os.path.abspath(__file__))))
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
37 conf = appconfig('config:development.ini', relative_to=rel_path)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
38 load_environment(conf.global_conf, conf.local_conf)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
39
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
40 add_cache(conf)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
41
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
42 USER = 'test_admin'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
43 PASS = 'test12'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
44 HOST = '127.0.0.1:5000'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
45 DEBUG = True
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
46 log = logging.getLogger(__name__)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
47
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
48
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
49 class Command(object):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
50
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
51 def __init__(self, cwd):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
52 self.cwd = cwd
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
53
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
54 def execute(self, cmd, *args):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
55 """Runs command on the system with given ``args``.
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
56 """
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
57
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
58 command = cmd + ' ' + ' '.join(args)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
59 log.debug('Executing %s' % command)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
60 if DEBUG:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
61 print command
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
62 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=self.cwd)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
63 stdout, stderr = p.communicate()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
64 if DEBUG:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
65 print stdout, stderr
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
66 return stdout, stderr
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
67
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
68 def get_session():
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
69 engine = engine_from_config(conf, 'sqlalchemy.db1.')
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
70 init_model(engine)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
71 sa = meta.Session()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
72 return sa
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
73
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
74
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
75 def create_test_user(force=True):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
76 print 'creating test user'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
77 sa = get_session()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
78
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
79 user = sa.query(User).filter(User.username == USER).scalar()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
80
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
81 if force and user is not None:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
82 print 'removing current user'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
83 for repo in sa.query(Repository).filter(Repository.user == user).all():
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
84 sa.delete(repo)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
85 sa.delete(user)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
86 sa.commit()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
87
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
88 if user is None or force:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
89 print 'creating new one'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
90 new_usr = User()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
91 new_usr.username = USER
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
92 new_usr.password = get_crypt_password(PASS)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93 new_usr.email = 'mail@mail.com'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
94 new_usr.name = 'test'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
95 new_usr.lastname = 'lasttestname'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
96 new_usr.active = True
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
97 new_usr.admin = True
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
98 sa.add(new_usr)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
99 sa.commit()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
100
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
101 print 'done'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
102
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
103
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
104 def create_test_repo(force=True):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
105 print 'creating test repo'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
106 from rhodecode.model.repo import RepoModel
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
107 sa = get_session()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
108
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
109 user = sa.query(User).filter(User.username == USER).scalar()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
110 if user is None:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
111 raise Exception('user not found')
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
112
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
113
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
114 repo = sa.query(Repository).filter(Repository.repo_name == HG_REPO).scalar()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
115
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
116 if repo is None:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
117 print 'repo not found creating'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
118
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
119 form_data = {'repo_name':HG_REPO,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
120 'repo_type':'hg',
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
121 'private':False,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
122 'clone_uri':'' }
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
123 rm = RepoModel(sa)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
124 rm.base_path = '/home/hg'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
125 rm.create(form_data, user)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
126
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
127 print 'done'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
128
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
129 def set_anonymous_access(enable=True):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
130 sa = get_session()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
131 user = sa.query(User).filter(User.username == 'default').one()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
132 user.active = enable
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
133 sa.add(user)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
134 sa.commit()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
135
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
136 def get_anonymous_access():
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
137 sa = get_session()
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
138 return sa.query(User).filter(User.username == 'default').one().active
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
139
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
140
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
141 #==============================================================================
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
142 # TESTS
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
143 #==============================================================================
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
144 def test_clone_with_credentials(no_errors=False,repo=HG_REPO):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
145 cwd = path = jn(TESTS_TMP_PATH, repo)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
146
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
147
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
148 try:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
149 shutil.rmtree(path, ignore_errors=True)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
150 os.makedirs(path)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
151 #print 'made dirs %s' % jn(path)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
152 except OSError:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
153 raise
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
154
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
155
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
156 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
157 {'user':USER,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
158 'pass':PASS,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
159 'host':HOST,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
160 'cloned_repo':repo,
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
161 'dest':path+_RandomNameSequence().next()}
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
162
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
163 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
164
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
165 if no_errors is False:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
166 assert """adding file changes""" in stdout, 'no messages about cloning'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
167 assert """abort""" not in stderr , 'got error from clone'
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
168
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
169 if __name__ == '__main__':
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
170 try:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
171 create_test_user(force=False)
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
172
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
173 for i in range(int(sys.argv[2])):
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
174 test_clone_with_credentials(repo=sys.argv[1])
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
175
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
176 except Exception,e:
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
177 sys.exit('stop on %s' % e)