296
296
self.assertEqual(result, request.execute(''))
299
class TestSmartServerBzrDirRequestGetConfigFile(
300
tests.TestCaseWithMemoryTransport):
301
"""Tests for BzrDir.get_config_file."""
303
def test_present(self):
304
backing = self.get_transport()
305
dir = self.make_bzrdir('.')
306
dir.get_config().set_default_stack_on("/")
307
local_result = dir._get_config()._get_config_file().read()
308
request_class = smart_dir.SmartServerBzrDirRequestConfigFile
309
request = request_class(backing)
310
expected = SuccessfulSmartServerResponse((), local_result)
311
self.assertEqual(expected, request.execute(''))
313
def test_missing(self):
314
backing = self.get_transport()
315
dir = self.make_bzrdir('.')
316
request_class = smart_dir.SmartServerBzrDirRequestConfigFile
317
request = request_class(backing)
318
expected = SuccessfulSmartServerResponse((), '')
319
self.assertEqual(expected, request.execute(''))
299
322
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport):
301
324
def test_empty_dir(self):
1386
1409
for key, item in smart.request.request_handlers.iteritems():
1412
def assertHandlerEqual(self, verb, handler):
1413
self.assertEqual(smart.request.request_handlers.get(verb), handler)
1389
1415
def test_registered_methods(self):
1390
1416
"""Test that known methods are registered to the correct object."""
1392
smart.request.request_handlers.get('Branch.get_config_file'),
1417
self.assertHandlerEqual('Branch.get_config_file',
1393
1418
smart.branch.SmartServerBranchGetConfigFile)
1395
smart.request.request_handlers.get('Branch.get_parent'),
1419
self.assertHandlerEqual('Branch.get_parent',
1396
1420
smart.branch.SmartServerBranchGetParent)
1398
smart.request.request_handlers.get('Branch.get_tags_bytes'),
1421
self.assertHandlerEqual('Branch.get_tags_bytes',
1399
1422
smart.branch.SmartServerBranchGetTagsBytes)
1401
smart.request.request_handlers.get('Branch.lock_write'),
1423
self.assertHandlerEqual('Branch.lock_write',
1402
1424
smart.branch.SmartServerBranchRequestLockWrite)
1404
smart.request.request_handlers.get('Branch.last_revision_info'),
1425
self.assertHandlerEqual('Branch.last_revision_info',
1405
1426
smart.branch.SmartServerBranchRequestLastRevisionInfo)
1407
smart.request.request_handlers.get('Branch.revision_history'),
1427
self.assertHandlerEqual('Branch.revision_history',
1408
1428
smart.branch.SmartServerRequestRevisionHistory)
1410
smart.request.request_handlers.get('Branch.set_config_option'),
1429
self.assertHandlerEqual('Branch.set_config_option',
1411
1430
smart.branch.SmartServerBranchRequestSetConfigOption)
1413
smart.request.request_handlers.get('Branch.set_last_revision'),
1431
self.assertHandlerEqual('Branch.set_last_revision',
1414
1432
smart.branch.SmartServerBranchRequestSetLastRevision)
1416
smart.request.request_handlers.get('Branch.set_last_revision_info'),
1433
self.assertHandlerEqual('Branch.set_last_revision_info',
1417
1434
smart.branch.SmartServerBranchRequestSetLastRevisionInfo)
1419
smart.request.request_handlers.get('Branch.unlock'),
1435
self.assertHandlerEqual('Branch.unlock',
1420
1436
smart.branch.SmartServerBranchRequestUnlock)
1422
smart.request.request_handlers.get('BzrDir.find_repository'),
1437
self.assertHandlerEqual('BzrDir.find_repository',
1423
1438
smart.bzrdir.SmartServerRequestFindRepositoryV1)
1425
smart.request.request_handlers.get('BzrDir.find_repositoryV2'),
1439
self.assertHandlerEqual('BzrDir.find_repositoryV2',
1426
1440
smart.bzrdir.SmartServerRequestFindRepositoryV2)
1428
smart.request.request_handlers.get('BzrDirFormat.initialize'),
1441
self.assertHandlerEqual('BzrDirFormat.initialize',
1429
1442
smart.bzrdir.SmartServerRequestInitializeBzrDir)
1431
smart.request.request_handlers.get('BzrDir.cloning_metadir'),
1443
self.assertHandlerEqual('BzrDir.cloning_metadir',
1432
1444
smart.bzrdir.SmartServerBzrDirRequestCloningMetaDir)
1434
smart.request.request_handlers.get('BzrDir.open_branch'),
1445
self.assertHandlerEqual('BzrDir.get_config_file',
1446
smart.bzrdir.SmartServerBzrDirRequestConfigFile)
1447
self.assertHandlerEqual('BzrDir.open_branch',
1435
1448
smart.bzrdir.SmartServerRequestOpenBranch)
1437
smart.request.request_handlers.get('BzrDir.open_branchV2'),
1449
self.assertHandlerEqual('BzrDir.open_branchV2',
1438
1450
smart.bzrdir.SmartServerRequestOpenBranchV2)
1440
smart.request.request_handlers.get('PackRepository.autopack'),
1451
self.assertHandlerEqual('PackRepository.autopack',
1441
1452
smart.packrepository.SmartServerPackRepositoryAutopack)
1443
smart.request.request_handlers.get('Repository.gather_stats'),
1453
self.assertHandlerEqual('Repository.gather_stats',
1444
1454
smart.repository.SmartServerRepositoryGatherStats)
1446
smart.request.request_handlers.get('Repository.get_parent_map'),
1455
self.assertHandlerEqual('Repository.get_parent_map',
1447
1456
smart.repository.SmartServerRepositoryGetParentMap)
1449
smart.request.request_handlers.get(
1450
'Repository.get_revision_graph'),
1457
self.assertHandlerEqual('Repository.get_revision_graph',
1451
1458
smart.repository.SmartServerRepositoryGetRevisionGraph)
1453
smart.request.request_handlers.get('Repository.get_stream'),
1459
self.assertHandlerEqual('Repository.get_stream',
1454
1460
smart.repository.SmartServerRepositoryGetStream)
1456
smart.request.request_handlers.get('Repository.has_revision'),
1461
self.assertHandlerEqual('Repository.has_revision',
1457
1462
smart.repository.SmartServerRequestHasRevision)
1459
smart.request.request_handlers.get('Repository.insert_stream'),
1463
self.assertHandlerEqual('Repository.insert_stream',
1460
1464
smart.repository.SmartServerRepositoryInsertStream)
1462
smart.request.request_handlers.get('Repository.insert_stream_locked'),
1465
self.assertHandlerEqual('Repository.insert_stream_locked',
1463
1466
smart.repository.SmartServerRepositoryInsertStreamLocked)
1465
smart.request.request_handlers.get('Repository.is_shared'),
1467
self.assertHandlerEqual('Repository.is_shared',
1466
1468
smart.repository.SmartServerRepositoryIsShared)
1468
smart.request.request_handlers.get('Repository.lock_write'),
1469
self.assertHandlerEqual('Repository.lock_write',
1469
1470
smart.repository.SmartServerRepositoryLockWrite)
1471
smart.request.request_handlers.get('Repository.tarball'),
1471
self.assertHandlerEqual('Repository.tarball',
1472
1472
smart.repository.SmartServerRepositoryTarball)
1474
smart.request.request_handlers.get('Repository.unlock'),
1473
self.assertHandlerEqual('Repository.unlock',
1475
1474
smart.repository.SmartServerRepositoryUnlock)
1477
smart.request.request_handlers.get('Transport.is_readonly'),
1475
self.assertHandlerEqual('Transport.is_readonly',
1478
1476
smart.request.SmartServerIsReadonly)