~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Martin Pool
  • Date: 2009-11-16 02:26:32 UTC
  • mto: This revision was merged to the branch mainline in revision 4880.
  • Revision ID: mbp@sourcefrog.net-20091116022632-261trs2osy8oupe3
Convert version-info to use TextUIOutputStream

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
from cStringIO import StringIO
28
28
 
29
29
from bzrlib import (
30
 
    branch,
31
30
    bzrdir,
32
31
    config,
33
32
    errors,
37
36
    pack,
38
37
    remote,
39
38
    repository,
 
39
    smart,
40
40
    tests,
41
41
    treebuilder,
42
42
    urlutils,
61
61
    condition_isinstance,
62
62
    split_suite_by_condition,
63
63
    multiply_tests,
 
64
    KnownFailure,
64
65
    )
65
 
from bzrlib.transport import get_transport
 
66
from bzrlib.transport import get_transport, http
66
67
from bzrlib.transport.memory import MemoryTransport
67
68
from bzrlib.transport.remote import (
68
69
    RemoteTransport,
134
135
        b = BzrDir.open_from_transport(self.transport).open_branch()
135
136
        self.assertStartsWith(str(b), 'RemoteBranch(')
136
137
 
137
 
    def test_remote_bzrdir_repr(self):
138
 
        b = BzrDir.open_from_transport(self.transport)
139
 
        self.assertStartsWith(str(b), 'RemoteBzrDir(')
140
 
 
141
138
    def test_remote_branch_format_supports_stacking(self):
142
139
        t = self.transport
143
140
        self.make_branch('unstackable', format='pack-0.92')
444
441
            'BzrDir.cloning_metadir', ('quack/', 'False'),
445
442
            'error', ('BranchReference',)),
446
443
        client.add_expected_call(
447
 
            'BzrDir.open_branchV3', ('quack/',),
 
444
            'BzrDir.open_branchV2', ('quack/',),
448
445
            'success', ('ref', self.get_url('referenced'))),
449
446
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
450
447
            _client=client)
535
532
        self.make_branch('.')
536
533
        a_dir = BzrDir.open(self.get_url('.'))
537
534
        self.reset_smart_call_log()
538
 
        verb = 'BzrDir.open_branchV3'
 
535
        verb = 'BzrDir.open_branchV2'
539
536
        self.disable_verb(verb)
540
537
        format = a_dir.open_branch()
541
538
        call_count = len([call for call in self.hpss_calls if
551
548
        transport = transport.clone('quack')
552
549
        client = FakeClient(transport.base)
553
550
        client.add_expected_call(
554
 
            'BzrDir.open_branchV3', ('quack/',),
 
551
            'BzrDir.open_branchV2', ('quack/',),
555
552
            'success', ('branch', branch_network_name))
556
553
        client.add_expected_call(
557
554
            'BzrDir.find_repositoryV3', ('quack/',),
576
573
            _client=client)
577
574
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
578
575
        self.assertEqual(
579
 
            [('call', 'BzrDir.open_branchV3', ('quack/',))],
 
576
            [('call', 'BzrDir.open_branchV2', ('quack/',))],
580
577
            client._calls)
581
578
 
582
579
    def test__get_tree_branch(self):
606
603
        network_name = reference_format.network_name()
607
604
        branch_network_name = self.get_branch_format().network_name()
608
605
        client.add_expected_call(
609
 
            'BzrDir.open_branchV3', ('~hello/',),
 
606
            'BzrDir.open_branchV2', ('~hello/',),
610
607
            'success', ('branch', branch_network_name))
611
608
        client.add_expected_call(
612
609
            'BzrDir.find_repositoryV3', ('~hello/',),
1194
1191
        client = FakeClient(self.get_url())
1195
1192
        branch_network_name = self.get_branch_format().network_name()
1196
1193
        client.add_expected_call(
1197
 
            'BzrDir.open_branchV3', ('stacked/',),
 
1194
            'BzrDir.open_branchV2', ('stacked/',),
1198
1195
            'success', ('branch', branch_network_name))
1199
1196
        client.add_expected_call(
1200
1197
            'BzrDir.find_repositoryV3', ('stacked/',),
1230
1227
        client = FakeClient(self.get_url())
1231
1228
        branch_network_name = self.get_branch_format().network_name()
1232
1229
        client.add_expected_call(
1233
 
            'BzrDir.open_branchV3', ('stacked/',),
 
1230
            'BzrDir.open_branchV2', ('stacked/',),
1234
1231
            'success', ('branch', branch_network_name))
1235
1232
        client.add_expected_call(
1236
1233
            'BzrDir.find_repositoryV3', ('stacked/',),
1785
1782
        return repo, client
1786
1783
 
1787
1784
 
1788
 
def remoted_description(format):
1789
 
    return 'Remote: ' + format.get_format_description()
1790
 
 
1791
 
 
1792
 
class TestBranchFormat(tests.TestCase):
1793
 
 
1794
 
    def test_get_format_description(self):
1795
 
        remote_format = RemoteBranchFormat()
1796
 
        real_format = branch.BranchFormat.get_default_format()
1797
 
        remote_format._network_name = real_format.network_name()
1798
 
        self.assertEqual(remoted_description(real_format),
1799
 
            remote_format.get_format_description())
1800
 
 
1801
 
 
1802
1785
class TestRepositoryFormat(TestRemoteRepository):
1803
1786
 
1804
1787
    def test_fast_delta(self):
1811
1794
        false_format._network_name = false_name
1812
1795
        self.assertEqual(False, false_format.fast_deltas)
1813
1796
 
1814
 
    def test_get_format_description(self):
1815
 
        remote_repo_format = RemoteRepositoryFormat()
1816
 
        real_format = repository.RepositoryFormat.get_default_format()
1817
 
        remote_repo_format._network_name = real_format.network_name()
1818
 
        self.assertEqual(remoted_description(real_format),
1819
 
            remote_repo_format.get_format_description())
1820
 
 
1821
1797
 
1822
1798
class TestRepositoryGatherStats(TestRemoteRepository):
1823
1799
 
2008
1984
        self.assertLength(1, self.hpss_calls)
2009
1985
 
2010
1986
    def disableExtraResults(self):
2011
 
        self.overrideAttr(SmartServerRepositoryGetParentMap,
2012
 
                          'no_extra_results', True)
 
1987
        old_flag = SmartServerRepositoryGetParentMap.no_extra_results
 
1988
        SmartServerRepositoryGetParentMap.no_extra_results = True
 
1989
        def reset_values():
 
1990
            SmartServerRepositoryGetParentMap.no_extra_results = old_flag
 
1991
        self.addCleanup(reset_values)
2013
1992
 
2014
1993
    def test_null_cached_missing_and_stop_key(self):
2015
1994
        self.setup_smart_server_with_call_log()
2776
2755
        expected_error = errors.NotBranchError(path=bzrdir.root_transport.base)
2777
2756
        self.assertEqual(expected_error, translated_error)
2778
2757
 
2779
 
    def test_nobranch_one_arg(self):
2780
 
        bzrdir = self.make_bzrdir('')
2781
 
        translated_error = self.translateTuple(
2782
 
            ('nobranch', 'extra detail'), bzrdir=bzrdir)
2783
 
        expected_error = errors.NotBranchError(
2784
 
            path=bzrdir.root_transport.base,
2785
 
            detail='extra detail')
2786
 
        self.assertEqual(expected_error, translated_error)
2787
 
 
2788
2758
    def test_LockContention(self):
2789
2759
        translated_error = self.translateTuple(('LockContention',))
2790
2760
        expected_error = errors.LockContention('(remote lock)')
2903
2873
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2904
2874
        # been muttered to the log file for developer to look at.
2905
2875
        self.assertContainsRe(
2906
 
            self.get_log(),
 
2876
            self._get_log(keep_log_file=True),
2907
2877
            "Missing key 'branch' in context")
2908
2878
 
2909
2879
    def test_path_missing(self):
2917
2887
        self.assertEqual(server_error, translated_error)
2918
2888
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2919
2889
        # been muttered to the log file for developer to look at.
2920
 
        self.assertContainsRe(self.get_log(), "Missing key 'path' in context")
 
2890
        self.assertContainsRe(
 
2891
            self._get_log(keep_log_file=True), "Missing key 'path' in context")
2921
2892
 
2922
2893
 
2923
2894
class TestStacking(tests.TestCaseWithTransport):
3051
3022
            local_tree.commit('more local changes are better')
3052
3023
            branch = Branch.open(self.get_url('tree3'))
3053
3024
            branch.lock_read()
3054
 
            self.addCleanup(branch.unlock)
3055
3025
            return None, branch
3056
3026
        rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered',
3057
3027
            branch_factory=make_stacked_stacked)