769
770
return OldSmartClient()
772
class RemoteBranchTestCase(TestRemote):
773
class RemoteBzrDirTestCase(TestRemote):
775
def make_remote_bzrdir(self, transport, client):
776
"""Make a RemotebzrDir using 'client' as the _client."""
777
return RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
781
class RemoteBranchTestCase(RemoteBzrDirTestCase):
774
783
def make_remote_branch(self, transport, client):
775
784
"""Make a RemoteBranch using 'client' as its _SmartClient.
780
789
# we do not want bzrdir to make any remote calls, so use False as its
781
790
# _client. If it tries to make a remote call, this will fail
783
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
792
bzrdir = self.make_remote_bzrdir(transport, False)
785
793
repo = RemoteRepository(bzrdir, None, _client=client)
786
794
branch_format = self.get_branch_format()
787
795
format = RemoteBranchFormat(network_name=branch_format.network_name())
836
844
branch = self.make_remote_branch(transport, client)
837
845
result = branch.get_parent()
838
846
self.assertEqual('http://foo/', result)
847
client.finished_test()
850
class TestBranchSetParentLocation(RemoteBranchTestCase):
852
def test_no_parent(self):
853
# We call the verb when setting parent to None
854
transport = MemoryTransport()
855
client = FakeClient(transport.base)
856
client.add_expected_call(
857
'Branch.get_stacked_on_url', ('quack/',),
858
'error', ('NotStacked',))
859
client.add_expected_call(
860
'Branch.set_parent_location', ('quack/', 'b', 'r', ''),
862
transport.mkdir('quack')
863
transport = transport.clone('quack')
864
branch = self.make_remote_branch(transport, client)
865
branch._lock_token = 'b'
866
branch._repo_lock_token = 'r'
867
branch._set_parent_location(None)
868
client.finished_test()
870
def test_parent(self):
871
transport = MemoryTransport()
872
client = FakeClient(transport.base)
873
client.add_expected_call(
874
'Branch.get_stacked_on_url', ('kwaak/',),
875
'error', ('NotStacked',))
876
client.add_expected_call(
877
'Branch.set_parent_location', ('kwaak/', 'b', 'r', 'foo'),
879
transport.mkdir('kwaak')
880
transport = transport.clone('kwaak')
881
branch = self.make_remote_branch(transport, client)
882
branch._lock_token = 'b'
883
branch._repo_lock_token = 'r'
884
branch._set_parent_location('foo')
885
client.finished_test()
887
def test_backwards_compat(self):
888
self.setup_smart_server_with_call_log()
889
branch = self.make_branch('.')
890
self.reset_smart_call_log()
891
verb = 'Branch.set_parent_location'
892
self.disable_verb(verb)
893
branch.set_parent('http://foo/')
894
self.assertLength(12, self.hpss_calls)
841
897
class TestBranchGetTagsBytes(RemoteBranchTestCase):
1418
1474
client.finished_test()
1477
class TestBzrDirGetSetConfig(RemoteBzrDirTestCase):
1479
def test__get_config(self):
1480
client = FakeClient()
1481
client.add_success_response_with_body('default_stack_on = /\n', 'ok')
1482
transport = MemoryTransport()
1483
bzrdir = self.make_remote_bzrdir(transport, client)
1484
config = bzrdir.get_config()
1485
self.assertEqual('/', config.get_default_stack_on())
1487
[('call_expecting_body', 'BzrDir.get_config_file', ('memory:///',))],
1490
def test_set_option_uses_vfs(self):
1491
self.setup_smart_server_with_call_log()
1492
bzrdir = self.make_bzrdir('.')
1493
self.reset_smart_call_log()
1494
config = bzrdir.get_config()
1495
config.set_default_stack_on('/')
1496
self.assertLength(3, self.hpss_calls)
1498
def test_backwards_compat_get_option(self):
1499
self.setup_smart_server_with_call_log()
1500
bzrdir = self.make_bzrdir('.')
1501
verb = 'BzrDir.get_config_file'
1502
self.disable_verb(verb)
1503
self.reset_smart_call_log()
1504
self.assertEqual(None,
1505
bzrdir._get_config().get_option('default_stack_on'))
1506
self.assertLength(3, self.hpss_calls)
1421
1509
class TestTransportIsReadonly(tests.TestCase):
1423
1511
def test_true(self):
1473
1561
class TestRemoteSSHTransportAuthentication(tests.TestCaseInTempDir):
1475
def test_defaults_to_none(self):
1563
def test_defaults_to_getuser(self):
1476
1564
t = RemoteSSHTransport('bzr+ssh://example.com')
1477
self.assertIs(None, t._get_credentials()[0])
1565
self.assertIs(getpass.getuser(), t._get_credentials()[0])
1479
1567
def test_uses_authentication_config(self):
1480
1568
conf = config.AuthenticationConfig()
2410
2498
# it should have an appropriate fallback repository, which should also
2411
2499
# be a RemoteRepository
2412
self.assertEquals(len(remote_repo._fallback_repositories), 1)
2500
self.assertLength(1, remote_repo._fallback_repositories)
2413
2501
self.assertIsInstance(remote_repo._fallback_repositories[0],
2414
2502
RemoteRepository)
2415
2503
# and it has the revision committed to the underlying repository;