Mercurial > kallithea
annotate rhodecode/tests/test_concurency.py @ 1605:df59c0503636 beta
implements #215 Repository view uses a README (text/markdown + rst)
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 27 Oct 2011 03:26:02 +0200 |
parents | 2afe9320d5e6 |
children |
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 |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
9 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
10 :license: GPLv3, see COPYING for more details. |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
11 """ |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
12 # This program is free software: you can redistribute it and/or modify |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
13 # it under the terms of the GNU General Public License as published by |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
14 # the Free Software Foundation, either version 3 of the License, or |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
15 # (at your option) any later version. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
16 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
17 # This program is distributed in the hope that it will be useful, |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
20 # GNU General Public License for more details. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
21 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
22 # You should have received a copy of the GNU General Public License |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
23 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
24 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
25 import os |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import sys |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 import shutil |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 import logging |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 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
|
30 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
|
31 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
32 from tempfile import _RandomNameSequence |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from subprocess import Popen, PIPE |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
35 from paste.deploy import appconfig |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
36 from pylons import config |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 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
|
38 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
39 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
|
40 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
|
41 from rhodecode.model import meta |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
42 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
|
43 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
|
44 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
45 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
|
46 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
|
47 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
48 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
|
49 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
|
50 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
|
51 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
52 add_cache(conf) |
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 USER = 'test_admin' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 PASS = 'test12' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 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
|
57 DEBUG = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
58 log = logging.getLogger(__name__) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 class Command(object): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
62 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
63 def __init__(self, cwd): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 self.cwd = cwd |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 def execute(self, cmd, *args): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
67 """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
|
68 """ |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
70 command = cmd + ' ' + ' '.join(args) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 log.debug('Executing %s' % command) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 if DEBUG: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 print command |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 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
|
75 stdout, stderr = p.communicate() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 if DEBUG: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
77 print stdout, stderr |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 return stdout, stderr |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 def get_session(): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 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
|
82 init_model(engine) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 sa = meta.Session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
84 return sa |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
85 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
87 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
|
88 print 'creating test user' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
90 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 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
|
92 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
93 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
|
94 print 'removing current user' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 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
|
96 sa.delete(repo) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 sa.delete(user) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
98 sa.commit() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 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
|
101 print 'creating new one' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 new_usr = User() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
103 new_usr.username = USER |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 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
|
105 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
|
106 new_usr.name = 'test' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
107 new_usr.lastname = 'lasttestname' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
108 new_usr.active = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 new_usr.admin = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 sa.add(new_usr) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 sa.commit() |
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 print 'done' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
114 |
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 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
|
117 print 'creating test repo' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 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
|
119 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
121 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
|
122 if user is None: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 raise Exception('user not found') |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
124 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
126 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
|
127 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 if repo is None: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
129 print 'repo not found creating' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 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
|
132 'repo_type':'hg', |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 'private':False, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
134 'clone_uri':'' } |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 rm = RepoModel(sa) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 rm.base_path = '/home/hg' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 rm.create(form_data, user) |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
138 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 print 'done' |
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 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
|
142 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 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
|
144 user.active = enable |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 sa.add(user) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
146 sa.commit() |
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 def get_anonymous_access(): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 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
|
151 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
152 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
153 #============================================================================== |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
154 # TESTS |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
155 #============================================================================== |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
156 def test_clone_with_credentials(no_errors=False, repo=HG_REPO): |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 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
|
158 |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
159 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 try: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
161 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
|
162 os.makedirs(path) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
163 #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
|
164 except OSError: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
165 raise |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
166 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
167 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
168 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
|
169 {'user':USER, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
170 'pass':PASS, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
171 'host':HOST, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
172 'cloned_repo':repo, |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
173 'dest':path + _RandomNameSequence().next()} |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
175 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
|
176 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 if no_errors is False: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
178 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
|
179 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
|
180 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
181 if __name__ == '__main__': |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
182 try: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 create_test_user(force=False) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
184 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
185 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
|
186 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
|
187 |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
188 except Exception, e: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
189 sys.exit('stop on %s' % e) |