~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-03-13 03:56:23 UTC
  • mfrom: (4118.1.5 fix-stackable-remote-repo)
  • Revision ID: pqm@pqm.ubuntu.com-20090313035623-vn0615cs6bd6590e
(andrew) Fix performance regression (many small round-trips) when
        pushing to a remote pack, and improve some tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
from bzrlib.smart import server, medium
52
52
from bzrlib.smart.client import _SmartClient
53
53
from bzrlib.symbol_versioning import one_four
 
54
from bzrlib.tests import (
 
55
    condition_isinstance,
 
56
    split_suite_by_condition,
 
57
    multiply_tests,
 
58
    )
54
59
from bzrlib.transport import get_transport, http
55
60
from bzrlib.transport.memory import MemoryTransport
56
61
from bzrlib.transport.remote import (
59
64
    RemoteTCPTransport,
60
65
)
61
66
 
 
67
def load_tests(standard_tests, module, loader):
 
68
    to_adapt, result = split_suite_by_condition(
 
69
        standard_tests, condition_isinstance(BasicRemoteObjectTests))
 
70
    smart_server_version_scenarios = [
 
71
        ('HPSS-v2', 
 
72
            {'transport_server': server.SmartTCPServer_for_testing_v2_only}),
 
73
        ('HPSS-v3', 
 
74
            {'transport_server': server.SmartTCPServer_for_testing})]
 
75
    return multiply_tests(to_adapt, smart_server_version_scenarios, result)
 
76
 
62
77
 
63
78
class BasicRemoteObjectTests(tests.TestCaseWithTransport):
64
79
 
65
80
    def setUp(self):
66
 
        self.transport_server = server.SmartTCPServer_for_testing
67
81
        super(BasicRemoteObjectTests, self).setUp()
68
82
        self.transport = self.get_transport()
69
83
        # make a branch that can be opened over the smart transport
123
137
        b = BzrDir.open_from_transport(t.clone('stackable')).open_branch()
124
138
        self.assertTrue(b._format.supports_stacking())
125
139
 
 
140
    def test_remote_repo_format_supports_external_references(self):
 
141
        t = self.transport
 
142
        bd = self.make_bzrdir('unstackable', format='pack-0.92')
 
143
        r = bd.create_repository()
 
144
        self.assertFalse(r._format.supports_external_lookups)
 
145
        r = BzrDir.open_from_transport(t.clone('unstackable')).open_repository()
 
146
        self.assertFalse(r._format.supports_external_lookups)
 
147
        bd = self.make_bzrdir('stackable', format='1.9')
 
148
        r = bd.create_repository()
 
149
        self.assertTrue(r._format.supports_external_lookups)
 
150
        r = BzrDir.open_from_transport(t.clone('stackable')).open_repository()
 
151
        self.assertTrue(r._format.supports_external_lookups)
 
152
 
126
153
 
127
154
class FakeProtocol(object):
128
155
    """Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
876
903
            'success', ('ok', vfs_url))
877
904
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
878
905
            _client=client)
879
 
        branch = RemoteBranch(bzrdir, RemoteRepository(bzrdir, None),
 
906
        repo_fmt = remote.RemoteRepositoryFormat()
 
907
        repo_fmt._custom_format = stacked_branch.repository._format
 
908
        branch = RemoteBranch(bzrdir, RemoteRepository(bzrdir, repo_fmt),
880
909
            _client=client)
881
910
        result = branch.get_stacked_on_url()
882
911
        self.assertEqual(vfs_url, result)
893
922
            'success', ('branch', branch_network_name))
894
923
        client.add_expected_call(
895
924
            'BzrDir.find_repositoryV3', ('stacked/',),
896
 
            'success', ('ok', '', 'no', 'no', 'no',
 
925
            'success', ('ok', '', 'no', 'no', 'yes',
897
926
                stacked_branch.repository._format.network_name()))
898
927
        # called twice, once from constructor and then again by us
899
928
        client.add_expected_call(
929
958
            'success', ('branch', branch_network_name))
930
959
        client.add_expected_call(
931
960
            'BzrDir.find_repositoryV3', ('stacked/',),
932
 
            'success', ('ok', '', 'no', 'no', 'no', network_name))
 
961
            'success', ('ok', '', 'no', 'no', 'yes', network_name))
933
962
        # called twice, once from constructor and then again by us
934
963
        client.add_expected_call(
935
964
            'Branch.get_stacked_on_url', ('stacked/',),