annotate rhodecode/tests/test_hg_operations.py @ 909:1f0e37c0854d beta

fixed hg operations test script
author Marcin Kuzminski <marcin@python-works.com>
date Mon, 03 Jan 2011 00:30:05 +0100
parents a7efcee0f399
children 811fa5d45de8
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 """
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
3 rhodecode.tests.test_hg_operations
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
5
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
6 Test suite for making push/pull operations
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
7
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
8 :created_on: Dec 30, 2010
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
9 :copyright: (c) 2010 by marcink.
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
10 :license: LICENSE_NAME, see LICENSE_FILE for more details.
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
11 """
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
12
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
13 import os
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
14 import shutil
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
15 import logging
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
16
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
17 from subprocess import Popen, PIPE
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
18
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
19 from os.path import join as jn
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
20
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
21 from rhodecode.tests import TESTS_TMP_PATH, NEW_HG_REPO, HG_REPO
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
22
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
23 USER = 'test_admin'
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
24 PASS = 'test12'
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
25 HOST = '127.0.0.1:5000'
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
26
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
27 log = logging.getLogger(__name__)
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
28
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
29
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
30 class Command(object):
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
31
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
32 def __init__(self, cwd):
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
33 self.cwd = cwd
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
34
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
35 def execute(self, cmd, *args):
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
36 """Runs command on the system with given ``args``.
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
37 """
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
38
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
39 command = cmd + ' ' + ' '.join(args)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
40 log.debug('Executing %s' % command)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
41 print command
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
42 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
43 stdout, stderr = p.communicate()
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
44 print stdout, stderr
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
45 return stdout, stderr
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
46
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
47
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
48 #===============================================================================
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
49 # TESTS
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
50 #===============================================================================
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
51 def test_clone():
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
52 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
53
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
54 try:
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
55 shutil.rmtree(path, ignore_errors=True)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
56 os.makedirs(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
57 #print 'made dirs %s' % jn(path)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
58 except OSError:
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
59 raise
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
60
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
61
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
62 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
63 {'user':USER,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
64 'pass':PASS,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
65 'host':HOST,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
66 'cloned_repo':HG_REPO,
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
67 'dest':path}
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
68
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
69 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
70
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
71 assert """adding file changes""" in stdout, 'no messages about cloning'
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
72 assert """abort""" not in stderr , 'got error from clone'
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
73
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
74
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
75
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
76 def test_clone_anonymous_ok():
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
77 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
78
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
79 try:
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
80 shutil.rmtree(path, ignore_errors=True)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
81 os.makedirs(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
82 #print 'made dirs %s' % jn(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
83 except OSError:
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
84 raise
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
85
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
86
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
87 clone_url = 'http://%(host)s/%(cloned_repo)s %(dest)s' % \
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
88 {'user':USER,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
89 'pass':PASS,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
90 'host':HOST,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
91 'cloned_repo':HG_REPO,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
92 'dest':path}
755
99ece4c484e1 Added basic test push/pull script
Marcin Kuzminski <marcin@python-works.com>
parents:
diff changeset
93
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
94 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
95 print stdout, stderr
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
96 assert """adding file changes""" in stdout, 'no messages about cloning'
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
97 assert """abort""" not in stderr , 'got error from clone'
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
98
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
99 def test_clone_wrong_credentials():
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
100 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
101
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
102 try:
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
103 shutil.rmtree(path, ignore_errors=True)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
104 os.makedirs(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
105 #print 'made dirs %s' % jn(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
106 except OSError:
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
107 raise
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
108
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
109
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
110 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s %(dest)s' % \
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
111 {'user':USER + 'error',
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
112 'pass':PASS,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
113 'host':HOST,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
114 'cloned_repo':HG_REPO,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
115 'dest':path}
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
116
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
117 stdout, stderr = Command(cwd).execute('hg clone', clone_url)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
118
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
119 assert """abort: authorization failed""" in stderr , 'no error from wrong credentials'
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
120
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
121
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
122 def test_pull():
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
123 pass
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
124
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
125 def test_push():
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
126
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
127 modified_file = jn(TESTS_TMP_PATH, HG_REPO, 'setup.py')
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
128 for i in xrange(5):
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
129 cmd = """echo 'added_line%s' >> %s""" % (i, modified_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
130 Command(cwd).execute(cmd)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
131
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
132 cmd = """hg ci -m 'changed file %s' %s """ % (i, modified_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
133 Command(cwd).execute(cmd)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
134
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
135 Command(cwd).execute('hg push %s' % jn(TESTS_TMP_PATH, HG_REPO))
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
136
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
137 def test_push_new_file():
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
138
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
139 test_clone()
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
140
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
141 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
142 added_file = jn(path, 'setup.py')
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
143
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
144 Command(cwd).execute('touch %s' % added_file)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
145
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
146 Command(cwd).execute('hg add %s' % added_file)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
147
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
148 for i in xrange(15):
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
149 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
150 Command(cwd).execute(cmd)
809
7b18e7ca66da extended hg push test script
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
151
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
152 cmd = """hg ci -m 'commited new %s' %s """ % (i, added_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
153 Command(cwd).execute(cmd)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
154
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
155 push_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
156 {'user':USER,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
157 'pass':PASS,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
158 'host':HOST,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
159 'cloned_repo':HG_REPO,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
160 'dest':jn(TESTS_TMP_PATH, HG_REPO)}
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
161
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
162 Command(cwd).execute('hg push %s' % push_url)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
163
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
164 def test_push_wrong_credentials():
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
165
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
166 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
167 {'user':USER + 'xxx',
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
168 'pass':PASS,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
169 'host':HOST,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
170 'cloned_repo':HG_REPO,
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
171 'dest':jn(TESTS_TMP_PATH, HG_REPO)}
809
7b18e7ca66da extended hg push test script
Marcin Kuzminski <marcin@python-works.com>
parents: 790
diff changeset
172
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
173 modified_file = jn(TESTS_TMP_PATH, HG_REPO, 'setup.py')
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
174 for i in xrange(5):
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
175 cmd = """echo 'added_line%s' >> %s""" % (i, modified_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
176 Command(cwd).execute(cmd)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
177
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
178 cmd = """hg ci -m 'commited %s' %s """ % (i, modified_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
179 Command(cwd).execute(cmd)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
180
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
181 Command(cwd).execute('hg push %s' % clone_url)
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
182
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
183 def test_push_wrong_path():
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
184 cwd = path = jn(TESTS_TMP_PATH, HG_REPO)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
185 added_file = jn(path, 'somefile.py')
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
186
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
187 try:
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
188 shutil.rmtree(path, ignore_errors=True)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
189 os.makedirs(path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
190 print 'made dirs %s' % jn(path)
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
191 except OSError:
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
192 raise
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
193
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
194 Command(cwd).execute("""echo '' > %s""" % added_file)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
195 Command(cwd).execute("""hg init %s""" % path)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
196 Command(cwd).execute("""hg add %s""" % added_file)
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
197
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
198 for i in xrange(2):
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
199 cmd = """echo 'added_line%s' >> %s""" % (i, added_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
200 Command(cwd).execute(cmd)
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
201
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
202 cmd = """hg ci -m 'commited new %s' %s """ % (i, added_file)
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
203 Command(cwd).execute(cmd)
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
204
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
205 clone_url = 'http://%(user)s:%(pass)s@%(host)s/%(cloned_repo)s' % \
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
206 {'user':USER,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
207 'pass':PASS,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
208 'host':HOST,
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
209 'cloned_repo':HG_REPO + '_error',
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
210 'dest':jn(TESTS_TMP_PATH, HG_REPO)}
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
211
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
212 stdout, stderr = Command(cwd).execute('hg push %s' % clone_url)
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
213 assert """abort: HTTP Error 403: Forbidden""" in stderr
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
214
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
215
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
216 if __name__ == '__main__':
897
a7efcee0f399 updated mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 896
diff changeset
217 test_clone()
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
218 test_clone_wrong_credentials()
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
219 ##test_clone_anonymous_ok()
896
af65ca7e5c2b changed mercurial test operations script
Marcin Kuzminski <marcin@python-works.com>
parents: 809
diff changeset
220
909
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
221 #test_push_new_file()
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
222 #test_push_wrong_path()
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
223 #test_push_wrong_credentials()
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
224
1f0e37c0854d fixed hg operations test script
Marcin Kuzminski <marcin@python-works.com>
parents: 897
diff changeset
225