annotate rhodecode/tests/other/test_vcs_operations.py @ 3937:2f5e6f1c5bdc beta

Bumped mercurial version
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 03 Jun 2013 14:18:07 +0200
parents 5067d6e826a5
children ffd45b185016
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 *
3617
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
41 from rhodecode.model.db import User, Repository, UserLog, UserIpMap,\
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
42 CacheInvalidation
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
43 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
44 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
45 from rhodecode.model.user import UserModel
1596
089ef495e9dd fixed test_hg_push operations
Marcin Kuzminski <marcin@python-works.com>
parents: 1532
diff changeset
46
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
47 DEBUG = True
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
48 HOST = '127.0.0.1:5000' # test host
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
49
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
50
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
51 class Command(object):
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
52
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
53 def __init__(self, cwd):
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
54 self.cwd = cwd
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
55
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
56 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
57 """
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
58 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
59 """
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
60
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
61 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
62 if DEBUG:
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
63 print '*** CMD %s ***' % command
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
64 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
65 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
66 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
67 print stdout, stderr
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
68 return stdout, stderr
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
69
1498
fcc676c6bf3b updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents: 1296
diff changeset
70
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
71 def _get_tmp_dir():
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
72 return tempfile.mkdtemp(prefix='rc_integration_test')
1498
fcc676c6bf3b updated test_hg_operation script
Marcin Kuzminski <marcin@python-works.com>
parents: 1296
diff changeset
73
930
f9016563f987 Added sql session into test hg script
Marcin Kuzminski <marcin@python-works.com>
parents: 910
diff changeset
74
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
75 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
76 if dest is None:
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
77 #make temp clone
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
78 dest = _get_tmp_dir()
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
79 params = {
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
80 'user': TEST_USER_ADMIN_LOGIN,
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
81 'passwd': TEST_USER_ADMIN_PASS,
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
82 'host': HOST,
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
83 'cloned_repo': repo,
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
84 'dest': dest
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
85 }
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
86 params.update(**kwargs)
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
87 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
88 _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
89 else:
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
90 _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
91 return _url
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
92
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
93
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
94 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
95 """
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
96 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
97 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
98
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
99 :param vcs:
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
100 :param DEST:
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
101 """
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
102 # 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
103 cwd = path = jn(DEST)
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 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
106 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
107 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
108
3617
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
109 for i in xrange(kwargs.get('files_no', 3)):
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
110 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
111 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
112 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
113 if vcs == 'hg':
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
114 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
115 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
116 )
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
117 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
118 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
119 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
120 )
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
121 Command(cwd).execute(cmd)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
122 # PUSH it back
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
123 if vcs == 'hg':
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
124 _REPO = HG_REPO
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
125 elif vcs == 'git':
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
126 _REPO = GIT_REPO
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
127
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
128 kwargs['dest'] = ''
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
129 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
130 if 'clone_url' in kwargs:
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
131 clone_url = kwargs['clone_url']
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
132 if vcs == 'hg':
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
133 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
134 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
135 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
136
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
137 return stdout, stderr
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
138
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
139
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
140 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
141 user = User.get_by_username(User.DEFAULT_USER)
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
142 user.active = enable
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
143 Session().add(user)
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
144 Session().commit()
1529
0b268dd369ec Fixed test_hg_operations test and added concurency test
Marcin Kuzminski <marcin@python-works.com>
parents: 1498
diff changeset
145 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
146 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
147 raise Exception('Cannot set anonymous access')
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
148
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
149
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
150 #==============================================================================
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
151 # TESTS
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
152 #==============================================================================
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
153
3829
5067d6e826a5 created basic TestClass for tests that does
Marcin Kuzminski <marcin@python-works.com>
parents: 3824
diff changeset
154 class TestVCSOperations(BaseTestCase):
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
155
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
156 @classmethod
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
157 def setup_class(cls):
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
158 #DISABLE ANONYMOUS ACCESS
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
159 set_anonymous_access(False)
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
160
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
161 def setUp(self):
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
162 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
163 Repository.unlock(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
164 r.enable_locking = False
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
165 Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
166 Session().commit()
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
167
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
168 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
169 Repository.unlock(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
170 r.enable_locking = False
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
171 Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
172 Session().commit()
2728
6341084b7a2f rewrote test_scm_operations, now run by nosetests
Marcin Kuzminski <marcin@python-works.com>
parents: 2527
diff changeset
173
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
174 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
175 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
176 stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
177
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
178 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
179 assert 'adding changesets' in stdout
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
180 assert 'adding manifests' in stdout
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
181 assert 'adding file changes' in stdout
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
182
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
183 assert stderr == ''
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
184
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
185 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
186 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
187 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
188
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
189 assert 'Cloning into' in stdout
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
190 assert stderr == ''
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
191
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
192 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
193 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
194 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
195 assert 'abort: authorization failed' in stderr
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
196
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
197 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
198 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
199 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
200 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
201
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
202 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
203 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
204 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
205 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
206
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
207 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
208 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
209 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
210 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
211
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
212 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
213 clone_url = _construct_url('trololo')
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
214 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
215 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
216
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
217 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
218 clone_url = _construct_url('trololo')
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
219 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
220 assert 'not found:' in stderr
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
221
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
222 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
223 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
224 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
225 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
226
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
227 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
228
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
229 assert 'pushing to' in stdout
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
230 assert 'Repository size' in stdout
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
231 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
232
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
233 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
234 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
235 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
236 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
237
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
238 # 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
239 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
240
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
241 #WTF git stderr ?!
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
242 assert 'master -> master' in stderr
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
243
3617
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
244 def test_push_invalidates_cache_hg(self):
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
245 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
246 ==HG_REPO).one()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
247 key.cache_active = True
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
248 Session().add(key)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
249 Session().commit()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
250
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
251 DEST = _get_tmp_dir()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
252 clone_url = _construct_url(HG_REPO, dest=DEST)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
253 stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
254
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
255 stdout, stderr = _add_files_and_push('hg', DEST, files_no=1)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
256 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
257 ==HG_REPO).one()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
258 self.assertEqual(key.cache_active, False)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
259
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
260 def test_push_invalidates_cache_git(self):
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
261 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
262 ==GIT_REPO).one()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
263 key.cache_active = True
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
264 Session().add(key)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
265 Session().commit()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
266
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
267 DEST = _get_tmp_dir()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
268 clone_url = _construct_url(GIT_REPO, dest=DEST)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
269 stdout, stderr = Command('/tmp').execute('git clone', clone_url)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
270
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
271 # commit some stuff into this repo
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
272 stdout, stderr = _add_files_and_push('git', DEST, files_no=1)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
273
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
274 key = CacheInvalidation.query().filter(CacheInvalidation.cache_key
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
275 ==GIT_REPO).one()
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
276 self.assertEqual(key.cache_active, False)
b5c3680e7c76 added tests if push set cache invalidation state
Marcin Kuzminski <marcin@python-works.com>
parents: 3480
diff changeset
277
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
278 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
279 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
280 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
281 stdout, stderr = Command('/tmp').execute('hg clone', clone_url)
1047
15b60f83420c tests update
Marcin Kuzminski <marcin@python-works.com>
parents: 1008
diff changeset
282
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
283 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
284 passwd='name')
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
285
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
286 assert 'abort: authorization failed' in stderr
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
287
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
288 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
289 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
290 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
291 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
292
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
293 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
294 passwd='name')
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
295
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
296 assert 'fatal: Authentication failed' in stderr
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
297
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
298 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
299 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
300 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
301 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
302
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
303 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
304 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
305
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
306 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
307
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
308 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
309 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
310 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
311 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
312
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
313 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
314 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
315
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
316 assert 'not found:' in stderr
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
317
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
318 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
319 # enable locking
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
320 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
321 r.enable_locking = True
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
322 Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
323 Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
324 # clone
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
325 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
326 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
327
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
328 #check if lock was made
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
329 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
330 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
331
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
332 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
333 # enable locking
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
334 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
335 r.enable_locking = True
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
336 Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
337 Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
338 # clone
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
339 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
340 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
341
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
342 #check if lock was made
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
343 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
344 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
345
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
346 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
347 #lock repo
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
348 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
349 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
350 #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
351 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
352 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
353 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
354 % (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
355 assert msg in stderr
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
356
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
357 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
358 #lock repo
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
359 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
360 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
361 #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
362 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
363 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
364 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
365 assert msg in stderr
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
366
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
367 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
368 #clone some temp
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
369 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
370 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
371 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
372
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
373 #lock repo
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
374 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
375 # let this user actually push !
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
376 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
377 perm='repository.write')
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
378 Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
379 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
380
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
381 #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
382 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
383 user=TEST_USER_REGULAR_LOGIN,
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
384 passwd=TEST_USER_REGULAR_PASS)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
385 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
386 % (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
387 assert msg in stderr
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
388
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
389 #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
390 # 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
391 # #clone some temp
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
392 # DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
393 # 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
394 # 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
395 #
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
396 # #lock repo
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
397 # 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
398 # # let this user actually push !
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
399 # 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
400 # perm='repository.write')
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
401 # Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
402 # 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
403 #
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
404 # #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
405 # 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
406 # user=TEST_USER_REGULAR_LOGIN,
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
407 # passwd=TEST_USER_REGULAR_PASS)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
408 # 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
409 # % (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
410 # #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
411 # # 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
412 # msg = "405 Method Not Allowed"
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
413 # assert msg in stderr
2527
95624ce4465f orginized test module
Marcin Kuzminski <marcin@python-works.com>
parents: 1824
diff changeset
414
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
415 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
416 # enable locking
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
417 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
418 r.enable_locking = True
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
419 Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
420 Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
421 #clone some temp
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
422 DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
423 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
424 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
425
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
426 #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
427 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
428 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
429
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
430 #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
431 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
432 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
433 #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
434 Session.remove()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
435 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
436 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
437
2752
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
438 #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
439 # 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
440 # # enable locking
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
441 # 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
442 # r.enable_locking = True
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
443 # Session().add(r)
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
444 # Session().commit()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
445 # #clone some temp
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
446 # DEST = _get_tmp_dir()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
447 # 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
448 # 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
449 #
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
450 # #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
451 # 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
452 # 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
453 #
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
454 # #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
455 # 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
456 # #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
457 # #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
458 # Session.remove()
6d904a0cd48d added new suite of tests for VCS operations
Marcin Kuzminski <marcin@python-works.com>
parents: 2728
diff changeset
459 # 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
460 # assert r.locked == [None, None]
3131
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
461
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
462 def test_ip_restriction_hg(self):
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
463 user_model = UserModel()
3180
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
464 try:
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
465 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
466 Session().commit()
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
467 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
468 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
469 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
470 finally:
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
471 #release IP restrictions
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
472 for ip in UserIpMap.getAll():
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
473 UserIpMap.delete(ip.ip_id)
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
474 Session().commit()
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
475
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
476 time.sleep(2)
3131
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
477 clone_url = _construct_url(HG_REPO)
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
478 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
479
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
480 assert 'requesting all changes' in stdout
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
481 assert 'adding changesets' in stdout
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
482 assert 'adding manifests' in stdout
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
483 assert 'adding file changes' in stdout
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
484
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
485 assert stderr == ''
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
486
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
487 def test_ip_restriction_git(self):
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
488 user_model = UserModel()
3180
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
489 try:
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
490 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
491 Session().commit()
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
492 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
493 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
494 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
495 assert msg in stderr
3180
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
496 finally:
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
497 #release IP restrictions
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
498 for ip in UserIpMap.getAll():
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
499 UserIpMap.delete(ip.ip_id)
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
500 Session().commit()
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
501
3472d8f37e6d fixed ip restriction tests when runned multiple times.
Marcin Kuzminski <marcin@python-works.com>
parents: 3131
diff changeset
502 time.sleep(2)
3131
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
503 clone_url = _construct_url(GIT_REPO)
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
504 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
505
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
506 assert 'Cloning into' in stdout
21307b019ad4 added integration tests for IP restriction option
Marcin Kuzminski <marcin@python-works.com>
parents: 2957
diff changeset
507 assert stderr == ''