~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_sftp_transport.py

  • Committer: Andrew Bennetts
  • Date: 2007-03-28 07:08:42 UTC
  • mfrom: (2380 +trunk)
  • mto: (2018.5.146 hpss)
  • mto: This revision was merged to the branch mainline in revision 2414.
  • Revision ID: andrew.bennetts@canonical.com-20070328070842-r843houy668oxb9o
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 Robey Pointer <robey@lag.net>, Canonical Ltd
 
1
# Copyright (C) 2005 Robey Pointer <robey@lag.net>
 
2
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
2
3
#
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
16
17
 
17
18
import os
18
19
import socket
 
20
import sys
19
21
import threading
20
22
import time
21
23
 
105
107
 
106
108
    def test__remote_path(self):
107
109
        t = self.get_transport()
 
110
        # This test require unix-like absolute path
 
111
        test_dir = self.test_dir
 
112
        if sys.platform == 'win32':
 
113
            # using hack suggested by John Meinel.
 
114
            # TODO: write another mock server for this test
 
115
            #       and use absolute path without drive letter
 
116
            test_dir = '/' + test_dir
108
117
        # try what is currently used:
109
118
        # remote path = self._abspath(relpath)
110
 
        self.assertEqual(self.test_dir + '/relative', t._remote_path('relative'))
 
119
        self.assertEqual(test_dir + '/relative', t._remote_path('relative'))
111
120
        # we dont os.path.join because windows gives us the wrong path
112
 
        root_segments = self.test_dir.split('/')
 
121
        root_segments = test_dir.split('/')
113
122
        root_parent = '/'.join(root_segments[:-1])
114
123
        # .. should be honoured
115
124
        self.assertEqual(root_parent + '/sibling', t._remote_path('../sibling'))
205
214
        """Test that if no 'ssh' is available we get builtin paramiko"""
206
215
        from bzrlib.transport import ssh
207
216
        # set '.' as the only location in the path, forcing no 'ssh' to exist
208
 
        orig_vendor = ssh._ssh_vendor
 
217
        orig_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
209
218
        orig_path = set_or_unset_env('PATH', '.')
210
219
        try:
211
220
            # No vendor defined yet, query for one
212
 
            ssh._ssh_vendor = None
 
221
            ssh._ssh_vendor_manager.clear_cache()
213
222
            vendor = ssh._get_ssh_vendor()
214
223
            self.assertIsInstance(vendor, ssh.ParamikoVendor)
215
224
        finally:
216
225
            set_or_unset_env('PATH', orig_path)
217
 
            ssh._ssh_vendor = orig_vendor
 
226
            ssh._ssh_vendor_manager._cached_ssh_vendor = orig_vendor
218
227
 
219
228
    def test_abspath_root_sibling_server(self):
220
229
        from bzrlib.transport.sftp import SFTPSiblingAbsoluteServer
338
347
        s.bind(('localhost', 0))
339
348
        self.bogus_url = 'sftp://%s:%s/' % s.getsockname()
340
349
 
341
 
        orig_vendor = bzrlib.transport.ssh._ssh_vendor
 
350
        orig_vendor = bzrlib.transport.ssh._ssh_vendor_manager._cached_ssh_vendor
342
351
        def reset():
343
 
            bzrlib.transport.ssh._ssh_vendor = orig_vendor
 
352
            bzrlib.transport.ssh._ssh_vendor_manager._cached_ssh_vendor = orig_vendor
344
353
            s.close()
345
354
        self.addCleanup(reset)
346
355
 
347
356
    def set_vendor(self, vendor):
348
357
        import bzrlib.transport.ssh
349
 
        bzrlib.transport.ssh._ssh_vendor = vendor
 
358
        bzrlib.transport.ssh._ssh_vendor_manager._cached_ssh_vendor = vendor
350
359
 
351
360
    def test_bad_connection_paramiko(self):
352
361
        """Test that a real connection attempt raises the right error"""