474
473
self.assertFinished(client)
476
class TestBzrDirOpen(TestRemote):
478
def make_fake_client_and_transport(self, path='quack'):
479
transport = MemoryTransport()
480
transport.mkdir(path)
481
transport = transport.clone(path)
482
client = FakeClient(transport.base)
483
return client, transport
485
def test_absent(self):
486
client, transport = self.make_fake_client_and_transport()
487
client.add_expected_call(
488
'BzrDir.open_2.1', ('quack/',), 'success', ('no',))
489
self.assertRaises(errors.NotBranchError, RemoteBzrDir, transport,
490
remote.RemoteBzrDirFormat(), _client=client, _force_probe=True)
491
self.assertFinished(client)
493
def test_present_without_workingtree(self):
494
client, transport = self.make_fake_client_and_transport()
495
client.add_expected_call(
496
'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'no'))
497
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
498
_client=client, _force_probe=True)
499
self.assertIsInstance(bd, RemoteBzrDir)
500
self.assertFalse(bd.has_workingtree())
501
self.assertRaises(errors.NoWorkingTree, bd.open_workingtree)
502
self.assertFinished(client)
504
def test_present_with_workingtree(self):
505
client, transport = self.make_fake_client_and_transport()
506
client.add_expected_call(
507
'BzrDir.open_2.1', ('quack/',), 'success', ('yes', 'yes'))
508
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
509
_client=client, _force_probe=True)
510
self.assertIsInstance(bd, RemoteBzrDir)
511
self.assertTrue(bd.has_workingtree())
512
self.assertRaises(errors.NotLocalUrl, bd.open_workingtree)
513
self.assertFinished(client)
515
def test_backwards_compat(self):
516
client, transport = self.make_fake_client_and_transport()
517
client.add_expected_call(
518
'BzrDir.open_2.1', ('quack/',), 'unknown', ('BzrDir.open_2.1',))
519
client.add_expected_call(
520
'BzrDir.open', ('quack/',), 'success', ('yes',))
521
bd = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
522
_client=client, _force_probe=True)
523
self.assertIsInstance(bd, RemoteBzrDir)
524
self.assertFinished(client)
477
527
class TestBzrDirOpenBranch(TestRemote):
479
529
def test_backwards_compat(self):
689
739
# fallback all the way to the first version.
690
740
reference_format = self.get_repo_format()
691
741
network_name = reference_format.network_name()
692
client = FakeClient('bzr://example.com/')
742
server_url = 'bzr://example.com/'
743
self.permit_url(server_url)
744
client = FakeClient(server_url)
693
745
client.add_unknown_method_response('BzrDir.find_repositoryV3')
694
746
client.add_unknown_method_response('BzrDir.find_repositoryV2')
695
747
client.add_success_response('ok', '', 'no', 'no')
701
753
reference_format.get_format_string(), 'ok')
702
754
# PackRepository wants to do a stat
703
755
client.add_success_response('stat', '0', '65535')
704
remote_transport = RemoteTransport('bzr://example.com/quack/', medium=False,
756
remote_transport = RemoteTransport(server_url + 'quack/', medium=False,
706
758
bzrdir = RemoteBzrDir(remote_transport, remote.RemoteBzrDirFormat(),
721
773
# fallback to find_repositoryV2
722
774
reference_format = self.get_repo_format()
723
775
network_name = reference_format.network_name()
724
client = FakeClient('bzr://example.com/')
776
server_url = 'bzr://example.com/'
777
self.permit_url(server_url)
778
client = FakeClient(server_url)
725
779
client.add_unknown_method_response('BzrDir.find_repositoryV3')
726
780
client.add_success_response('ok', '', 'no', 'no', 'no')
727
781
# A real repository instance will be created to determine the network
732
786
reference_format.get_format_string(), 'ok')
733
787
# PackRepository wants to do a stat
734
788
client.add_success_response('stat', '0', '65535')
735
remote_transport = RemoteTransport('bzr://example.com/quack/', medium=False,
789
remote_transport = RemoteTransport(server_url + 'quack/', medium=False,
737
791
bzrdir = RemoteBzrDir(remote_transport, remote.RemoteBzrDirFormat(),
1727
1781
return repo, client
1784
def remoted_description(format):
1785
return 'Remote: ' + format.get_format_description()
1788
class TestBranchFormat(tests.TestCase):
1790
def test_get_format_description(self):
1791
remote_format = RemoteBranchFormat()
1792
real_format = branch.BranchFormat.get_default_format()
1793
remote_format._network_name = real_format.network_name()
1794
self.assertEqual(remoted_description(real_format),
1795
remote_format.get_format_description())
1730
1798
class TestRepositoryFormat(TestRemoteRepository):
1732
1800
def test_fast_delta(self):
1739
1807
false_format._network_name = false_name
1740
1808
self.assertEqual(False, false_format.fast_deltas)
1810
def test_get_format_description(self):
1811
remote_repo_format = RemoteRepositoryFormat()
1812
real_format = repository.RepositoryFormat.get_default_format()
1813
remote_repo_format._network_name = real_format.network_name()
1814
self.assertEqual(remoted_description(real_format),
1815
remote_repo_format.get_format_description())
1743
1818
class TestRepositoryGatherStats(TestRemoteRepository):