annotate rhodecode/tests/scripts/test_vcs_operations.py @ 3480:bc7fb3e8d77e beta

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