1
# Copyright (C) 2005-2010 Robey Pointer <robey@lag.net>
1
# Copyright (C) 2005-2011 Robey Pointer <robey@lag.net>
2
2
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
4
4
# This program is free software; you can redistribute it and/or modify
47
44
from bzrlib.transport import sftp as _mod_sftp
48
45
from bzrlib.tests import stub_sftp
50
from bzrlib.workingtree import WorkingTree
53
48
def set_test_transport_to_sftp(testcase):
54
49
"""A helper to set transports on test case instances."""
174
169
"""Test that if no 'ssh' is available we get builtin paramiko"""
175
170
from bzrlib.transport import ssh
176
171
# set '.' as the only location in the path, forcing no 'ssh' to exist
177
orig_vendor = ssh._ssh_vendor_manager._cached_ssh_vendor
178
orig_path = set_or_unset_env('PATH', '.')
180
# No vendor defined yet, query for one
181
ssh._ssh_vendor_manager.clear_cache()
182
vendor = ssh._get_ssh_vendor()
183
self.assertIsInstance(vendor, ssh.ParamikoVendor)
185
set_or_unset_env('PATH', orig_path)
186
ssh._ssh_vendor_manager._cached_ssh_vendor = orig_vendor
172
self.overrideAttr(ssh, '_ssh_vendor_manager')
173
self.overrideEnv('PATH', '.')
174
ssh._ssh_vendor_manager.clear_cache()
175
vendor = ssh._get_ssh_vendor()
176
self.assertIsInstance(vendor, ssh.ParamikoVendor)
188
178
def test_abspath_root_sibling_server(self):
189
179
server = stub_sftp.SFTPSiblingAbsoluteServer()
190
180
server.start_server()
192
transport = _mod_transport.get_transport(server.get_url())
193
self.assertFalse(transport.abspath('/').endswith('/~/'))
194
self.assertTrue(transport.abspath('/').endswith('/'))
181
self.addCleanup(server.stop_server)
183
transport = _mod_transport.get_transport(server.get_url())
184
self.assertFalse(transport.abspath('/').endswith('/~/'))
185
self.assertTrue(transport.abspath('/').endswith('/'))
200
189
class SFTPBranchTest(TestCaseWithSFTPServer):