~ubuntu-branches/ubuntu/oneiric/dulwich/oneiric

« back to all changes in this revision

Viewing changes to dulwich/tests/test_client.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2010-07-30 13:22:11 UTC
  • mfrom: (1.2.11 upstream) (8.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20100730132211-k6aop8v5z42mawef
Tags: 0.6.1-1
* New upstream release.
* Bump standards version to 3.9.1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
# MA  02110-1301, USA.
18
18
 
19
19
from cStringIO import StringIO
20
 
from unittest import TestCase
21
20
 
22
21
from dulwich.client import (
23
22
    GitClient,
24
 
    )
 
23
    SSHGitClient,
 
24
    )
 
25
from dulwich.tests import (
 
26
    TestCase,
 
27
    )
 
28
from dulwich.protocol import (
 
29
    Protocol,
 
30
    )
 
31
 
 
32
 
 
33
class DummyClient(GitClient):
 
34
    def __init__(self, can_read, read, write):
 
35
        self.can_read = can_read
 
36
        self.read = read
 
37
        self.write = write
 
38
        GitClient.__init__(self)
 
39
 
 
40
    def _connect(self, service, path):
 
41
        return Protocol(self.read, self.write), self.can_read
25
42
 
26
43
 
27
44
# TODO(durin42): add unit-level tests of GitClient
28
45
class GitClientTests(TestCase):
29
46
 
30
47
    def setUp(self):
 
48
        super(GitClientTests, self).setUp()
31
49
        self.rout = StringIO()
32
50
        self.rin = StringIO()
33
 
        self.client = GitClient(lambda x: True, self.rin.read,
34
 
            self.rout.write)
 
51
        self.client = DummyClient(lambda x: True, self.rin.read,
 
52
                                  self.rout.write)
35
53
 
36
54
    def test_caps(self):
37
55
        self.assertEquals(set(['multi_ack', 'side-band-64k', 'ofs-delta',
47
65
        self.rin.seek(0)
48
66
        self.client.fetch_pack("bla", lambda heads: [], None, None, None)
49
67
        self.assertEquals(self.rout.getvalue(), "0000")
 
68
 
 
69
 
 
70
class SSHGitClientTests(TestCase):
 
71
 
 
72
    def setUp(self):
 
73
        super(SSHGitClientTests, self).setUp()
 
74
        self.client = SSHGitClient("git.samba.org")
 
75
 
 
76
    def test_default_command(self):
 
77
        self.assertEquals("git-upload-pack", self.client._get_cmd_path("upload-pack"))
 
78
 
 
79
    def test_alternative_command_path(self):
 
80
        self.client.alternative_paths["upload-pack"] = "/usr/lib/git/git-upload-pack"
 
81
        self.assertEquals("/usr/lib/git/git-upload-pack", self.client._get_cmd_path("upload-pack"))
 
82