~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: 2011-01-21 19:38:13 UTC
  • mfrom: (1.2.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20110121193813-2cnp21akwf5j0pq2
Tags: 0.7.0-1
* New upstream release.
 + Changes default test runner from nose to testtools.
* Drop Pure- from the description.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
from dulwich.client import (
22
22
    GitClient,
 
23
    TCPGitClient,
 
24
    SubprocessGitClient,
23
25
    SSHGitClient,
 
26
    get_transport_and_path,
24
27
    )
25
28
from dulwich.tests import (
26
29
    TestCase,
27
30
    )
28
31
from dulwich.protocol import (
 
32
    TCP_GIT_PORT,
29
33
    Protocol,
30
34
    )
31
35
 
60
64
 
61
65
    def test_fetch_pack_none(self):
62
66
        self.rin.write(
63
 
            "008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n"
64
 
            "0000")
 
67
            '008855dcc6bf963f922e1ed5c4bbaaefcfacef57b1d7 HEAD.multi_ack thin-pack side-band side-band-64k ofs-delta shallow no-progress include-tag\n'
 
68
            '0000')
65
69
        self.rin.seek(0)
66
 
        self.client.fetch_pack("bla", lambda heads: [], None, None, None)
67
 
        self.assertEquals(self.rout.getvalue(), "0000")
 
70
        self.client.fetch_pack('bla', lambda heads: [], None, None, None)
 
71
        self.assertEquals(self.rout.getvalue(), '0000')
 
72
 
 
73
    def test_get_transport_and_path_tcp(self):
 
74
        client, path = get_transport_and_path('git://foo.com/bar/baz')
 
75
        self.assertTrue(isinstance(client, TCPGitClient))
 
76
        self.assertEquals('foo.com', client._host)
 
77
        self.assertEquals(TCP_GIT_PORT, client._port)
 
78
        self.assertEqual('/bar/baz', path)
 
79
 
 
80
        client, path = get_transport_and_path('git://foo.com:1234/bar/baz')
 
81
        self.assertTrue(isinstance(client, TCPGitClient))
 
82
        self.assertEquals('foo.com', client._host)
 
83
        self.assertEquals(1234, client._port)
 
84
        self.assertEqual('/bar/baz', path)
 
85
 
 
86
    def test_get_transport_and_path_ssh_explicit(self):
 
87
        client, path = get_transport_and_path('git+ssh://foo.com/bar/baz')
 
88
        self.assertTrue(isinstance(client, SSHGitClient))
 
89
        self.assertEquals('foo.com', client.host)
 
90
        self.assertEquals(None, client.port)
 
91
        self.assertEquals(None, client.username)
 
92
        self.assertEqual('/bar/baz', path)
 
93
 
 
94
        client, path = get_transport_and_path('git+ssh://foo.com:1234/bar/baz')
 
95
        self.assertTrue(isinstance(client, SSHGitClient))
 
96
        self.assertEquals('foo.com', client.host)
 
97
        self.assertEquals(1234, client.port)
 
98
        self.assertEqual('/bar/baz', path)
 
99
 
 
100
    def test_get_transport_and_path_ssh_implicit(self):
 
101
        client, path = get_transport_and_path('foo:/bar/baz')
 
102
        self.assertTrue(isinstance(client, SSHGitClient))
 
103
        self.assertEquals('foo', client.host)
 
104
        self.assertEquals(None, client.port)
 
105
        self.assertEquals(None, client.username)
 
106
        self.assertEqual('/bar/baz', path)
 
107
 
 
108
        client, path = get_transport_and_path('foo.com:/bar/baz')
 
109
        self.assertTrue(isinstance(client, SSHGitClient))
 
110
        self.assertEquals('foo.com', client.host)
 
111
        self.assertEquals(None, client.port)
 
112
        self.assertEquals(None, client.username)
 
113
        self.assertEqual('/bar/baz', path)
 
114
 
 
115
        client, path = get_transport_and_path('user@foo.com:/bar/baz')
 
116
        self.assertTrue(isinstance(client, SSHGitClient))
 
117
        self.assertEquals('foo.com', client.host)
 
118
        self.assertEquals(None, client.port)
 
119
        self.assertEquals('user', client.username)
 
120
        self.assertEqual('/bar/baz', path)
 
121
 
 
122
    def test_get_transport_and_path_subprocess(self):
 
123
        client, path = get_transport_and_path('foo.bar/baz')
 
124
        self.assertTrue(isinstance(client, SubprocessGitClient))
 
125
        self.assertEquals('foo.bar/baz', path)
 
126
 
 
127
    def test_get_transport_and_path_error(self):
 
128
        self.assertRaises(ValueError, get_transport_and_path, 'foo://bar/baz')
68
129
 
69
130
 
70
131
class SSHGitClientTests(TestCase):
71
132
 
72
133
    def setUp(self):
73
134
        super(SSHGitClientTests, self).setUp()
74
 
        self.client = SSHGitClient("git.samba.org")
 
135
        self.client = SSHGitClient('git.samba.org')
75
136
 
76
137
    def test_default_command(self):
77
 
        self.assertEquals("git-upload-pack", self.client._get_cmd_path("upload-pack"))
 
138
        self.assertEquals('git-upload-pack', self.client._get_cmd_path('upload-pack'))
78
139
 
79
140
    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"))
 
141
        self.client.alternative_paths['upload-pack'] = '/usr/lib/git/git-upload-pack'
 
142
        self.assertEquals('/usr/lib/git/git-upload-pack', self.client._get_cmd_path('upload-pack'))
82
143