Mercurial > kallithea
annotate rhodecode/tests/_test_concurency.py @ 2375:bc2d8c03c050 beta
Implemented #467 Journal logs comments on changesets
- added created/updated user action to journal
- added created/updated users group action journal
- added ip adresses to most of action_log calls to track IP changes
- rewrote action_parser to simpler and more efficient solution
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Sun, 03 Jun 2012 00:40:14 +0200 |
parents | 89efedac4e6c |
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 |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1813
diff
changeset
|
9 :author: marcink |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1813
diff
changeset
|
10 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
11 :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
|
12 """ |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
13 # 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
|
14 # 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
|
15 # the Free Software Foundation, either version 3 of the License, or |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
16 # (at your option) any later version. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
17 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
18 # 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
|
19 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
20 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
21 # GNU General Public License for more details. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
22 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
23 # 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
|
24 # 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
|
25 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
26 import os |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
27 import sys |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
28 import shutil |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
29 import logging |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
30 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
|
31 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
|
32 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
33 from tempfile import _RandomNameSequence |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
34 from subprocess import Popen, PIPE |
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 from paste.deploy import appconfig |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
37 from pylons import config |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
38 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
|
39 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
40 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
|
41 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
|
42 from rhodecode.model import meta |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
43 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
|
44 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
|
45 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
46 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
|
47 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
|
48 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
49 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
|
50 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
|
51 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
|
52 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
53 add_cache(conf) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
54 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
55 USER = 'test_admin' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
56 PASS = 'test12' |
1734
48d4fcf04a29
another major refactoring with session management
Marcin Kuzminski <marcin@python-works.com>
parents:
1666
diff
changeset
|
57 HOST = 'hg.local' |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
58 METHOD = 'pull' |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
59 DEBUG = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
60 log = logging.getLogger(__name__) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
61 |
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 class Command(object): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
64 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
65 def __init__(self, cwd): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
66 self.cwd = cwd |
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 execute(self, cmd, *args): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
69 """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
|
70 """ |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
71 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
72 command = cmd + ' ' + ' '.join(args) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
73 log.debug('Executing %s' % command) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
74 if DEBUG: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
75 print command |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
76 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
|
77 stdout, stderr = p.communicate() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
78 if DEBUG: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
79 print stdout, stderr |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
80 return stdout, stderr |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
81 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
82 def get_session(): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
83 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
|
84 init_model(engine) |
1749
8ecc6b8229a5
commit less models
Marcin Kuzminski <marcin@python-works.com>
parents:
1734
diff
changeset
|
85 sa = meta.Session |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
86 return sa |
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 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
89 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
|
90 print 'creating test user' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
91 sa = get_session() |
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 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
|
94 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
95 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
|
96 print 'removing current user' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
97 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
|
98 sa.delete(repo) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
99 sa.delete(user) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
100 sa.commit() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
101 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
102 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
|
103 print 'creating new one' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
104 new_usr = User() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
105 new_usr.username = USER |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
106 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
|
107 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
|
108 new_usr.name = 'test' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
109 new_usr.lastname = 'lasttestname' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
110 new_usr.active = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
111 new_usr.admin = True |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
112 sa.add(new_usr) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
113 sa.commit() |
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 print 'done' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
116 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
117 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
118 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
|
119 print 'creating test repo' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
120 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
|
121 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
122 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
123 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
|
124 if user is None: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
125 raise Exception('user not found') |
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 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
128 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
|
129 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
130 if repo is None: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
131 print 'repo not found creating' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
132 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
133 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
|
134 'repo_type':'hg', |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
135 'private':False, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
136 'clone_uri':'' } |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
137 rm = RepoModel(sa) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
138 rm.base_path = '/home/hg' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
139 rm.create(form_data, user) |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
140 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
141 print 'done' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
142 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
143 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
|
144 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
145 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
|
146 user.active = enable |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
147 sa.add(user) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
148 sa.commit() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
149 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
150 def get_anonymous_access(): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
151 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
152 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
|
153 |
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 # TESTS |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
157 #============================================================================== |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
158 def test_clone_with_credentials(no_errors=False, repo=HG_REPO, method=METHOD, |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
159 seq=None): |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
160 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
|
161 |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
162 if seq == None: |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
163 seq = _RandomNameSequence().next() |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
164 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
165 try: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
166 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
|
167 os.makedirs(path) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
168 #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
|
169 except OSError: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
170 raise |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
171 |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
172 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \ |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
173 {'user':USER, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
174 'pass':PASS, |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
175 'host':HOST, |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
176 'cloned_repo':repo, } |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
177 |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
178 dest = path + seq |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
179 if method == 'pull': |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
180 stdout, stderr = Command(cwd).execute('hg', method, '--cwd', dest, clone_url) |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
181 else: |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
182 stdout, stderr = Command(cwd).execute('hg', method, clone_url, dest) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
183 |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
184 if no_errors is False: |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
185 assert """adding file changes""" in stdout, 'no messages about cloning' |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
186 assert """abort""" not in stderr , 'got error from clone' |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
187 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
188 if __name__ == '__main__': |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
189 try: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
190 create_test_user(force=False) |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
191 seq = None |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
192 import time |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
193 |
1813
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
194 try: |
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
195 METHOD = sys.argv[3] |
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
196 except: |
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
197 pass |
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
198 |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
199 if METHOD == 'pull': |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
200 seq = _RandomNameSequence().next() |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
201 test_clone_with_credentials(repo=sys.argv[1], method='clone', |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
202 seq=seq) |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
203 s = time.time() |
1813
a8c66e870bd0
implements #285: Implemented non changeable urls for clone url, and web views
Marcin Kuzminski <marcin@python-works.com>
parents:
1749
diff
changeset
|
204 for i in range(1, int(sys.argv[2]) + 1): |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
205 print 'take', i |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
206 test_clone_with_credentials(repo=sys.argv[1], method=METHOD, |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
207 seq=seq) |
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
208 print 'time taken %.3f' % (time.time() - s) |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
209 except Exception, e: |
1666
a404060706c0
test concurency script updates
Marcin Kuzminski <marcin@python-works.com>
parents:
1628
diff
changeset
|
210 raise |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
211 sys.exit('stop on %s' % e) |