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