Mercurial > kallithea
annotate rhodecode/tests/scripts/test_vcs_operations.py @ 3131:21307b019ad4 beta
added integration tests for IP restriction option
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Thu, 03 Jan 2013 00:44:06 +0100 |
parents | 15dc5b2ff672 |
children | 3472d8f37e6d |
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 """ |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
3 rhodecode.tests.test_scm_operations |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
5 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
6 Test suite for making push/pull operations. |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
7 Run using:: |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
8 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
9 RC_WHOOSH_TEST_DISABLE=1 RC_NO_TMP_PATH=1 nosetests rhodecode/tests/scripts/test_vcs_operations.py |
1203
6832ef664673
source code cleanup: remove trailing white space, normalize file endings
Marcin Kuzminski <marcin@python-works.com>
parents:
1087
diff
changeset
|
10 |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
11 :created_on: Dec 30, 2010 |
1824
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1715
diff
changeset
|
12 :author: marcink |
89efedac4e6c
2012 copyrights
Marcin Kuzminski <marcin@python-works.com>
parents:
1715
diff
changeset
|
13 :copyright: (C) 2010-2012 Marcin Kuzminski <marcin@python-works.com> |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
14 :license: GPLv3, see COPYING for more details. |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
15 """ |
1532
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
16 # 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
|
17 # 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
|
18 # the Free Software Foundation, either version 3 of the License, or |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
19 # (at your option) any later version. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
20 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
21 # 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
|
22 # but WITHOUT ANY WARRANTY; without even the implied warranty of |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
23 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
24 # GNU General Public License for more details. |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
25 # |
2afe9320d5e6
updated docstrings
Marcin Kuzminski <marcin@python-works.com>
parents:
1530
diff
changeset
|
26 # 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
|
27 # 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
|
28 |
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
29 import os |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
30 import tempfile |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
31 import unittest |
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 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
38 from rhodecode.tests import * |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
39 from rhodecode.model.db import User, Repository, UserLog |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
40 from rhodecode.model.meta import Session |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
41 from rhodecode.model.repo import RepoModel |
3131
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
42 from rhodecode.model.user import UserModel |
1596
089ef495e9dd
fixed test_hg_push operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1532
diff
changeset
|
43 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
44 DEBUG = True |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
45 HOST = '127.0.0.1:5000' # test host |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
46 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
47 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
48 class Command(object): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
49 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
50 def __init__(self, cwd): |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
51 self.cwd = cwd |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
52 |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
53 def execute(self, cmd, *args): |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
54 """ |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
55 Runs command on the system with given ``args``. |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
56 """ |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
57 |
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
58 command = cmd + ' ' + ' '.join(args) |
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
|
59 if DEBUG: |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
60 print '*** CMD %s ***' % command |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
61 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
|
62 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
|
63 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
|
64 print stdout, stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
65 return stdout, stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
66 |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
67 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
68 def _get_tmp_dir(): |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
69 return tempfile.mkdtemp(prefix='rc_integration_test') |
1498
fcc676c6bf3b
updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents:
1296
diff
changeset
|
70 |
930
f9016563f987
Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents:
910
diff
changeset
|
71 |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
72 def _construct_url(repo, dest=None, **kwargs): |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
73 if dest is None: |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
74 #make temp clone |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
75 dest = _get_tmp_dir() |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
76 params = { |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
77 'user': TEST_USER_ADMIN_LOGIN, |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
78 'passwd': TEST_USER_ADMIN_PASS, |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
79 'host': HOST, |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
80 'cloned_repo': repo, |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
81 'dest': dest |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
82 } |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
83 params.update(**kwargs) |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
84 if params['user'] and params['passwd']: |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
85 _url = 'http://%(user)s:%(passwd)s@%(host)s/%(cloned_repo)s %(dest)s' % params |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
86 else: |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
87 _url = 'http://(host)s/%(cloned_repo)s %(dest)s' % params |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
88 return _url |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
89 |
1047 | 90 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
91 def _add_files_and_push(vcs, DEST, **kwargs): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
92 """ |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
93 Generate some files, add it to DEST repo and push back |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
94 vcs is git or hg and defines what VCS we want to make those files for |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
95 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
96 :param vcs: |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
97 :param DEST: |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
98 """ |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
99 # commit some stuff into this repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
100 cwd = path = jn(DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
101 #added_file = jn(path, '%ssetupążźć.py' % _RandomNameSequence().next()) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
102 added_file = jn(path, '%ssetup.py' % _RandomNameSequence().next()) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
103 Command(cwd).execute('touch %s' % added_file) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
104 Command(cwd).execute('%s add %s' % (vcs, added_file)) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
105 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
106 for i in xrange(3): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
107 cmd = """echo 'added_line%s' >> %s""" % (i, added_file) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
108 Command(cwd).execute(cmd) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
109 if vcs == 'hg': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
110 cmd = """hg commit -m 'commited new %s' -u '%s' %s """ % ( |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
111 i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
112 ) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
113 elif vcs == 'git': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
114 cmd = """git ci -m 'commited new %s' --author '%s' %s """ % ( |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
115 i, 'Marcin Kuźminski <marcin@python-blog.com>', added_file |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
116 ) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
117 Command(cwd).execute(cmd) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
118 # PUSH it back |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
119 if vcs == 'hg': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
120 _REPO = HG_REPO |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
121 elif vcs == 'git': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
122 _REPO = GIT_REPO |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
123 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
124 kwargs['dest'] = '' |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
125 clone_url = _construct_url(_REPO, **kwargs) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
126 if 'clone_url' in kwargs: |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
127 clone_url = kwargs['clone_url'] |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
128 if vcs == 'hg': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
129 stdout, stderr = Command(cwd).execute('hg push --verbose', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
130 elif vcs == 'git': |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
131 stdout, stderr = Command(cwd).execute('git push', clone_url + " master") |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
132 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
133 return stdout, stderr |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
134 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
135 |
1047 | 136 def set_anonymous_access(enable=True): |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
137 user = User.get_by_username(User.DEFAULT_USER) |
1047 | 138 user.active = enable |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
139 Session().add(user) |
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
140 Session().commit() |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
141 print '\tanonymous access is now:', enable |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
142 if enable != User.get_by_username(User.DEFAULT_USER).active: |
1596
089ef495e9dd
fixed test_hg_push operations
Marcin Kuzminski <marcin@python-works.com>
parents:
1532
diff
changeset
|
143 raise Exception('Cannot set anonymous access') |
1047 | 144 |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
145 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
146 #============================================================================== |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
147 # TESTS |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
148 #============================================================================== |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
149 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
150 class TestVCSOperations(unittest.TestCase): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
151 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
152 @classmethod |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
153 def setup_class(cls): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
154 #DISABLE ANONYMOUS ACCESS |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
155 set_anonymous_access(False) |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
156 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
157 def setUp(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
158 r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
159 Repository.unlock(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
160 r.enable_locking = False |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
161 Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
162 Session().commit() |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
163 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
164 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
165 Repository.unlock(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
166 r.enable_locking = False |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
167 Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
168 Session().commit() |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
169 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
170 def test_clone_hg_repo_by_admin(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
171 clone_url = _construct_url(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
172 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
1047 | 173 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
174 assert 'requesting all changes' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
175 assert 'adding changesets' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
176 assert 'adding manifests' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
177 assert 'adding file changes' in stdout |
1047 | 178 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
179 assert stderr == '' |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
180 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
181 def test_clone_git_repo_by_admin(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
182 clone_url = _construct_url(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
183 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
184 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
185 assert 'Cloning into' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
186 assert stderr == '' |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
187 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
188 def test_clone_wrong_credentials_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
189 clone_url = _construct_url(HG_REPO, passwd='bad!') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
190 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
191 assert 'abort: authorization failed' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
192 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
193 def test_clone_wrong_credentials_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
194 clone_url = _construct_url(GIT_REPO, passwd='bad!') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
195 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
196 assert 'fatal: Authentication failed' in stderr |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
197 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
198 def test_clone_git_dir_as_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
199 clone_url = _construct_url(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
200 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
201 assert 'HTTP Error 404: Not Found' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
202 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
203 def test_clone_hg_repo_as_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
204 clone_url = _construct_url(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
205 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
206 assert 'not found:' in stderr |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
207 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
208 def test_clone_non_existing_path_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
209 clone_url = _construct_url('trololo') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
210 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
211 assert 'HTTP Error 404: Not Found' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
212 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
213 def test_clone_non_existing_path_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
214 clone_url = _construct_url('trololo') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
215 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
216 assert 'not found:' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
217 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
218 def test_push_new_file_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
219 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
220 clone_url = _construct_url(HG_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
221 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
222 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
223 stdout, stderr = _add_files_and_push('hg', DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
224 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
225 assert 'pushing to' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
226 assert 'Repository size' in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
227 assert 'Last revision is now' in stdout |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
228 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
229 def test_push_new_file_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
230 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
231 clone_url = _construct_url(GIT_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
232 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
233 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
234 # commit some stuff into this repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
235 stdout, stderr = _add_files_and_push('git', DEST) |
755
99ece4c484e1
Added basic test push/pull script
Marcin Kuzminski <marcin@python-works.com>
parents:
diff
changeset
|
236 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
237 #WTF git stderr ?! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
238 assert 'master -> master' in stderr |
1047 | 239 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
240 def test_push_wrong_credentials_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
241 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
242 clone_url = _construct_url(HG_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
243 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
1047 | 244 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
245 stdout, stderr = _add_files_and_push('hg', DEST, user='bad', |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
246 passwd='name') |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
247 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
248 assert 'abort: authorization failed' in stderr |
909
1f0e37c0854d
fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents:
897
diff
changeset
|
249 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
250 def test_push_wrong_credentials_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
251 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
252 clone_url = _construct_url(GIT_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
253 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
254 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
255 stdout, stderr = _add_files_and_push('git', DEST, user='bad', |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
256 passwd='name') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
257 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
258 assert 'fatal: Authentication failed' in stderr |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
259 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
260 def test_push_back_to_wrong_url_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
261 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
262 clone_url = _construct_url(HG_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
263 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
264 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
265 stdout, stderr = _add_files_and_push('hg', DEST, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
266 clone_url='http://127.0.0.1:5000/tmp',) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
267 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
268 assert 'HTTP Error 404: Not Found' in stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
269 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
270 def test_push_back_to_wrong_url_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
271 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
272 clone_url = _construct_url(GIT_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
273 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
274 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
275 stdout, stderr = _add_files_and_push('git', DEST, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
276 clone_url='http://127.0.0.1:5000/tmp',) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
277 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
278 assert 'not found:' in stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
279 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
280 def test_clone_and_create_lock_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
281 # enable locking |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
282 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
283 r.enable_locking = True |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
284 Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
285 Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
286 # clone |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
287 clone_url = _construct_url(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
288 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
289 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
290 #check if lock was made |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
291 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
292 assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id |
809
7b18e7ca66da
extended hg push test script
Marcin Kuzminski <marcin@python-works.com>
parents:
790
diff
changeset
|
293 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
294 def test_clone_and_create_lock_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
295 # enable locking |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
296 r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
297 r.enable_locking = True |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
298 Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
299 Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
300 # clone |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
301 clone_url = _construct_url(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
302 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
303 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
304 #check if lock was made |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
305 r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
306 assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
307 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
308 def test_clone_after_repo_was_locked_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
309 #lock repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
310 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
311 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
312 #pull fails since repo is locked |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
313 clone_url = _construct_url(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
314 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
315 msg = ("""abort: HTTP Error 423: Repository `%s` locked by user `%s`""" |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
316 % (HG_REPO, TEST_USER_ADMIN_LOGIN)) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
317 assert msg in stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
318 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
319 def test_clone_after_repo_was_locked_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
320 #lock repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
321 r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
322 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
323 #pull fails since repo is locked |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
324 clone_url = _construct_url(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
325 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
2957
15dc5b2ff672
latest git version fixes issue with handling locking
Marcin Kuzminski <marcin@python-works.com>
parents:
2752
diff
changeset
|
326 msg = ("""423 Repository `%s` locked by user `%s`""" |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
327 % (GIT_REPO, TEST_USER_ADMIN_LOGIN)) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
328 assert msg in stderr |
896
af65ca7e5c2b
changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
809
diff
changeset
|
329 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
330 def test_push_on_locked_repo_by_other_user_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
331 #clone some temp |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
332 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
333 clone_url = _construct_url(HG_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
334 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
335 |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
336 #lock repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
337 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
338 # let this user actually push ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
339 RepoModel().grant_user_permission(repo=r, user=TEST_USER_REGULAR_LOGIN, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
340 perm='repository.write') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
341 Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
342 Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
343 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
344 #push fails repo is locked by other user ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
345 stdout, stderr = _add_files_and_push('hg', DEST, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
346 user=TEST_USER_REGULAR_LOGIN, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
347 passwd=TEST_USER_REGULAR_PASS) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
348 msg = ("""abort: HTTP Error 423: Repository `%s` locked by user `%s`""" |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
349 % (HG_REPO, TEST_USER_ADMIN_LOGIN)) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
350 assert msg in stderr |
897
a7efcee0f399
updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents:
896
diff
changeset
|
351 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
352 #TODO: fix me ! somehow during tests hooks don't get called on GIT |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
353 # def test_push_on_locked_repo_by_other_user_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
354 # #clone some temp |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
355 # DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
356 # clone_url = _construct_url(GIT_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
357 # stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
358 # |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
359 # #lock repo |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
360 # r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
361 # # let this user actually push ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
362 # RepoModel().grant_user_permission(repo=r, user=TEST_USER_REGULAR_LOGIN, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
363 # perm='repository.write') |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
364 # Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
365 # Repository.lock(r, User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
366 # |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
367 # #push fails repo is locked by other user ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
368 # stdout, stderr = _add_files_and_push('git', DEST, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
369 # user=TEST_USER_REGULAR_LOGIN, |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
370 # passwd=TEST_USER_REGULAR_PASS) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
371 # msg = ("""abort: HTTP Error 423: Repository `%s` locked by user `%s`""" |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
372 # % (GIT_REPO, TEST_USER_ADMIN_LOGIN)) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
373 # #TODO: fix this somehow later on GIT, GIT is stupid and even if we throw |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
374 # # back 423 to it, it makes ANOTHER request and we fail there with 405 :/ |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
375 # msg = "405 Method Not Allowed" |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
376 # assert msg in stderr |
2527
95624ce4465f
orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents:
1824
diff
changeset
|
377 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
378 def test_push_unlocks_repository_hg(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
379 # enable locking |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
380 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
381 r.enable_locking = True |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
382 Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
383 Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
384 #clone some temp |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
385 DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
386 clone_url = _construct_url(HG_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
387 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
388 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
389 #check for lock repo after clone |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
390 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
391 assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id |
1529
0b268dd369ec
Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents:
1498
diff
changeset
|
392 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
393 #push is ok and repo is now unlocked |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
394 stdout, stderr = _add_files_and_push('hg', DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
395 assert ('remote: Released lock on repo `%s`' % HG_REPO) in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
396 #we need to cleanup the Session Here ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
397 Session.remove() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
398 r = Repository.get_by_repo_name(HG_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
399 assert r.locked == [None, None] |
2728
6341084b7a2f
rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents:
2527
diff
changeset
|
400 |
2752
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
401 #TODO: fix me ! somehow during tests hooks don't get called on GIT |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
402 # def test_push_unlocks_repository_git(self): |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
403 # # enable locking |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
404 # r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
405 # r.enable_locking = True |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
406 # Session().add(r) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
407 # Session().commit() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
408 # #clone some temp |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
409 # DEST = _get_tmp_dir() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
410 # clone_url = _construct_url(GIT_REPO, dest=DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
411 # stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
412 # |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
413 # #check for lock repo after clone |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
414 # r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
415 # assert r.locked[0] == User.get_by_username(TEST_USER_ADMIN_LOGIN).user_id |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
416 # |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
417 # #push is ok and repo is now unlocked |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
418 # stdout, stderr = _add_files_and_push('git', DEST) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
419 # #assert ('remote: Released lock on repo `%s`' % GIT_REPO) in stdout |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
420 # #we need to cleanup the Session Here ! |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
421 # Session.remove() |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
422 # r = Repository.get_by_repo_name(GIT_REPO) |
6d904a0cd48d
added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents:
2728
diff
changeset
|
423 # assert r.locked == [None, None] |
3131
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
424 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
425 def test_ip_restriction_hg(self): |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
426 user_model = UserModel() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
427 new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
428 Session().commit() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
429 clone_url = _construct_url(HG_REPO) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
430 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
431 assert 'abort: HTTP Error 403: Forbidden' in stderr |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
432 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
433 #release IP restrictions |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
434 clone_url = _construct_url(HG_REPO) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
435 user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
436 Session().commit() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
437 stdout, stderr = Command('/tmp').execute('hg clone', clone_url) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
438 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
439 assert 'requesting all changes' in stdout |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
440 assert 'adding changesets' in stdout |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
441 assert 'adding manifests' in stdout |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
442 assert 'adding file changes' in stdout |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
443 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
444 assert stderr == '' |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
445 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
446 def test_ip_restriction_git(self): |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
447 user_model = UserModel() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
448 new_ip = user_model.add_extra_ip(TEST_USER_ADMIN_LOGIN, '10.10.10.10/32') |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
449 Session().commit() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
450 clone_url = _construct_url(GIT_REPO) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
451 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
452 assert 'error: The requested URL returned error: 403 Forbidden' in stderr |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
453 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
454 #release IP restrictions |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
455 clone_url = _construct_url(GIT_REPO) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
456 user_model.delete_extra_ip(TEST_USER_ADMIN_LOGIN, new_ip.ip_id) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
457 Session().commit() |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
458 stdout, stderr = Command('/tmp').execute('git clone', clone_url) |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
459 |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
460 assert 'Cloning into' in stdout |
21307b019ad4
added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents:
2957
diff
changeset
|
461 assert stderr == '' |