263
264
class TestRemote(tests.TestCaseWithMemoryTransport):
266
def get_branch_format(self):
267
reference_bzrdir_format = bzrdir.format_registry.get('default')()
268
return reference_bzrdir_format.get_branch_format()
265
270
def get_repo_format(self):
266
271
reference_bzrdir_format = bzrdir.format_registry.get('default')()
267
272
return reference_bzrdir_format.repository_format
371
376
control_name = reference_bzrdir_format.network_name()
372
377
client.add_expected_call(
373
378
'BzrDir.cloning_metadir', ('quack/', 'False'),
374
'success', (control_name, '', ('direct', ''))),
379
'success', (control_name, '', ('branch', ''))),
375
380
a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
377
382
result = a_bzrdir.cloning_metadir()
387
392
class TestBzrDirOpenBranch(TestRemote):
394
def test_backwards_compat(self):
395
self.setup_smart_server_with_call_log()
396
self.make_branch('.')
397
a_dir = BzrDir.open(self.get_url('.'))
398
self.reset_smart_call_log()
399
verb = 'BzrDir.open_branchV2'
400
self.disable_verb(verb)
401
format = a_dir.open_branch()
402
call_count = len([call for call in self.hpss_calls if
403
call.call.method == verb])
404
self.assertEqual(1, call_count)
389
406
def test_branch_present(self):
390
407
reference_format = self.get_repo_format()
391
408
network_name = reference_format.network_name()
409
branch_network_name = self.get_branch_format().network_name()
392
410
transport = MemoryTransport()
393
411
transport.mkdir('quack')
394
412
transport = transport.clone('quack')
395
413
client = FakeClient(transport.base)
396
414
client.add_expected_call(
397
'BzrDir.open_branch', ('quack/',),
398
'success', ('ok', ''))
415
'BzrDir.open_branchV2', ('quack/',),
416
'success', ('branch', branch_network_name))
399
417
client.add_expected_call(
400
418
'BzrDir.find_repositoryV3', ('quack/',),
401
419
'success', ('ok', '', 'no', 'no', 'no', network_name))
420
438
self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
421
439
self.assertEqual(
422
[('call', 'BzrDir.open_branch', ('quack/',))],
440
[('call', 'BzrDir.open_branchV2', ('quack/',))],
425
443
def test__get_tree_branch(self):
447
465
client = FakeClient(transport.base)
448
466
reference_format = self.get_repo_format()
449
467
network_name = reference_format.network_name()
468
branch_network_name = self.get_branch_format().network_name()
450
469
client.add_expected_call(
451
'BzrDir.open_branch', ('~hello/',),
452
'success', ('ok', ''))
470
'BzrDir.open_branchV2', ('~hello/',),
471
'success', ('branch', branch_network_name))
453
472
client.add_expected_call(
454
473
'BzrDir.find_repositoryV3', ('~hello/',),
455
474
'success', ('ok', '', 'no', 'no', 'no', network_name))
687
706
return OldSmartClient()
690
class RemoteBranchTestCase(tests.TestCase):
709
class RemoteBranchTestCase(TestRemote):
692
711
def make_remote_branch(self, transport, client):
693
712
"""Make a RemoteBranch using 'client' as its _SmartClient.
701
720
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
703
722
repo = RemoteRepository(bzrdir, None, _client=client)
704
return RemoteBranch(bzrdir, repo, _client=client)
723
branch_format = self.get_branch_format()
724
format = RemoteBranchFormat(network_name=branch_format.network_name())
725
return RemoteBranch(bzrdir, repo, _client=client, format=format)
707
728
class TestBranchGetParent(RemoteBranchTestCase):
754
775
self.assertEqual('http://foo/', result)
778
class TestBranchGetTagsBytes(RemoteBranchTestCase):
780
def test_backwards_compat(self):
781
self.setup_smart_server_with_call_log()
782
branch = self.make_branch('.')
783
self.reset_smart_call_log()
784
verb = 'Branch.get_tags_bytes'
785
self.disable_verb(verb)
786
branch.tags.get_tag_dict()
787
call_count = len([call for call in self.hpss_calls if
788
call.call.method == verb])
789
self.assertEqual(1, call_count)
791
def test_trivial(self):
792
transport = MemoryTransport()
793
client = FakeClient(transport.base)
794
client.add_expected_call(
795
'Branch.get_stacked_on_url', ('quack/',),
796
'error', ('NotStacked',))
797
client.add_expected_call(
798
'Branch.get_tags_bytes', ('quack/',),
800
transport.mkdir('quack')
801
transport = transport.clone('quack')
802
branch = self.make_remote_branch(transport, client)
803
result = branch.tags.get_tag_dict()
804
client.finished_test()
805
self.assertEqual({}, result)
757
808
class TestBranchLastRevisionInfo(RemoteBranchTestCase):
759
810
def test_empty_branch(self):
827
878
stacked_branch = self.make_branch('stacked', format='1.6')
828
879
stacked_branch.set_stacked_on_url('../base')
829
880
client = FakeClient(self.get_url())
881
branch_network_name = self.get_branch_format().network_name()
830
882
client.add_expected_call(
831
'BzrDir.open_branch', ('stacked/',),
832
'success', ('ok', ''))
883
'BzrDir.open_branchV2', ('stacked/',),
884
'success', ('branch', branch_network_name))
833
885
client.add_expected_call(
834
886
'BzrDir.find_repositoryV3', ('stacked/',),
835
887
'success', ('ok', '', 'no', 'no', 'no',
862
914
reference_format = self.get_repo_format()
863
915
network_name = reference_format.network_name()
864
916
client = FakeClient(self.get_url())
917
branch_network_name = self.get_branch_format().network_name()
865
918
client.add_expected_call(
866
'BzrDir.open_branch', ('stacked/',),
867
'success', ('ok', ''))
919
'BzrDir.open_branchV2', ('stacked/',),
920
'success', ('branch', branch_network_name))
868
921
client.add_expected_call(
869
922
'BzrDir.find_repositoryV3', ('stacked/',),
870
923
'success', ('ok', '', 'no', 'no', 'no', network_name))