~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_remote.py

  • Committer: John Arbash Meinel
  • Date: 2010-02-17 17:11:16 UTC
  • mfrom: (4797.2.17 2.1)
  • mto: (4797.2.18 2.1)
  • mto: This revision was merged to the branch mainline in revision 5055.
  • Revision ID: john@arbash-meinel.com-20100217171116-h7t9223ystbnx5h8
merge bzr.2.1 in preparation for NEWS entry.

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
27
27
from cStringIO import StringIO
28
28
 
29
29
from bzrlib import (
 
30
    branch,
30
31
    bzrdir,
31
32
    config,
32
33
    errors,
36
37
    pack,
37
38
    remote,
38
39
    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,
65
64
    )
66
 
from bzrlib.transport import get_transport, http
 
65
from bzrlib.transport import get_transport
67
66
from bzrlib.transport.memory import MemoryTransport
68
67
from bzrlib.transport.remote import (
69
68
    RemoteTransport,
135
134
        b = BzrDir.open_from_transport(self.transport).open_branch()
136
135
        self.assertStartsWith(str(b), 'RemoteBranch(')
137
136
 
 
137
    def test_remote_bzrdir_repr(self):
 
138
        b = BzrDir.open_from_transport(self.transport)
 
139
        self.assertStartsWith(str(b), 'RemoteBzrDir(')
 
140
 
138
141
    def test_remote_branch_format_supports_stacking(self):
139
142
        t = self.transport
140
143
        self.make_branch('unstackable', format='pack-0.92')
441
444
            'BzrDir.cloning_metadir', ('quack/', 'False'),
442
445
            'error', ('BranchReference',)),
443
446
        client.add_expected_call(
444
 
            'BzrDir.open_branchV2', ('quack/',),
 
447
            'BzrDir.open_branchV3', ('quack/',),
445
448
            'success', ('ref', self.get_url('referenced'))),
446
449
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
447
450
            _client=client)
532
535
        self.make_branch('.')
533
536
        a_dir = BzrDir.open(self.get_url('.'))
534
537
        self.reset_smart_call_log()
535
 
        verb = 'BzrDir.open_branchV2'
 
538
        verb = 'BzrDir.open_branchV3'
536
539
        self.disable_verb(verb)
537
540
        format = a_dir.open_branch()
538
541
        call_count = len([call for call in self.hpss_calls if
548
551
        transport = transport.clone('quack')
549
552
        client = FakeClient(transport.base)
550
553
        client.add_expected_call(
551
 
            'BzrDir.open_branchV2', ('quack/',),
 
554
            'BzrDir.open_branchV3', ('quack/',),
552
555
            'success', ('branch', branch_network_name))
553
556
        client.add_expected_call(
554
557
            'BzrDir.find_repositoryV3', ('quack/',),
573
576
            _client=client)
574
577
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
575
578
        self.assertEqual(
576
 
            [('call', 'BzrDir.open_branchV2', ('quack/',))],
 
579
            [('call', 'BzrDir.open_branchV3', ('quack/',))],
577
580
            client._calls)
578
581
 
579
582
    def test__get_tree_branch(self):
603
606
        network_name = reference_format.network_name()
604
607
        branch_network_name = self.get_branch_format().network_name()
605
608
        client.add_expected_call(
606
 
            'BzrDir.open_branchV2', ('~hello/',),
 
609
            'BzrDir.open_branchV3', ('~hello/',),
607
610
            'success', ('branch', branch_network_name))
608
611
        client.add_expected_call(
609
612
            'BzrDir.find_repositoryV3', ('~hello/',),
1191
1194
        client = FakeClient(self.get_url())
1192
1195
        branch_network_name = self.get_branch_format().network_name()
1193
1196
        client.add_expected_call(
1194
 
            'BzrDir.open_branchV2', ('stacked/',),
 
1197
            'BzrDir.open_branchV3', ('stacked/',),
1195
1198
            'success', ('branch', branch_network_name))
1196
1199
        client.add_expected_call(
1197
1200
            'BzrDir.find_repositoryV3', ('stacked/',),
1227
1230
        client = FakeClient(self.get_url())
1228
1231
        branch_network_name = self.get_branch_format().network_name()
1229
1232
        client.add_expected_call(
1230
 
            'BzrDir.open_branchV2', ('stacked/',),
 
1233
            'BzrDir.open_branchV3', ('stacked/',),
1231
1234
            'success', ('branch', branch_network_name))
1232
1235
        client.add_expected_call(
1233
1236
            'BzrDir.find_repositoryV3', ('stacked/',),
1782
1785
        return repo, client
1783
1786
 
1784
1787
 
 
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
 
1785
1802
class TestRepositoryFormat(TestRemoteRepository):
1786
1803
 
1787
1804
    def test_fast_delta(self):
1794
1811
        false_format._network_name = false_name
1795
1812
        self.assertEqual(False, false_format.fast_deltas)
1796
1813
 
 
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
 
1797
1821
 
1798
1822
class TestRepositoryGatherStats(TestRemoteRepository):
1799
1823
 
2755
2779
        expected_error = errors.NotBranchError(path=bzrdir.root_transport.base)
2756
2780
        self.assertEqual(expected_error, translated_error)
2757
2781
 
 
2782
    def test_nobranch_one_arg(self):
 
2783
        bzrdir = self.make_bzrdir('')
 
2784
        translated_error = self.translateTuple(
 
2785
            ('nobranch', 'extra detail'), bzrdir=bzrdir)
 
2786
        expected_error = errors.NotBranchError(
 
2787
            path=bzrdir.root_transport.base,
 
2788
            detail='extra detail')
 
2789
        self.assertEqual(expected_error, translated_error)
 
2790
 
2758
2791
    def test_LockContention(self):
2759
2792
        translated_error = self.translateTuple(('LockContention',))
2760
2793
        expected_error = errors.LockContention('(remote lock)')
2873
2906
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2874
2907
        # been muttered to the log file for developer to look at.
2875
2908
        self.assertContainsRe(
2876
 
            self._get_log(keep_log_file=True),
 
2909
            self.get_log(),
2877
2910
            "Missing key 'branch' in context")
2878
2911
 
2879
2912
    def test_path_missing(self):
2887
2920
        self.assertEqual(server_error, translated_error)
2888
2921
        # In addition to re-raising ErrorFromSmartServer, some debug info has
2889
2922
        # been muttered to the log file for developer to look at.
2890
 
        self.assertContainsRe(
2891
 
            self._get_log(keep_log_file=True), "Missing key 'path' in context")
 
2923
        self.assertContainsRe(self.get_log(), "Missing key 'path' in context")
2892
2924
 
2893
2925
 
2894
2926
class TestStacking(tests.TestCaseWithTransport):
3022
3054
            local_tree.commit('more local changes are better')
3023
3055
            branch = Branch.open(self.get_url('tree3'))
3024
3056
            branch.lock_read()
 
3057
            self.addCleanup(branch.unlock)
3025
3058
            return None, branch
3026
3059
        rev_ord, expected_revs = self.get_ordered_revs('1.9', 'unordered',
3027
3060
            branch_factory=make_stacked_stacked)