~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2009-02-20 03:28:07 UTC
  • mto: This revision was merged to the branch mainline in revision 4023.
  • Revision ID: robertc@robertcollins.net-20090220032807-9ezo43wv9boso5id
Create a verb for Repository.set_make_working_trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
260
260
        self.assertTrue(result)
261
261
 
262
262
 
 
263
class TestRemote(tests.TestCaseWithMemoryTransport):
 
264
    
 
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)
 
270
        def restoreVerb():
 
271
            request_handlers.register(verb, orig_method)
 
272
        self.addCleanup(restoreVerb)
 
273
 
 
274
 
263
275
class Test_ClientMedium_remote_path_from_transport(tests.TestCase):
264
276
    """Tests for the behaviour of client_medium.remote_path_from_transport."""
265
277
 
447
459
            RemoteBzrDirFormat.probe_transport, OldServerTransport())
448
460
 
449
461
 
450
 
class TestBzrDirCreateRepository(tests.TestCaseWithMemoryTransport):
 
462
class TestBzrDirCreateRepository(TestRemote):
451
463
 
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')
459
 
        try:
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)
464
 
        finally:
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)
466
473
 
467
474
    def test_current_server(self):
468
475
        transport = self.get_transport('.')
1123
1130
        self.assertEqual('bar', t._get_credentials()[0])
1124
1131
 
1125
1132
 
1126
 
class TestRemoteRepository(tests.TestCase):
 
1133
class TestRemoteRepository(TestRemote):
1127
1134
    """Base for testing RemoteRepository protocol usage.
1128
1135
    
1129
1136
    These tests contain frozen requests and responses.  We want any changes to 
1466
1473
            client._calls)
1467
1474
 
1468
1475
 
 
1476
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository):
 
1477
 
 
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)
 
1488
 
 
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'),
 
1494
            'success', ('ok',))
 
1495
        client.add_expected_call(
 
1496
            'Repository.set_make_working_trees', ('quack/', 'False'),
 
1497
            'success', ('ok',))
 
1498
        repo.set_make_working_trees(True)
 
1499
        repo.set_make_working_trees(False)
 
1500
 
 
1501
 
1469
1502
class TestRepositoryUnlock(TestRemoteRepository):
1470
1503
 
1471
1504
    def test_unlock(self):