263
263
class TestRemote(tests.TestCaseWithMemoryTransport):
265
def get_repo_format(self):
266
reference_bzrdir_format = bzrdir.format_registry.get('default')()
267
return reference_bzrdir_format.repository_format
265
269
def disable_verb(self, verb):
266
270
"""Disable a verb for one test."""
267
271
request_handlers = smart.request.request_handlers
345
349
AssertionError, client_medium._remember_remote_is_before, (1, 9))
348
class TestBzrDirOpenBranch(tests.TestCase):
352
class TestBzrDirOpenBranch(TestRemote):
350
354
def test_branch_present(self):
355
reference_format = self.get_repo_format()
356
network_name = reference_format.network_name()
351
357
transport = MemoryTransport()
352
358
transport.mkdir('quack')
353
359
transport = transport.clone('quack')
356
362
'BzrDir.open_branch', ('quack/',),
357
363
'success', ('ok', ''))
358
364
client.add_expected_call(
359
'BzrDir.find_repositoryV2', ('quack/',),
360
'success', ('ok', '', 'no', 'no', 'no'))
365
'BzrDir.find_repositoryV3', ('quack/',),
366
'success', ('ok', '', 'no', 'no', 'no', network_name))
361
367
client.add_expected_call(
362
368
'Branch.get_stacked_on_url', ('quack/',),
363
369
'error', ('NotStacked',))
404
410
# transmitted as "~", not "%7E".
405
411
transport = RemoteTCPTransport('bzr://localhost/~hello/')
406
412
client = FakeClient(transport.base)
413
reference_format = self.get_repo_format()
414
network_name = reference_format.network_name()
407
415
client.add_expected_call(
408
416
'BzrDir.open_branch', ('~hello/',),
409
417
'success', ('ok', ''))
410
418
client.add_expected_call(
411
'BzrDir.find_repositoryV2', ('~hello/',),
412
'success', ('ok', '', 'no', 'no', 'no'))
419
'BzrDir.find_repositoryV3', ('~hello/',),
420
'success', ('ok', '', 'no', 'no', 'no', network_name))
413
421
client.add_expected_call(
414
422
'Branch.get_stacked_on_url', ('~hello/',),
415
423
'error', ('NotStacked',))
419
427
client.finished_test()
421
429
def check_open_repository(self, rich_root, subtrees, external_lookup='no'):
430
reference_format = self.get_repo_format()
431
network_name = reference_format.network_name()
422
432
transport = MemoryTransport()
423
433
transport.mkdir('quack')
424
434
transport = transport.clone('quack')
432
442
subtree_response = 'no'
433
443
client = FakeClient(transport.base)
434
444
client.add_success_response(
435
'ok', '', rich_response, subtree_response, external_lookup)
445
'ok', '', rich_response, subtree_response, external_lookup,
436
447
bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
438
449
result = bzrdir.open_repository()
439
450
self.assertEqual(
440
[('call', 'BzrDir.find_repositoryV2', ('quack/',))],
451
[('call', 'BzrDir.find_repositoryV3', ('quack/',))],
442
453
self.assertIsInstance(result, RemoteRepository)
443
454
self.assertEqual(bzrdir, result.bzrdir)
535
546
class TestBzrDirOpenRepository(TestRemote):
537
def get_repo_format(self):
538
reference_bzrdir_format = bzrdir.format_registry.get('default')()
539
return reference_bzrdir_format.repository_format
541
548
def test_backwards_compat_1_2_3(self):
542
549
# fallback all the way to the first version.
543
550
reference_format = self.get_repo_format()
699
706
self.assertEqual((2, revid), result)
702
class TestBranch_get_stacked_on_url(tests.TestCaseWithMemoryTransport):
709
class TestBranch_get_stacked_on_url(TestRemote):
703
710
"""Test Branch._get_stacked_on_url rpc"""
705
712
def test_get_stacked_on_invalid_url(self):
739
746
'BzrDir.open_branch', ('stacked/',),
740
747
'success', ('ok', ''))
741
748
client.add_expected_call(
742
'BzrDir.find_repositoryV2', ('stacked/',),
743
'success', ('ok', '', 'no', 'no', 'no'))
749
'BzrDir.find_repositoryV3', ('stacked/',),
750
'success', ('ok', '', 'no', 'no', 'no',
751
stacked_branch.repository._format.network_name()))
744
752
# called twice, once from constructor and then again by us
745
753
client.add_expected_call(
746
754
'Branch.get_stacked_on_url', ('stacked/',),
766
774
base_branch = self.make_branch('base', format='1.6')
767
775
stacked_branch = self.make_branch('stacked', format='1.6')
768
776
stacked_branch.set_stacked_on_url('../base')
777
reference_format = self.get_repo_format()
778
network_name = reference_format.network_name()
769
779
client = FakeClient(self.get_url())
770
780
client.add_expected_call(
771
781
'BzrDir.open_branch', ('stacked/',),
772
782
'success', ('ok', ''))
773
783
client.add_expected_call(
774
'BzrDir.find_repositoryV2', ('stacked/',),
775
'success', ('ok', '', 'no', 'no', 'no'))
784
'BzrDir.find_repositoryV3', ('stacked/',),
785
'success', ('ok', '', 'no', 'no', 'no', network_name))
776
786
# called twice, once from constructor and then again by us
777
787
client.add_expected_call(
778
788
'Branch.get_stacked_on_url', ('stacked/',),