annotate rhodecode/tests/scripts/test_vcs_operations.py @ 3199:9f57b5624ec4 beta

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