~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_smart.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-15 03:10:36 UTC
  • mfrom: (4288.1.6 push.roundtrips)
  • Revision ID: pqm@pqm.ubuntu.com-20090415031036-ikndntbkaaj5zjya
(robertc) 6 less round trips on smart push by using a verb to get
        bzrdir stacking policy and inheriting set_parent for
        RemoteBranch. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
296
296
        self.assertEqual(result, request.execute(''))
297
297
 
298
298
 
 
299
class TestSmartServerBzrDirRequestGetConfigFile(
 
300
    tests.TestCaseWithMemoryTransport):
 
301
    """Tests for BzrDir.get_config_file."""
 
302
 
 
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(''))
 
312
 
 
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(''))
 
320
 
 
321
 
299
322
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport):
300
323
 
301
324
    def test_empty_dir(self):
1386
1409
        for key, item in smart.request.request_handlers.iteritems():
1387
1410
            pass
1388
1411
 
 
1412
    def assertHandlerEqual(self, verb, handler):
 
1413
        self.assertEqual(smart.request.request_handlers.get(verb), handler)
 
1414
 
1389
1415
    def test_registered_methods(self):
1390
1416
        """Test that known methods are registered to the correct object."""
1391
 
        self.assertEqual(
1392
 
            smart.request.request_handlers.get('Branch.get_config_file'),
 
1417
        self.assertHandlerEqual('Branch.get_config_file',
1393
1418
            smart.branch.SmartServerBranchGetConfigFile)
1394
 
        self.assertEqual(
1395
 
            smart.request.request_handlers.get('Branch.get_parent'),
 
1419
        self.assertHandlerEqual('Branch.get_parent',
1396
1420
            smart.branch.SmartServerBranchGetParent)
1397
 
        self.assertEqual(
1398
 
            smart.request.request_handlers.get('Branch.get_tags_bytes'),
 
1421
        self.assertHandlerEqual('Branch.get_tags_bytes',
1399
1422
            smart.branch.SmartServerBranchGetTagsBytes)
1400
 
        self.assertEqual(
1401
 
            smart.request.request_handlers.get('Branch.lock_write'),
 
1423
        self.assertHandlerEqual('Branch.lock_write',
1402
1424
            smart.branch.SmartServerBranchRequestLockWrite)
1403
 
        self.assertEqual(
1404
 
            smart.request.request_handlers.get('Branch.last_revision_info'),
 
1425
        self.assertHandlerEqual('Branch.last_revision_info',
1405
1426
            smart.branch.SmartServerBranchRequestLastRevisionInfo)
1406
 
        self.assertEqual(
1407
 
            smart.request.request_handlers.get('Branch.revision_history'),
 
1427
        self.assertHandlerEqual('Branch.revision_history',
1408
1428
            smart.branch.SmartServerRequestRevisionHistory)
1409
 
        self.assertEqual(
1410
 
            smart.request.request_handlers.get('Branch.set_config_option'),
 
1429
        self.assertHandlerEqual('Branch.set_config_option',
1411
1430
            smart.branch.SmartServerBranchRequestSetConfigOption)
1412
 
        self.assertEqual(
1413
 
            smart.request.request_handlers.get('Branch.set_last_revision'),
 
1431
        self.assertHandlerEqual('Branch.set_last_revision',
1414
1432
            smart.branch.SmartServerBranchRequestSetLastRevision)
1415
 
        self.assertEqual(
1416
 
            smart.request.request_handlers.get('Branch.set_last_revision_info'),
 
1433
        self.assertHandlerEqual('Branch.set_last_revision_info',
1417
1434
            smart.branch.SmartServerBranchRequestSetLastRevisionInfo)
1418
 
        self.assertEqual(
1419
 
            smart.request.request_handlers.get('Branch.unlock'),
 
1435
        self.assertHandlerEqual('Branch.unlock',
1420
1436
            smart.branch.SmartServerBranchRequestUnlock)
1421
 
        self.assertEqual(
1422
 
            smart.request.request_handlers.get('BzrDir.find_repository'),
 
1437
        self.assertHandlerEqual('BzrDir.find_repository',
1423
1438
            smart.bzrdir.SmartServerRequestFindRepositoryV1)
1424
 
        self.assertEqual(
1425
 
            smart.request.request_handlers.get('BzrDir.find_repositoryV2'),
 
1439
        self.assertHandlerEqual('BzrDir.find_repositoryV2',
1426
1440
            smart.bzrdir.SmartServerRequestFindRepositoryV2)
1427
 
        self.assertEqual(
1428
 
            smart.request.request_handlers.get('BzrDirFormat.initialize'),
 
1441
        self.assertHandlerEqual('BzrDirFormat.initialize',
1429
1442
            smart.bzrdir.SmartServerRequestInitializeBzrDir)
1430
 
        self.assertEqual(
1431
 
            smart.request.request_handlers.get('BzrDir.cloning_metadir'),
 
1443
        self.assertHandlerEqual('BzrDir.cloning_metadir',
1432
1444
            smart.bzrdir.SmartServerBzrDirRequestCloningMetaDir)
1433
 
        self.assertEqual(
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)
1436
 
        self.assertEqual(
1437
 
            smart.request.request_handlers.get('BzrDir.open_branchV2'),
 
1449
        self.assertHandlerEqual('BzrDir.open_branchV2',
1438
1450
            smart.bzrdir.SmartServerRequestOpenBranchV2)
1439
 
        self.assertEqual(
1440
 
            smart.request.request_handlers.get('PackRepository.autopack'),
 
1451
        self.assertHandlerEqual('PackRepository.autopack',
1441
1452
            smart.packrepository.SmartServerPackRepositoryAutopack)
1442
 
        self.assertEqual(
1443
 
            smart.request.request_handlers.get('Repository.gather_stats'),
 
1453
        self.assertHandlerEqual('Repository.gather_stats',
1444
1454
            smart.repository.SmartServerRepositoryGatherStats)
1445
 
        self.assertEqual(
1446
 
            smart.request.request_handlers.get('Repository.get_parent_map'),
 
1455
        self.assertHandlerEqual('Repository.get_parent_map',
1447
1456
            smart.repository.SmartServerRepositoryGetParentMap)
1448
 
        self.assertEqual(
1449
 
            smart.request.request_handlers.get(
1450
 
                'Repository.get_revision_graph'),
 
1457
        self.assertHandlerEqual('Repository.get_revision_graph',
1451
1458
            smart.repository.SmartServerRepositoryGetRevisionGraph)
1452
 
        self.assertEqual(
1453
 
            smart.request.request_handlers.get('Repository.get_stream'),
 
1459
        self.assertHandlerEqual('Repository.get_stream',
1454
1460
            smart.repository.SmartServerRepositoryGetStream)
1455
 
        self.assertEqual(
1456
 
            smart.request.request_handlers.get('Repository.has_revision'),
 
1461
        self.assertHandlerEqual('Repository.has_revision',
1457
1462
            smart.repository.SmartServerRequestHasRevision)
1458
 
        self.assertEqual(
1459
 
            smart.request.request_handlers.get('Repository.insert_stream'),
 
1463
        self.assertHandlerEqual('Repository.insert_stream',
1460
1464
            smart.repository.SmartServerRepositoryInsertStream)
1461
 
        self.assertEqual(
1462
 
            smart.request.request_handlers.get('Repository.insert_stream_locked'),
 
1465
        self.assertHandlerEqual('Repository.insert_stream_locked',
1463
1466
            smart.repository.SmartServerRepositoryInsertStreamLocked)
1464
 
        self.assertEqual(
1465
 
            smart.request.request_handlers.get('Repository.is_shared'),
 
1467
        self.assertHandlerEqual('Repository.is_shared',
1466
1468
            smart.repository.SmartServerRepositoryIsShared)
1467
 
        self.assertEqual(
1468
 
            smart.request.request_handlers.get('Repository.lock_write'),
 
1469
        self.assertHandlerEqual('Repository.lock_write',
1469
1470
            smart.repository.SmartServerRepositoryLockWrite)
1470
 
        self.assertEqual(
1471
 
            smart.request.request_handlers.get('Repository.tarball'),
 
1471
        self.assertHandlerEqual('Repository.tarball',
1472
1472
            smart.repository.SmartServerRepositoryTarball)
1473
 
        self.assertEqual(
1474
 
            smart.request.request_handlers.get('Repository.unlock'),
 
1473
        self.assertHandlerEqual('Repository.unlock',
1475
1474
            smart.repository.SmartServerRepositoryUnlock)
1476
 
        self.assertEqual(
1477
 
            smart.request.request_handlers.get('Transport.is_readonly'),
 
1475
        self.assertHandlerEqual('Transport.is_readonly',
1478
1476
            smart.request.SmartServerIsReadonly)