/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: Jelmer Vernooij
  • Date: 2010-03-21 21:39:33 UTC
  • mfrom: (5102 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5143.
  • Revision ID: jelmer@samba.org-20100321213933-fexeh9zcoz8oaju2
merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2008, 2009 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
54
54
    )
55
55
from bzrlib.repofmt import groupcompress_repo, pack_repo
56
56
from bzrlib.revision import NULL_REVISION
57
 
from bzrlib.smart import server, medium
 
57
from bzrlib.smart import medium
58
58
from bzrlib.smart.client import _SmartClient
59
59
from bzrlib.smart.repository import SmartServerRepositoryGetParentMap
60
60
from bzrlib.tests import (
61
61
    condition_isinstance,
62
62
    split_suite_by_condition,
63
63
    multiply_tests,
 
64
    test_server,
64
65
    )
65
66
from bzrlib.transport import get_transport
66
67
from bzrlib.transport.memory import MemoryTransport
75
76
        standard_tests, condition_isinstance(BasicRemoteObjectTests))
76
77
    smart_server_version_scenarios = [
77
78
        ('HPSS-v2',
78
 
            {'transport_server': server.SmartTCPServer_for_testing_v2_only}),
 
79
         {'transport_server': test_server.SmartTCPServer_for_testing_v2_only}),
79
80
        ('HPSS-v3',
80
 
            {'transport_server': server.SmartTCPServer_for_testing})]
 
81
         {'transport_server': test_server.SmartTCPServer_for_testing})]
81
82
    return multiply_tests(to_adapt, smart_server_version_scenarios, result)
82
83
 
83
84
 
134
135
        b = BzrDir.open_from_transport(self.transport).open_branch()
135
136
        self.assertStartsWith(str(b), 'RemoteBranch(')
136
137
 
 
138
    def test_remote_bzrdir_repr(self):
 
139
        b = BzrDir.open_from_transport(self.transport)
 
140
        self.assertStartsWith(str(b), 'RemoteBzrDir(')
 
141
 
137
142
    def test_remote_branch_format_supports_stacking(self):
138
143
        t = self.transport
139
144
        self.make_branch('unstackable', format='pack-0.92')
440
445
            'BzrDir.cloning_metadir', ('quack/', 'False'),
441
446
            'error', ('BranchReference',)),
442
447
        client.add_expected_call(
443
 
            'BzrDir.open_branchV2', ('quack/',),
 
448
            'BzrDir.open_branchV3', ('quack/',),
444
449
            'success', ('ref', self.get_url('referenced'))),
445
450
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
446
451
            _client=client)
531
536
        self.make_branch('.')
532
537
        a_dir = BzrDir.open(self.get_url('.'))
533
538
        self.reset_smart_call_log()
534
 
        verb = 'BzrDir.open_branchV2'
 
539
        verb = 'BzrDir.open_branchV3'
535
540
        self.disable_verb(verb)
536
541
        format = a_dir.open_branch()
537
542
        call_count = len([call for call in self.hpss_calls if
547
552
        transport = transport.clone('quack')
548
553
        client = FakeClient(transport.base)
549
554
        client.add_expected_call(
550
 
            'BzrDir.open_branchV2', ('quack/',),
 
555
            'BzrDir.open_branchV3', ('quack/',),
551
556
            'success', ('branch', branch_network_name))
552
557
        client.add_expected_call(
553
558
            'BzrDir.find_repositoryV3', ('quack/',),
572
577
            _client=client)
573
578
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
574
579
        self.assertEqual(
575
 
            [('call', 'BzrDir.open_branchV2', ('quack/',))],
 
580
            [('call', 'BzrDir.open_branchV3', ('quack/',))],
576
581
            client._calls)
577
582
 
578
583
    def test__get_tree_branch(self):
602
607
        network_name = reference_format.network_name()
603
608
        branch_network_name = self.get_branch_format().network_name()
604
609
        client.add_expected_call(
605
 
            'BzrDir.open_branchV2', ('~hello/',),
 
610
            'BzrDir.open_branchV3', ('~hello/',),
606
611
            'success', ('branch', branch_network_name))
607
612
        client.add_expected_call(
608
613
            'BzrDir.find_repositoryV3', ('~hello/',),
1190
1195
        client = FakeClient(self.get_url())
1191
1196
        branch_network_name = self.get_branch_format().network_name()
1192
1197
        client.add_expected_call(
1193
 
            'BzrDir.open_branchV2', ('stacked/',),
 
1198
            'BzrDir.open_branchV3', ('stacked/',),
1194
1199
            'success', ('branch', branch_network_name))
1195
1200
        client.add_expected_call(
1196
1201
            'BzrDir.find_repositoryV3', ('stacked/',),
1226
1231
        client = FakeClient(self.get_url())
1227
1232
        branch_network_name = self.get_branch_format().network_name()
1228
1233
        client.add_expected_call(
1229
 
            'BzrDir.open_branchV2', ('stacked/',),
 
1234
            'BzrDir.open_branchV3', ('stacked/',),
1230
1235
            'success', ('branch', branch_network_name))
1231
1236
        client.add_expected_call(
1232
1237
            'BzrDir.find_repositoryV3', ('stacked/',),
2004
2009
        self.assertLength(1, self.hpss_calls)
2005
2010
 
2006
2011
    def disableExtraResults(self):
2007
 
        old_flag = SmartServerRepositoryGetParentMap.no_extra_results
2008
 
        SmartServerRepositoryGetParentMap.no_extra_results = True
2009
 
        def reset_values():
2010
 
            SmartServerRepositoryGetParentMap.no_extra_results = old_flag
2011
 
        self.addCleanup(reset_values)
 
2012
        self.overrideAttr(SmartServerRepositoryGetParentMap,
 
2013
                          'no_extra_results', True)
2012
2014
 
2013
2015
    def test_null_cached_missing_and_stop_key(self):
2014
2016
        self.setup_smart_server_with_call_log()
2073
2075
 
2074
2076
    def test_allows_new_revisions(self):
2075
2077
        """get_parent_map's results can be updated by commit."""
2076
 
        smart_server = server.SmartTCPServer_for_testing()
 
2078
        smart_server = test_server.SmartTCPServer_for_testing()
2077
2079
        self.start_server(smart_server)
2078
2080
        self.make_branch('branch')
2079
2081
        branch = Branch.open(smart_server.get_url() + '/branch')
2621
2623
    """RemoteRepository.copy_content_into optimizations"""
2622
2624
 
2623
2625
    def test_copy_content_remote_to_local(self):
2624
 
        self.transport_server = server.SmartTCPServer_for_testing
 
2626
        self.transport_server = test_server.SmartTCPServer_for_testing
2625
2627
        src_repo = self.make_repository('repo1')
2626
2628
        src_repo = repository.Repository.open(self.get_url('repo1'))
2627
2629
        # At the moment the tarball-based copy_content_into can't write back
2775
2777
        expected_error = errors.NotBranchError(path=bzrdir.root_transport.base)
2776
2778
        self.assertEqual(expected_error, translated_error)
2777
2779
 
 
2780
    def test_nobranch_one_arg(self):
 
2781
        bzrdir = self.make_bzrdir('')
 
2782
        translated_error = self.translateTuple(
 
2783
            ('nobranch', 'extra detail'), bzrdir=bzrdir)
 
2784
        expected_error = errors.NotBranchError(
 
2785
            path=bzrdir.root_transport.base,
 
2786
            detail='extra detail')
 
2787
        self.assertEqual(expected_error, translated_error)
 
2788
 
2778
2789
    def test_LockContention(self):
2779
2790
        translated_error = self.translateTuple(('LockContention',))
2780
2791
        expected_error = errors.LockContention('(remote lock)')
2893
2904
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2894
2905
        # been muttered to the log file for developer to look at.
2895
2906
        self.assertContainsRe(
2896
 
            self._get_log(keep_log_file=True),
 
2907
            self.get_log(),
2897
2908
            "Missing key 'branch' in context")
2898
2909
 
2899
2910
    def test_path_missing(self):
2907
2918
        self.assertEqual(server_error, translated_error)
2908
2919
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2909
2920
        # been muttered to the log file for developer to look at.
2910
 
        self.assertContainsRe(
2911
 
            self._get_log(keep_log_file=True), "Missing key 'path' in context")
 
2921
        self.assertContainsRe(self.get_log(), "Missing key 'path' in context")
2912
2922
 
2913
2923
 
2914
2924
class TestStacking(tests.TestCaseWithTransport):
2932
2942
        stacked_branch = self.make_branch('stacked', format='1.9')
2933
2943
        stacked_branch.set_stacked_on_url('../base')
2934
2944
        # start a server looking at this
2935
 
        smart_server = server.SmartTCPServer_for_testing()
 
2945
        smart_server = test_server.SmartTCPServer_for_testing()
2936
2946
        self.start_server(smart_server)
2937
2947
        remote_bzrdir = BzrDir.open(smart_server.get_url() + '/stacked')
2938
2948
        # can get its branch and repository
3094
3104
        super(TestRemoteBranchEffort, self).setUp()
3095
3105
        # Create a smart server that publishes whatever the backing VFS server
3096
3106
        # does.
3097
 
        self.smart_server = server.SmartTCPServer_for_testing()
 
3107
        self.smart_server = test_server.SmartTCPServer_for_testing()
3098
3108
        self.start_server(self.smart_server, self.get_server())
3099
3109
        # Log all HPSS calls into self.hpss_calls.
3100
3110
        _SmartClient.hooks.install_named_hook(