/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Robert Collins
  • Date: 2009-02-26 06:01:21 UTC
  • mto: This revision was merged to the branch mainline in revision 4060.
  • Revision ID: robertc@robertcollins.net-20090226060121-i33y7mbr72nqlvyv
Actually make this branch work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
262
262
 
263
263
class TestRemote(tests.TestCaseWithMemoryTransport):
264
264
 
 
265
    def get_repo_format(self):
 
266
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
267
        return reference_bzrdir_format.repository_format
 
268
 
265
269
    def disable_verb(self, verb):
266
270
        """Disable a verb for one test."""
267
271
        request_handlers = smart.request.request_handlers
345
349
            AssertionError, client_medium._remember_remote_is_before, (1, 9))
346
350
 
347
351
 
348
 
class TestBzrDirOpenBranch(tests.TestCase):
 
352
class TestBzrDirOpenBranch(TestRemote):
349
353
 
350
354
    def test_branch_present(self):
 
355
        reference_format = self.get_repo_format()
 
356
        network_name = reference_format.network_name()
351
357
        transport = MemoryTransport()
352
358
        transport.mkdir('quack')
353
359
        transport = transport.clone('quack')
356
362
            'BzrDir.open_branch', ('quack/',),
357
363
            'success', ('ok', ''))
358
364
        client.add_expected_call(
359
 
            'BzrDir.find_repositoryV2', ('quack/',),
360
 
            'success', ('ok', '', 'no', 'no', 'no'))
 
365
            'BzrDir.find_repositoryV3', ('quack/',),
 
366
            'success', ('ok', '', 'no', 'no', 'no', network_name))
361
367
        client.add_expected_call(
362
368
            'Branch.get_stacked_on_url', ('quack/',),
363
369
            'error', ('NotStacked',))
404
410
        # transmitted as "~", not "%7E".
405
411
        transport = RemoteTCPTransport('bzr://localhost/~hello/')
406
412
        client = FakeClient(transport.base)
 
413
        reference_format = self.get_repo_format()
 
414
        network_name = reference_format.network_name()
407
415
        client.add_expected_call(
408
416
            'BzrDir.open_branch', ('~hello/',),
409
417
            'success', ('ok', ''))
410
418
        client.add_expected_call(
411
 
            'BzrDir.find_repositoryV2', ('~hello/',),
412
 
            'success', ('ok', '', 'no', 'no', 'no'))
 
419
            'BzrDir.find_repositoryV3', ('~hello/',),
 
420
            'success', ('ok', '', 'no', 'no', 'no', network_name))
413
421
        client.add_expected_call(
414
422
            'Branch.get_stacked_on_url', ('~hello/',),
415
423
            'error', ('NotStacked',))
419
427
        client.finished_test()
420
428
 
421
429
    def check_open_repository(self, rich_root, subtrees, external_lookup='no'):
 
430
        reference_format = self.get_repo_format()
 
431
        network_name = reference_format.network_name()
422
432
        transport = MemoryTransport()
423
433
        transport.mkdir('quack')
424
434
        transport = transport.clone('quack')
432
442
            subtree_response = 'no'
433
443
        client = FakeClient(transport.base)
434
444
        client.add_success_response(
435
 
            'ok', '', rich_response, subtree_response, external_lookup)
 
445
            'ok', '', rich_response, subtree_response, external_lookup,
 
446
            network_name)
436
447
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
437
448
            _client=client)
438
449
        result = bzrdir.open_repository()
439
450
        self.assertEqual(
440
 
            [('call', 'BzrDir.find_repositoryV2', ('quack/',))],
 
451
            [('call', 'BzrDir.find_repositoryV3', ('quack/',))],
441
452
            client._calls)
442
453
        self.assertIsInstance(result, RemoteRepository)
443
454
        self.assertEqual(bzrdir, result.bzrdir)
534
545
 
535
546
class TestBzrDirOpenRepository(TestRemote):
536
547
 
537
 
    def get_repo_format(self):
538
 
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
539
 
        return reference_bzrdir_format.repository_format
540
 
 
541
548
    def test_backwards_compat_1_2_3(self):
542
549
        # fallback all the way to the first version.
543
550
        reference_format = self.get_repo_format()
699
706
        self.assertEqual((2, revid), result)
700
707
 
701
708
 
702
 
class TestBranch_get_stacked_on_url(tests.TestCaseWithMemoryTransport):
 
709
class TestBranch_get_stacked_on_url(TestRemote):
703
710
    """Test Branch._get_stacked_on_url rpc"""
704
711
 
705
712
    def test_get_stacked_on_invalid_url(self):
739
746
            'BzrDir.open_branch', ('stacked/',),
740
747
            'success', ('ok', ''))
741
748
        client.add_expected_call(
742
 
            'BzrDir.find_repositoryV2', ('stacked/',),
743
 
            'success', ('ok', '', 'no', 'no', 'no'))
 
749
            'BzrDir.find_repositoryV3', ('stacked/',),
 
750
            'success', ('ok', '', 'no', 'no', 'no',
 
751
                stacked_branch.repository._format.network_name()))
744
752
        # called twice, once from constructor and then again by us
745
753
        client.add_expected_call(
746
754
            'Branch.get_stacked_on_url', ('stacked/',),
766
774
        base_branch = self.make_branch('base', format='1.6')
767
775
        stacked_branch = self.make_branch('stacked', format='1.6')
768
776
        stacked_branch.set_stacked_on_url('../base')
 
777
        reference_format = self.get_repo_format()
 
778
        network_name = reference_format.network_name()
769
779
        client = FakeClient(self.get_url())
770
780
        client.add_expected_call(
771
781
            'BzrDir.open_branch', ('stacked/',),
772
782
            'success', ('ok', ''))
773
783
        client.add_expected_call(
774
 
            'BzrDir.find_repositoryV2', ('stacked/',),
775
 
            'success', ('ok', '', 'no', 'no', 'no'))
 
784
            'BzrDir.find_repositoryV3', ('stacked/',),
 
785
            'success', ('ok', '', 'no', 'no', 'no', network_name))
776
786
        # called twice, once from constructor and then again by us
777
787
        client.add_expected_call(
778
788
            'Branch.get_stacked_on_url', ('stacked/',),