260
260
self.assertTrue(result)
263
class TestRemote(tests.TestCaseWithMemoryTransport):
265
def disable_verb(self, verb):
266
"""Disable a verb for one test."""
267
request_handlers = smart.request.request_handlers
268
orig_method = request_handlers.get(verb)
269
request_handlers.remove(verb)
271
request_handlers.register(verb, orig_method)
272
self.addCleanup(restoreVerb)
263
275
class Test_ClientMedium_remote_path_from_transport(tests.TestCase):
264
276
"""Tests for the behaviour of client_medium.remote_path_from_transport."""
447
459
RemoteBzrDirFormat.probe_transport, OldServerTransport())
450
class TestBzrDirCreateRepository(tests.TestCaseWithMemoryTransport):
462
class TestBzrDirCreateRepository(TestRemote):
452
464
def test_backwards_compat(self):
453
465
self.setup_smart_server_with_call_log()
454
466
bzrdir = self.make_bzrdir('.')
455
467
self.reset_smart_call_log()
456
request_handlers = smart.request.request_handlers
457
orig_method = request_handlers.get('BzrDir.create_repository')
458
request_handlers.remove('BzrDir.create_repository')
460
repo = bzrdir.create_repository()
461
create_repo_call_count = len([call for call in self.hpss_calls if
462
call[0].method == 'BzrDir.create_repository'])
463
self.assertEqual(1, create_repo_call_count)
465
request_handlers.register('BzrDir.create_repository', orig_method)
468
self.disable_verb('BzrDir.create_repository')
469
repo = bzrdir.create_repository()
470
create_repo_call_count = len([call for call in self.hpss_calls if
471
call[0].method == 'BzrDir.create_repository'])
472
self.assertEqual(1, create_repo_call_count)
467
474
def test_current_server(self):
468
475
transport = self.get_transport('.')
1123
1130
self.assertEqual('bar', t._get_credentials()[0])
1126
class TestRemoteRepository(tests.TestCase):
1133
class TestRemoteRepository(TestRemote):
1127
1134
"""Base for testing RemoteRepository protocol usage.
1129
1136
These tests contain frozen requests and responses. We want any changes to
1476
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository):
1478
def test_backwards_compat(self):
1479
self.setup_smart_server_with_call_log()
1480
repo = self.make_repository('.')
1481
self.reset_smart_call_log()
1482
verb = 'Repository.set_make_working_trees'
1483
self.disable_verb(verb)
1484
repo.set_make_working_trees(True)
1485
call_count = len([call for call in self.hpss_calls if
1486
call[0].method == verb])
1487
self.assertEqual(1, call_count)
1489
def test_current(self):
1490
transport_path = 'quack'
1491
repo, client = self.setup_fake_client_and_repository(transport_path)
1492
client.add_expected_call(
1493
'Repository.set_make_working_trees', ('quack/', 'True'),
1495
client.add_expected_call(
1496
'Repository.set_make_working_trees', ('quack/', 'False'),
1498
repo.set_make_working_trees(True)
1499
repo.set_make_working_trees(False)
1469
1502
class TestRepositoryUnlock(TestRemoteRepository):
1471
1504
def test_unlock(self):