Mercurial > kallithea
annotate rhodecode/tests/test_hg_operations.py @ 1556:1efca2908ae4 beta
fixes issue #248 cannot edit repos inside a group on windows
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 13 Oct 2011 04:26:43 +0200 |
parents | 2afe9320d5e6 |
children | 089ef495e9dd |
rev | line source |
---|---|
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
1 # -*- coding: utf-8 -*- |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
2 """ |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
3 rhodecode.tests.test_hg_operations |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
5 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
6 Test suite for making push/pull operations |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
7 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
8 :created_on: Dec 30, 2010 |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
9 :copyright: (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
10 :license: GPLv3, see COPYING for more details. |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
11 """ |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
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:
1530
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:
1530
diff
changeset
|
14 # the Free Software Foundation, either version 3 of the License, or |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
15 # (at your option) any later version. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
16 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
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:
1530
diff
changeset
|
18 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
20 # GNU General Public License for more details. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
21 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
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:
1530
diff
changeset
|
23 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
24 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
25 import os |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
26 import time |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
27 import sys |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
28 import shutil |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
29 import logging |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
30 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
31 from os.path import join as jn |
1277
cf2a67b91ffc
fixed path for .ini file in test hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
32 from os.path import dirname as dn |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
33 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
34 from tempfile import _RandomNameSequence |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
35 from subprocess import Popen, PIPE |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
36 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
37 from paste.deploy import appconfig |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
38 from pylons import config |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
39 from sqlalchemy import engine_from_config |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
40 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
41 from rhodecode.lib.utils import add_cache |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
42 from rhodecode.model import init_model |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
43 from rhodecode.model import meta |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
44 from rhodecode.model.db import User, Repository, UserLog |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
45 from rhodecode.lib.auth import get_crypt_password |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
46 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
47 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
48 from rhodecode.config.environment import load_environment |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
49 |
1277
cf2a67b91ffc
fixed path for .ini file in test hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
50 rel_path = dn(dn(dn(os.path.abspath(__file__)))) |
cf2a67b91ffc
fixed path for .ini file in test hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1203
diff
changeset
|
51 conf = appconfig('config:development.ini', relative_to=rel_path) |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
52 load_environment(conf.global_conf, conf.local_conf) |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
53 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
54 add_cache(conf) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
55 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
56 USER = 'test_admin' |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
57 PASS = 'test12' |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
58 HOST = '127.0.0.1:5000' |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
59 DEBUG = True if sys.argv[1:] else False |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
60 print 'DEBUG:', DEBUG |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
61 log = logging.getLogger(__name__) |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
62 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
63 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
64 class Command(object): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
65 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
66 def __init__(self, cwd): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
67 self.cwd = cwd |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
68 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
69 def execute(self, cmd, *args): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
70 """Runs command on the system with given ``args``. |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
71 """ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
72 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
73 command = cmd + ' ' + ' '.join(args) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
74 log.debug('Executing %s' % command) |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
75 if DEBUG: |
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
76 print command |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
77 p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=self.cwd) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
78 stdout, stderr = p.communicate() |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
79 if DEBUG: |
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
80 print stdout, stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
81 return stdout, stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
82 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
83 |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
84 def test_wrapp(func): |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
85 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
86 def __wrapp(*args, **kwargs): |
1530
04027bdb876c
Refactoring of model get functions
Marcin Kuzminski <marcin@python-works.com>
parents:
1529
diff
changeset
|
87 print '>>>%s' % func.__name__ |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
88 try: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
89 res = func(*args, **kwargs) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
90 except Exception, e: |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
91 print ('###############\n-' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
92 '--%s failed %s--\n' |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
93 '###############\n' % (func.__name__, e)) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
94 sys.exit() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
95 print '++OK++' |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
96 return res |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
97 return __wrapp |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
98 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
99 def get_session(): |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
100 engine = engine_from_config(conf, 'sqlalchemy.db1.') |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
101 init_model(engine) |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
102 sa = meta.Session |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
103 return sa |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
104 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
105 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
106 def create_test_user(force=True): |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
107 print '\tcreating test user' |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
108 sa = get_session() |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
109 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
110 user = sa.query(User).filter(User.username == USER).scalar() |
988
7f4943c90876
fixed test hg operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
930
diff
changeset
|
111 |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
112 if force and user is not None: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
113 print '\tremoving current user' |
1047 | 114 for repo in sa.query(Repository).filter(Repository.user == user).all(): |
115 sa.delete(repo) | |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
116 sa.delete(user) |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
117 sa.commit() |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
118 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
119 if user is None or force: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
120 print '\tcreating new one' |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
121 new_usr = User() |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
122 new_usr.username = USER |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
123 new_usr.password = get_crypt_password(PASS) |
988
7f4943c90876
fixed test hg operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
930
diff
changeset
|
124 new_usr.email = 'mail@mail.com' |
7f4943c90876
fixed test hg operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
930
diff
changeset
|
125 new_usr.name = 'test' |
7f4943c90876
fixed test hg operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
930
diff
changeset
|
126 new_usr.lastname = 'lasttestname' |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
127 new_usr.active = True |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
128 new_usr.admin = True |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
129 sa.add(new_usr) |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
130 sa.commit() |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
131 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
132 print '\tdone' |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
133 |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
134 |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
135 def create_test_repo(force=True): |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
136 from rhodecode.model.repo import RepoModel |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
137 sa = get_session() |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
138 |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
139 user = sa.query(User).filter(User.username == USER).scalar() |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
140 if user is None: |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
141 raise Exception('user not found') |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
142 |
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
143 |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
144 repo = sa.query(Repository).filter(Repository.repo_name == HG_REPO).scalar() |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
145 |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
146 if repo is None: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
147 print '\trepo not found creating' |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
148 |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
149 form_data = {'repo_name':HG_REPO, |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
150 'repo_type':'hg', |
1296
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
151 'private':False, |
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
152 'clone_uri':'' } |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
153 rm = RepoModel(sa) |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
154 rm.base_path = '/home/hg' |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
155 rm.create(form_data, user) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
156 |
1047 | 157 |
158 def set_anonymous_access(enable=True): | |
159 sa = get_session() | |
160 user = sa.query(User).filter(User.username == 'default').one() | |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
161 sa.expire(user) |
1047 | 162 user.active = enable |
163 sa.add(user) | |
164 sa.commit() | |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
165 sa.remove() |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
166 import time;time.sleep(3) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
167 print '\tanonymous access is now:', enable |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
168 |
1047 | 169 |
170 def get_anonymous_access(): | |
171 sa = get_session() | |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
172 obj1 = sa.query(User).filter(User.username == 'default').one() |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
173 sa.expire(obj1) |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
174 return obj1.active |
1047 | 175 |
176 | |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
177 #============================================================================== |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
178 # TESTS |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
179 #============================================================================== |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
180 @test_wrapp |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
181 def test_clone_with_credentials(no_errors=False): |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
182 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
183 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
184 try: |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
185 shutil.rmtree(path, ignore_errors=True) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
186 os.makedirs(path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
187 #print 'made dirs %s' % jn(path) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
188 except OSError: |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
189 raise |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
190 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
191 print '\tchecking if anonymous access is enabled' |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
192 anonymous_access = get_anonymous_access() |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
193 if anonymous_access: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
194 print '\tenabled, disabling it ' |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
195 set_anonymous_access(enable=False) |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
196 time.sleep(1) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
197 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
198 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \ |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
199 {'user':USER, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
200 'pass':PASS, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
201 'host':HOST, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
202 'cloned_repo':HG_REPO, |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
203 'dest':path} |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
204 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
205 stdout, stderr = Command(cwd).execute('hg clone', clone_url) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
206 |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
207 if no_errors is False: |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
208 assert """adding file changes""" in stdout, 'no messages about cloning' |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
209 assert """abort""" not in stderr , 'got error from clone' |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
210 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
211 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
212 @test_wrapp |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
213 def test_clone_anonymous(): |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
214 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
215 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
216 try: |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
217 shutil.rmtree(path, ignore_errors=True) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
218 os.makedirs(path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
219 #print 'made dirs %s' % jn(path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
220 except OSError: |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
221 raise |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
222 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
223 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
224 print '\tchecking if anonymous access is enabled' |
1047 | 225 anonymous_access = get_anonymous_access() |
226 if not anonymous_access: | |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
227 print '\tnot enabled, enabling it ' |
1047 | 228 set_anonymous_access(enable=True) |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
229 time.sleep(1) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
230 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
231 clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
232 {'user':USER, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
233 'pass':PASS, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
234 'host':HOST, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
235 'cloned_repo':HG_REPO, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
236 'dest':path} |
755
99ece4c484e1
Added basic test push/pull script
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
237 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
238 stdout, stderr = Command(cwd).execute('hg clone', clone_url) |
1047 | 239 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
240 assert """adding file changes""" in stdout, 'no messages about cloning' |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
241 assert """abort""" not in stderr , 'got error from clone' |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
242 |
1047 | 243 #disable if it was enabled |
244 if not anonymous_access: | |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
245 print '\tdisabling anonymous access' |
1047 | 246 set_anonymous_access(enable=False) |
247 | |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
248 @test_wrapp |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
249 def test_clone_wrong_credentials(): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
250 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
251 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
252 try: |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
253 shutil.rmtree(path, ignore_errors=True) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
254 os.makedirs(path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
255 #print 'made dirs %s' % jn(path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
256 except OSError: |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
257 raise |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
258 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
259 print '\tchecking if anonymous access is enabled' |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
260 anonymous_access = get_anonymous_access() |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
261 if anonymous_access: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
262 print '\tenabled, disabling it ' |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
263 set_anonymous_access(enable=False) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
264 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
265 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
266 {'user':USER + 'error', |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
267 'pass':PASS, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
268 'host':HOST, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
269 'cloned_repo':HG_REPO, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
270 'dest':path} |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
271 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
272 stdout, stderr = Command(cwd).execute('hg clone', clone_url) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
273 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
274 if not """abort: authorization failed""" in stderr: |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
275 raise Exception('Failure') |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
276 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
277 @test_wrapp |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
278 def test_pull(): |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
279 pass |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
280 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
281 @test_wrapp |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
282 def test_push_modify_file(f_name='setup.py'): |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
283 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
284 modified_file = jn(TESTS_TMP_PATH, HG_REPO, f_name) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
285 for i in xrange(5): |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
286 cmd = """echo 'added_line%s' >> %s""" % (i, modified_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
287 Command(cwd).execute(cmd) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
288 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
289 cmd = """hg ci -m 'changed file %s' %s """ % (i, modified_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
290 Command(cwd).execute(cmd) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
291 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
292 Command(cwd).execute('hg push %s' % jn(TESTS_TMP_PATH, HG_REPO)) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
293 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
294 @test_wrapp |
1296
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
295 def test_push_new_file(commits=15, with_clone=True): |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
296 |
1296
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
297 if with_clone: |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
298 test_clone_with_credentials(no_errors=True) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
299 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
300 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
1087
51076a2a2b64
fixed unicode problems with file paths.
Marcin Kuzminski <marcin@python-works.com>
parents:
1047
diff
changeset
|
301 added_file = jn(path, '%ssetupążźć.py' % _RandomNameSequence().next()) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
302 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
303 Command(cwd).execute('touch %s' % added_file) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
304 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
305 Command(cwd).execute('hg add %s' % added_file) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
306 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
307 for i in xrange(commits): |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
308 cmd = """echo 'added_line%s' >> %s""" % (i, added_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
309 Command(cwd).execute(cmd) |
809
7b18e7ca66da
extended hg push test script
Marcin Kuzminski <marcin@python-works.com>
parents:
790
diff
changeset
|
310 |
1296
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
311 cmd = """hg ci -m 'commited new %s' -u '%s' %s """ % (i, |
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
312 'Marcin Kuźminski <marcin@python-blog.com>', |
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
313 added_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
314 Command(cwd).execute(cmd) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
315 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
316 push_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
317 {'user':USER, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
318 'pass':PASS, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
319 'host':HOST, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
320 'cloned_repo':HG_REPO, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
321 'dest':jn(TESTS_TMP_PATH, HG_REPO)} |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
322 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
323 Command(cwd).execute('hg push --verbose --debug %s' % push_url) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
324 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
325 @test_wrapp |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
326 def test_push_wrong_credentials(): |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
327 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
328 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \ |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
329 {'user':USER + 'xxx', |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
330 'pass':PASS, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
331 'host':HOST, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
332 'cloned_repo':HG_REPO, |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
333 'dest':jn(TESTS_TMP_PATH, HG_REPO)} |
809
7b18e7ca66da
extended hg push test script
Marcin Kuzminski <marcin@python-works.com>
parents:
790
diff
changeset
|
334 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
335 modified_file = jn(TESTS_TMP_PATH, HG_REPO, 'setup.py') |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
336 for i in xrange(5): |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
337 cmd = """echo 'added_line%s' >> %s""" % (i, modified_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
338 Command(cwd).execute(cmd) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
339 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
340 cmd = """hg ci -m 'commited %s' %s """ % (i, modified_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
341 Command(cwd).execute(cmd) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
342 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
343 Command(cwd).execute('hg push %s' % clone_url) |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
344 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
345 @test_wrapp |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
346 def test_push_wrong_path(): |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
347 cwd = path = jn(TESTS_TMP_PATH, HG_REPO) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
348 added_file = jn(path, 'somefile.py') |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
349 |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
350 try: |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
351 shutil.rmtree(path, ignore_errors=True) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
352 os.makedirs(path) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
353 print '\tmade dirs %s' % jn(path) |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
354 except OSError: |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
355 raise |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
356 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
357 Command(cwd).execute("""echo '' > %s""" % added_file) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
358 Command(cwd).execute("""hg init %s""" % path) |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
359 Command(cwd).execute("""hg add %s""" % added_file) |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
360 |
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
361 for i in xrange(2): |
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
362 cmd = """echo 'added_line%s' >> %s""" % (i, added_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
363 Command(cwd).execute(cmd) |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
364 |
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
365 cmd = """hg ci -m 'commited new %s' %s """ % (i, added_file) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
366 Command(cwd).execute(cmd) |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
367 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
368 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
369 {'user':USER, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
370 'pass':PASS, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
371 'host':HOST, |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
372 'cloned_repo':HG_REPO + '_error', |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
373 'dest':jn(TESTS_TMP_PATH, HG_REPO)} |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
374 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
375 stdout, stderr = Command(cwd).execute('hg push %s' % clone_url) |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
376 if not """abort: HTTP Error 403: Forbidden""" in stderr: |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
377 raise Exception('Failure') |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
378 |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
379 @test_wrapp |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
380 def get_logs(): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
381 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
382 return len(sa.query(UserLog).all()) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
383 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
384 @test_wrapp |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
385 def test_logs(initial): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
386 sa = get_session() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
387 logs = sa.query(UserLog).all() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
388 operations = 7 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
389 if initial + operations != len(logs): |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
390 raise Exception("missing number of logs %s vs %s" % (initial, len(logs))) |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
391 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
392 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
393 if __name__ == '__main__': |
1008
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
394 create_test_user(force=False) |
a9421a8a874f
updated testing script for hg operations
Marcin Kuzminski <marcin@python-works.com>
parents:
988
diff
changeset
|
395 create_test_repo() |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
396 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
397 initial_logs = get_logs() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
398 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
399 # test_push_modify_file() |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
400 test_clone_with_credentials() |
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
401 test_clone_wrong_credentials() |
910
811fa5d45de8
Rewrite simehg for enabling cloning with raw url for anonymous access + some optimizations for making less queries when authenticating users.
Marcin Kuzminski <marcin@python-works.com>
parents:
909
diff
changeset
|
402 |
988
7f4943c90876
fixed test hg operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
930
diff
changeset
|
403 |
1296
1bd6ed0f38b1
small fixes to test_hg_operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
1277
diff
changeset
|
404 test_push_new_file(commits=2, with_clone=True) |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
405 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
406 test_clone_anonymous() |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
407 test_push_wrong_path() |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
408 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
409 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
410 test_push_wrong_credentials() |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
411 |
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
412 test_logs(initial_logs) |