795
class TestSmartServerBranchRequestSetParent(tests.TestCaseWithMemoryTransport):
797
def test_set_parent_none(self):
798
branch = self.make_branch('base', format="1.9")
800
branch._set_parent_location('foo')
802
request = smart.branch.SmartServerBranchRequestSetParentLocation(
803
self.get_transport())
804
branch_token = branch.lock_write()
805
repo_token = branch.repository.lock_write()
807
response = request.execute('base', branch_token, repo_token, '')
809
branch.repository.unlock()
811
self.assertEqual(SuccessfulSmartServerResponse(()), response)
812
self.assertEqual(None, branch.get_parent())
814
def test_set_parent_something(self):
815
branch = self.make_branch('base', format="1.9")
816
request = smart.branch.SmartServerBranchRequestSetParentLocation(
817
self.get_transport())
818
branch_token = branch.lock_write()
819
repo_token = branch.repository.lock_write()
821
response = request.execute('base', branch_token, repo_token,
824
branch.repository.unlock()
826
self.assertEqual(SuccessfulSmartServerResponse(()), response)
827
self.assertEqual('http://bar/', branch.get_parent())
772
830
class TestSmartServerBranchRequestGetTagsBytes(tests.TestCaseWithMemoryTransport):
773
831
# Only called when the branch format and tags match [yay factory
774
832
# methods] so only need to test straight forward cases.
1386
1444
for key, item in smart.request.request_handlers.iteritems():
1447
def assertHandlerEqual(self, verb, handler):
1448
self.assertEqual(smart.request.request_handlers.get(verb), handler)
1389
1450
def test_registered_methods(self):
1390
1451
"""Test that known methods are registered to the correct object."""
1392
smart.request.request_handlers.get('Branch.get_config_file'),
1452
self.assertHandlerEqual('Branch.get_config_file',
1393
1453
smart.branch.SmartServerBranchGetConfigFile)
1395
smart.request.request_handlers.get('Branch.get_parent'),
1454
self.assertHandlerEqual('Branch.get_parent',
1396
1455
smart.branch.SmartServerBranchGetParent)
1398
smart.request.request_handlers.get('Branch.get_tags_bytes'),
1456
self.assertHandlerEqual('Branch.get_tags_bytes',
1399
1457
smart.branch.SmartServerBranchGetTagsBytes)
1401
smart.request.request_handlers.get('Branch.lock_write'),
1458
self.assertHandlerEqual('Branch.lock_write',
1402
1459
smart.branch.SmartServerBranchRequestLockWrite)
1404
smart.request.request_handlers.get('Branch.last_revision_info'),
1460
self.assertHandlerEqual('Branch.last_revision_info',
1405
1461
smart.branch.SmartServerBranchRequestLastRevisionInfo)
1407
smart.request.request_handlers.get('Branch.revision_history'),
1462
self.assertHandlerEqual('Branch.revision_history',
1408
1463
smart.branch.SmartServerRequestRevisionHistory)
1410
smart.request.request_handlers.get('Branch.set_config_option'),
1464
self.assertHandlerEqual('Branch.set_config_option',
1411
1465
smart.branch.SmartServerBranchRequestSetConfigOption)
1413
smart.request.request_handlers.get('Branch.set_last_revision'),
1466
self.assertHandlerEqual('Branch.set_last_revision',
1414
1467
smart.branch.SmartServerBranchRequestSetLastRevision)
1416
smart.request.request_handlers.get('Branch.set_last_revision_info'),
1468
self.assertHandlerEqual('Branch.set_last_revision_info',
1417
1469
smart.branch.SmartServerBranchRequestSetLastRevisionInfo)
1419
smart.request.request_handlers.get('Branch.unlock'),
1470
self.assertHandlerEqual('Branch.set_last_revision_ex',
1471
smart.branch.SmartServerBranchRequestSetLastRevisionEx)
1472
self.assertHandlerEqual('Branch.set_parent_location',
1473
smart.branch.SmartServerBranchRequestSetParentLocation)
1474
self.assertHandlerEqual('Branch.unlock',
1420
1475
smart.branch.SmartServerBranchRequestUnlock)
1422
smart.request.request_handlers.get('BzrDir.find_repository'),
1476
self.assertHandlerEqual('BzrDir.find_repository',
1423
1477
smart.bzrdir.SmartServerRequestFindRepositoryV1)
1425
smart.request.request_handlers.get('BzrDir.find_repositoryV2'),
1478
self.assertHandlerEqual('BzrDir.find_repositoryV2',
1426
1479
smart.bzrdir.SmartServerRequestFindRepositoryV2)
1428
smart.request.request_handlers.get('BzrDirFormat.initialize'),
1480
self.assertHandlerEqual('BzrDirFormat.initialize',
1429
1481
smart.bzrdir.SmartServerRequestInitializeBzrDir)
1431
smart.request.request_handlers.get('BzrDir.cloning_metadir'),
1482
self.assertHandlerEqual('BzrDir.cloning_metadir',
1432
1483
smart.bzrdir.SmartServerBzrDirRequestCloningMetaDir)
1434
smart.request.request_handlers.get('BzrDir.open_branch'),
1484
self.assertHandlerEqual('BzrDir.get_config_file',
1485
smart.bzrdir.SmartServerBzrDirRequestConfigFile)
1486
self.assertHandlerEqual('BzrDir.open_branch',
1435
1487
smart.bzrdir.SmartServerRequestOpenBranch)
1437
smart.request.request_handlers.get('BzrDir.open_branchV2'),
1488
self.assertHandlerEqual('BzrDir.open_branchV2',
1438
1489
smart.bzrdir.SmartServerRequestOpenBranchV2)
1440
smart.request.request_handlers.get('PackRepository.autopack'),
1490
self.assertHandlerEqual('PackRepository.autopack',
1441
1491
smart.packrepository.SmartServerPackRepositoryAutopack)
1443
smart.request.request_handlers.get('Repository.gather_stats'),
1492
self.assertHandlerEqual('Repository.gather_stats',
1444
1493
smart.repository.SmartServerRepositoryGatherStats)
1446
smart.request.request_handlers.get('Repository.get_parent_map'),
1494
self.assertHandlerEqual('Repository.get_parent_map',
1447
1495
smart.repository.SmartServerRepositoryGetParentMap)
1449
smart.request.request_handlers.get(
1450
'Repository.get_revision_graph'),
1496
self.assertHandlerEqual('Repository.get_revision_graph',
1451
1497
smart.repository.SmartServerRepositoryGetRevisionGraph)
1453
smart.request.request_handlers.get('Repository.get_stream'),
1498
self.assertHandlerEqual('Repository.get_stream',
1454
1499
smart.repository.SmartServerRepositoryGetStream)
1456
smart.request.request_handlers.get('Repository.has_revision'),
1500
self.assertHandlerEqual('Repository.has_revision',
1457
1501
smart.repository.SmartServerRequestHasRevision)
1459
smart.request.request_handlers.get('Repository.insert_stream'),
1502
self.assertHandlerEqual('Repository.insert_stream',
1460
1503
smart.repository.SmartServerRepositoryInsertStream)
1462
smart.request.request_handlers.get('Repository.insert_stream_locked'),
1504
self.assertHandlerEqual('Repository.insert_stream_locked',
1463
1505
smart.repository.SmartServerRepositoryInsertStreamLocked)
1465
smart.request.request_handlers.get('Repository.is_shared'),
1506
self.assertHandlerEqual('Repository.is_shared',
1466
1507
smart.repository.SmartServerRepositoryIsShared)
1468
smart.request.request_handlers.get('Repository.lock_write'),
1508
self.assertHandlerEqual('Repository.lock_write',
1469
1509
smart.repository.SmartServerRepositoryLockWrite)
1471
smart.request.request_handlers.get('Repository.tarball'),
1510
self.assertHandlerEqual('Repository.tarball',
1472
1511
smart.repository.SmartServerRepositoryTarball)
1474
smart.request.request_handlers.get('Repository.unlock'),
1512
self.assertHandlerEqual('Repository.unlock',
1475
1513
smart.repository.SmartServerRepositoryUnlock)
1477
smart.request.request_handlers.get('Transport.is_readonly'),
1514
self.assertHandlerEqual('Transport.is_readonly',
1478
1515
smart.request.SmartServerIsReadonly)