~ubuntu-branches/ubuntu/utopic/dulwich/utopic

« back to all changes in this revision

Viewing changes to dulwich/tests/compat/test_client.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2014-04-23 01:41:04 UTC
  • mfrom: (1.5.5)
  • Revision ID: package-import@ubuntu.com-20140423014104-nulhaisomztpfriy
Tags: 0.9.6-1
* New upstream release.
* Allow output to stderr in autopktest.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
"""Compatibilty tests between the Dulwich client and the cgit server."""
21
21
 
22
 
from cStringIO import StringIO
 
22
from io import BytesIO
23
23
import BaseHTTPServer
24
24
import SimpleHTTPServer
25
25
import copy
53
53
    import_repo_to_dir,
54
54
    run_git_or_fail,
55
55
    )
56
 
from dulwich.tests.compat.server_utils import (
57
 
    ShutdownServerMixIn,
58
 
    )
59
56
 
60
57
 
61
58
class DulwichClientTestBase(object):
114
111
    def make_dummy_commit(self, dest):
115
112
        b = objects.Blob.from_string('hi')
116
113
        dest.object_store.add_object(b)
117
 
        t = index.commit_tree(dest.object_store, [('hi', b.id, 0100644)])
 
114
        t = index.commit_tree(dest.object_store, [('hi', b.id, 0o100644)])
118
115
        c = objects.Commit()
119
116
        c.author = c.committer = 'Foo Bar <foo@example.com>'
120
117
        c.author_time = c.commit_time = 0
146
143
        c = self._client()
147
144
        try:
148
145
            c.send_pack(self._build_path('/dest'), lambda _: sendrefs, gen_pack)
149
 
        except errors.UpdateRefsError, e:
 
146
        except errors.UpdateRefsError as e:
150
147
            self.assertEqual('refs/heads/master failed to update', str(e))
151
148
            self.assertEqual({'refs/heads/branch': 'ok',
152
149
                              'refs/heads/master': 'non-fast-forward'},
160
157
        c = self._client()
161
158
        try:
162
159
            c.send_pack(self._build_path('/dest'), lambda _: sendrefs, gen_pack)
163
 
        except errors.UpdateRefsError, e:
 
160
        except errors.UpdateRefsError as e:
164
161
            self.assertEqual('refs/heads/branch, refs/heads/master failed to '
165
162
                             'update', str(e))
166
163
            self.assertEqual({'refs/heads/branch': 'non-fast-forward',
169
166
 
170
167
    def test_archive(self):
171
168
        c = self._client()
172
 
        f = StringIO()
 
169
        f = BytesIO()
173
170
        c.archive(self._build_path('/server_new.export'), 'HEAD', f.write)
174
171
        f.seek(0)
175
172
        tf = tarfile.open(fileobj=f)
439
436
        return 'http://%s:%s/' % (self.server_name, self.server_port)
440
437
 
441
438
 
442
 
if not getattr(HTTPGitServer, 'shutdown', None):
443
 
    _HTTPGitServer = HTTPGitServer
444
 
 
445
 
    class TCPGitServer(ShutdownServerMixIn, HTTPGitServer):
446
 
        """Subclass of HTTPGitServer that can be shut down."""
447
 
 
448
 
        def __init__(self, *args, **kwargs):
449
 
            # BaseServer is old-style so we have to call both __init__s
450
 
            ShutdownServerMixIn.__init__(self)
451
 
            _HTTPGitServer.__init__(self, *args, **kwargs)
452
 
 
453
 
 
454
439
class DulwichHttpClientTest(CompatTestCase, DulwichClientTestBase):
455
440
 
456
441
    min_git_version = (1, 7, 0, 2)