/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: 2009-02-25 14:36:59 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4049.
  • Revision ID: jelmer@samba.org-20090225143659-vx6cbqtmyicuzfyf
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 
19
19
These are proxy objects which act on remote objects by sending messages
20
20
through a smart client.  The proxies are to be created when attempting to open
21
 
the object given a transport that supports smartserver rpc operations. 
 
21
the object given a transport that supports smartserver rpc operations.
22
22
 
23
23
These tests correspond to tests.test_smart, which exercises the server side.
24
24
"""
34
34
    pack,
35
35
    remote,
36
36
    repository,
 
37
    smart,
37
38
    tests,
38
39
    urlutils,
39
40
    )
72
73
        tests.TestCaseWithTransport.tearDown(self)
73
74
 
74
75
    def test_create_remote_bzrdir(self):
75
 
        b = remote.RemoteBzrDir(self.transport)
 
76
        b = remote.RemoteBzrDir(self.transport, remote.RemoteBzrDirFormat())
76
77
        self.assertIsInstance(b, BzrDir)
77
78
 
78
79
    def test_open_remote_branch(self):
79
80
        # open a standalone branch in the working directory
80
 
        b = remote.RemoteBzrDir(self.transport)
 
81
        b = remote.RemoteBzrDir(self.transport, remote.RemoteBzrDirFormat())
81
82
        branch = b.open_branch()
82
83
        self.assertIsInstance(branch, Branch)
83
84
 
113
114
        self.assertStartsWith(str(b), 'RemoteBranch(')
114
115
 
115
116
 
116
 
class FakeRemoteTransport(object):
117
 
    """This class provides the minimum support for use in place of a RemoteTransport.
118
 
    
119
 
    It doesn't actually transmit requests, but rather expects them to be
120
 
    handled by a FakeClient which holds canned responses.  It does not allow
121
 
    any vfs access, therefore is not suitable for testing any operation that
122
 
    will fallback to vfs access.  Backing the test by an instance of this
123
 
    class guarantees that it's - done using non-vfs operations.
124
 
    """
125
 
 
126
 
    _default_url = 'fakeremotetransport://host/path/'
127
 
 
128
 
    def __init__(self, url=None):
129
 
        if url is None:
130
 
            url = self._default_url
131
 
        self.base = url
132
 
 
133
 
    def __repr__(self):
134
 
        return "%r(%r)" % (self.__class__.__name__,
135
 
            self.base)
136
 
 
137
 
    def clone(self, relpath):
138
 
        return FakeRemoteTransport(urlutils.join(self.base, relpath))
139
 
 
140
 
    def get(self, relpath):
141
 
        # only get is specifically stubbed out, because it's usually the first
142
 
        # thing we do.  anything else will fail with an AttributeError.
143
 
        raise AssertionError("%r doesn't support file access to %r"
144
 
            % (self, relpath))
145
 
 
146
 
 
147
 
 
148
117
class FakeProtocol(object):
149
118
    """Lookalike SmartClientRequestProtocolOne allowing body reading tests."""
150
119
 
170
139
 
171
140
class FakeClient(_SmartClient):
172
141
    """Lookalike for _SmartClient allowing testing."""
173
 
    
 
142
 
174
143
    def __init__(self, fake_medium_base='fake base'):
175
144
        """Create a FakeClient."""
176
145
        self.responses = []
178
147
        self.expecting_body = False
179
148
        # if non-None, this is the list of expected calls, with only the
180
149
        # method name and arguments included.  the body might be hard to
181
 
        # compute so is not included
 
150
        # compute so is not included. If a call is None, that call can
 
151
        # be anything.
182
152
        self._expected_calls = None
183
153
        _SmartClient.__init__(self, FakeMedium(self._calls, fake_medium_base))
184
154
 
194
164
 
195
165
    def add_success_response_with_body(self, body, *args):
196
166
        self.responses.append(('success', args, body))
 
167
        if self._expected_calls is not None:
 
168
            self._expected_calls.append(None)
197
169
 
198
170
    def add_error_response(self, *args):
199
171
        self.responses.append(('error', args))
228
200
            raise AssertionError("%r didn't expect any more calls "
229
201
                "but got %r%r"
230
202
                % (self, method, args,))
 
203
        if next_call is None:
 
204
            return
231
205
        if method != next_call[0] or args != next_call[1]:
232
206
            raise AssertionError("%r expected %r%r "
233
207
                "but got %r%r"
286
260
        self.assertTrue(result)
287
261
 
288
262
 
 
263
class TestRemote(tests.TestCaseWithMemoryTransport):
 
264
 
 
265
    def disable_verb(self, verb):
 
266
        """Disable a verb for one test."""
 
267
        request_handlers = smart.request.request_handlers
 
268
        orig_method = request_handlers.get(verb)
 
269
        request_handlers.remove(verb)
 
270
        def restoreVerb():
 
271
            request_handlers.register(verb, orig_method)
 
272
        self.addCleanup(restoreVerb)
 
273
 
 
274
 
289
275
class Test_ClientMedium_remote_path_from_transport(tests.TestCase):
290
276
    """Tests for the behaviour of client_medium.remote_path_from_transport."""
291
277
 
318
304
        cloned_transport = base_transport.clone(relpath)
319
305
        result = client_medium.remote_path_from_transport(cloned_transport)
320
306
        self.assertEqual(expected, result)
321
 
        
 
307
 
322
308
    def test_remote_path_from_transport_http(self):
323
309
        """Remote paths for HTTP transports are calculated differently to other
324
310
        transports.  They are just relative to the client base, not the root
340
326
        """
341
327
        client_medium = medium.SmartClientMedium('dummy base')
342
328
        self.assertFalse(client_medium._is_remote_before((99, 99)))
343
 
    
 
329
 
344
330
    def test__remember_remote_is_before(self):
345
331
        """Calling _remember_remote_is_before ratchets down the known remote
346
332
        version.
375
361
        client.add_expected_call(
376
362
            'Branch.get_stacked_on_url', ('quack/',),
377
363
            'error', ('NotStacked',))
378
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
364
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
365
            _client=client)
379
366
        result = bzrdir.open_branch()
380
367
        self.assertIsInstance(result, RemoteBranch)
381
368
        self.assertEqual(bzrdir, result.bzrdir)
387
374
        transport = transport.clone('quack')
388
375
        client = FakeClient(transport.base)
389
376
        client.add_error_response('nobranch')
390
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
377
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
378
            _client=client)
391
379
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
392
380
        self.assertEqual(
393
381
            [('call', 'BzrDir.open_branch', ('quack/',))],
403
391
        transport = MemoryTransport()
404
392
        # no requests on the network - catches other api calls being made.
405
393
        client = FakeClient(transport.base)
406
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
394
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
395
            _client=client)
407
396
        # patch the open_branch call to record that it was called.
408
397
        bzrdir.open_branch = open_branch
409
398
        self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch())
424
413
        client.add_expected_call(
425
414
            'Branch.get_stacked_on_url', ('~hello/',),
426
415
            'error', ('NotStacked',))
427
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
416
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
417
            _client=client)
428
418
        result = bzrdir.open_branch()
429
419
        client.finished_test()
430
420
 
443
433
        client = FakeClient(transport.base)
444
434
        client.add_success_response(
445
435
            'ok', '', rich_response, subtree_response, external_lookup)
446
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
436
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
437
            _client=client)
447
438
        result = bzrdir.open_repository()
448
439
        self.assertEqual(
449
440
            [('call', 'BzrDir.find_repositoryV2', ('quack/',))],
468
459
            RemoteBzrDirFormat.probe_transport, OldServerTransport())
469
460
 
470
461
 
 
462
class TestBzrDirCreateBranch(TestRemote):
 
463
 
 
464
    def test_backwards_compat(self):
 
465
        self.setup_smart_server_with_call_log()
 
466
        repo = self.make_repository('.')
 
467
        self.reset_smart_call_log()
 
468
        self.disable_verb('BzrDir.create_branch')
 
469
        branch = repo.bzrdir.create_branch()
 
470
        create_branch_call_count = len([call for call in self.hpss_calls if
 
471
            call[0].method == 'BzrDir.create_branch'])
 
472
        self.assertEqual(1, create_branch_call_count)
 
473
 
 
474
    def test_current_server(self):
 
475
        transport = self.get_transport('.')
 
476
        transport = transport.clone('quack')
 
477
        self.make_repository('quack')
 
478
        client = FakeClient(transport.base)
 
479
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
480
        reference_format = reference_bzrdir_format.get_branch_format()
 
481
        network_name = reference_format.network_name()
 
482
        reference_repo_fmt = reference_bzrdir_format.repository_format
 
483
        reference_repo_name = reference_repo_fmt.network_name()
 
484
        client.add_expected_call(
 
485
            'BzrDir.create_branch', ('quack/', network_name),
 
486
            'success', ('ok', network_name, '', 'no', 'no', 'yes',
 
487
            reference_repo_name))
 
488
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
489
            _client=client)
 
490
        branch = a_bzrdir.create_branch()
 
491
        # We should have got a remote branch
 
492
        self.assertIsInstance(branch, remote.RemoteBranch)
 
493
        # its format should have the settings from the response
 
494
        format = branch._format
 
495
        self.assertEqual(network_name, format.network_name())
 
496
 
 
497
 
 
498
class TestBzrDirCreateRepository(TestRemote):
 
499
 
 
500
    def test_backwards_compat(self):
 
501
        self.setup_smart_server_with_call_log()
 
502
        bzrdir = self.make_bzrdir('.')
 
503
        self.reset_smart_call_log()
 
504
        self.disable_verb('BzrDir.create_repository')
 
505
        repo = bzrdir.create_repository()
 
506
        create_repo_call_count = len([call for call in self.hpss_calls if
 
507
            call[0].method == 'BzrDir.create_repository'])
 
508
        self.assertEqual(1, create_repo_call_count)
 
509
 
 
510
    def test_current_server(self):
 
511
        transport = self.get_transport('.')
 
512
        transport = transport.clone('quack')
 
513
        self.make_bzrdir('quack')
 
514
        client = FakeClient(transport.base)
 
515
        reference_bzrdir_format = bzrdir.format_registry.get('default')()
 
516
        reference_format = reference_bzrdir_format.repository_format
 
517
        network_name = reference_format.network_name()
 
518
        client.add_expected_call(
 
519
            'BzrDir.create_repository', ('quack/',
 
520
                'Bazaar pack repository format 1 (needs bzr 0.92)\n', 'False'),
 
521
            'success', ('ok', 'no', 'no', 'no', network_name))
 
522
        a_bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
523
            _client=client)
 
524
        repo = a_bzrdir.create_repository()
 
525
        # We should have got a remote repository
 
526
        self.assertIsInstance(repo, remote.RemoteRepository)
 
527
        # its format should have the settings from the response
 
528
        format = repo._format
 
529
        self.assertFalse(format.rich_root_data)
 
530
        self.assertFalse(format.supports_tree_reference)
 
531
        self.assertFalse(format.supports_external_lookups)
 
532
        self.assertEqual(network_name, format.network_name())
 
533
 
 
534
 
471
535
class TestBzrDirOpenRepository(tests.TestCase):
472
536
 
473
537
    def test_backwards_compat_1_2(self):
475
539
        transport.mkdir('quack')
476
540
        transport = transport.clone('quack')
477
541
        client = FakeClient(transport.base)
478
 
        client.add_unknown_method_response('RemoteRepository.find_repositoryV2')
 
542
        client.add_unknown_method_response('BzrDir.find_repositoryV2')
479
543
        client.add_success_response('ok', '', 'no', 'no')
480
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
544
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
545
            _client=client)
481
546
        repo = bzrdir.open_repository()
482
547
        self.assertEqual(
483
548
            [('call', 'BzrDir.find_repositoryV2', ('quack/',)),
517
582
 
518
583
    def make_remote_branch(self, transport, client):
519
584
        """Make a RemoteBranch using 'client' as its _SmartClient.
520
 
        
 
585
 
521
586
        A RemoteBzrDir and RemoteRepository will also be created to fill out
522
587
        the RemoteBranch, albeit with stub values for some of their attributes.
523
588
        """
524
589
        # we do not want bzrdir to make any remote calls, so use False as its
525
590
        # _client.  If it tries to make a remote call, this will fail
526
591
        # immediately.
527
 
        bzrdir = RemoteBzrDir(transport, _client=False)
 
592
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
593
            _client=False)
528
594
        repo = RemoteRepository(bzrdir, None, _client=client)
529
595
        return RemoteBranch(bzrdir, repo, _client=client)
530
596
 
570
636
    """Test Branch._get_stacked_on_url rpc"""
571
637
 
572
638
    def test_get_stacked_on_invalid_url(self):
573
 
        raise tests.KnownFailure('opening a branch requires the server to open the fallback repository')
574
 
        transport = FakeRemoteTransport('fakeremotetransport:///')
 
639
        # test that asking for a stacked on url the server can't access works.
 
640
        # This isn't perfect, but then as we're in the same process there
 
641
        # really isn't anything we can do to be 100% sure that the server
 
642
        # doesn't just open in - this test probably needs to be rewritten using
 
643
        # a spawn()ed server.
 
644
        stacked_branch = self.make_branch('stacked', format='1.9')
 
645
        memory_branch = self.make_branch('base', format='1.9')
 
646
        vfs_url = self.get_vfs_only_url('base')
 
647
        stacked_branch.set_stacked_on_url(vfs_url)
 
648
        transport = stacked_branch.bzrdir.root_transport
575
649
        client = FakeClient(transport.base)
576
650
        client.add_expected_call(
577
 
            'Branch.get_stacked_on_url', ('.',),
578
 
            'success', ('ok', 'file:///stacked/on'))
579
 
        bzrdir = RemoteBzrDir(transport, _client=client)
580
 
        branch = RemoteBranch(bzrdir, None, _client=client)
 
651
            'Branch.get_stacked_on_url', ('stacked/',),
 
652
            'success', ('ok', vfs_url))
 
653
        # XXX: Multiple calls are bad, this second call documents what is
 
654
        # today.
 
655
        client.add_expected_call(
 
656
            'Branch.get_stacked_on_url', ('stacked/',),
 
657
            'success', ('ok', vfs_url))
 
658
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
659
            _client=client)
 
660
        branch = RemoteBranch(bzrdir, RemoteRepository(bzrdir, None),
 
661
            _client=client)
581
662
        result = branch.get_stacked_on_url()
582
 
        self.assertEqual(
583
 
            'file:///stacked/on', result)
 
663
        self.assertEqual(vfs_url, result)
584
664
 
585
665
    def test_backwards_compatible(self):
586
666
        # like with bzr1.6 with no Branch.get_stacked_on_url rpc
603
683
            'unknown', ('Branch.get_stacked_on_url',))
604
684
        # this will also do vfs access, but that goes direct to the transport
605
685
        # and isn't seen by the FakeClient.
606
 
        bzrdir = RemoteBzrDir(self.get_transport('stacked'), _client=client)
 
686
        bzrdir = RemoteBzrDir(self.get_transport('stacked'),
 
687
            remote.RemoteBzrDirFormat(), _client=client)
607
688
        branch = bzrdir.open_branch()
608
689
        result = branch.get_stacked_on_url()
609
690
        self.assertEqual('../base', result)
632
713
        client.add_expected_call(
633
714
            'Branch.get_stacked_on_url', ('stacked/',),
634
715
            'success', ('ok', '../base'))
635
 
        bzrdir = RemoteBzrDir(self.get_transport('stacked'), _client=client)
 
716
        bzrdir = RemoteBzrDir(self.get_transport('stacked'),
 
717
            remote.RemoteBzrDirFormat(), _client=client)
636
718
        branch = bzrdir.open_branch()
637
719
        result = branch.get_stacked_on_url()
638
720
        self.assertEqual('../base', result)
661
743
            'Branch.lock_write', ('branch/', '', ''),
662
744
            'success', ('ok', 'branch token', 'repo token'))
663
745
        client.add_expected_call(
 
746
            'Branch.last_revision_info',
 
747
            ('branch/',),
 
748
            'success', ('ok', '0', 'null:'))
 
749
        client.add_expected_call(
664
750
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'null:',),
665
751
            'success', ('ok',))
666
752
        client.add_expected_call(
691
777
            'Branch.lock_write', ('branch/', '', ''),
692
778
            'success', ('ok', 'branch token', 'repo token'))
693
779
        client.add_expected_call(
 
780
            'Branch.last_revision_info',
 
781
            ('branch/',),
 
782
            'success', ('ok', '0', 'null:'))
 
783
        lines = ['rev-id2']
 
784
        encoded_body = bz2.compress('\n'.join(lines))
 
785
        client.add_success_response_with_body(encoded_body, 'ok')
 
786
        client.add_expected_call(
694
787
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id2',),
695
788
            'success', ('ok',))
696
789
        client.add_expected_call(
720
813
            'Branch.lock_write', ('branch/', '', ''),
721
814
            'success', ('ok', 'branch token', 'repo token'))
722
815
        client.add_expected_call(
 
816
            'Branch.last_revision_info',
 
817
            ('branch/',),
 
818
            'success', ('ok', '0', 'null:'))
 
819
        # get_graph calls to construct the revision history, for the set_rh
 
820
        # hook
 
821
        lines = ['rev-id']
 
822
        encoded_body = bz2.compress('\n'.join(lines))
 
823
        client.add_success_response_with_body(encoded_body, 'ok')
 
824
        client.add_expected_call(
723
825
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',),
724
826
            'error', ('NoSuchRevision', 'rev-id'))
725
827
        client.add_expected_call(
750
852
            'Branch.lock_write', ('branch/', '', ''),
751
853
            'success', ('ok', 'branch token', 'repo token'))
752
854
        client.add_expected_call(
 
855
            'Branch.last_revision_info',
 
856
            ('branch/',),
 
857
            'success', ('ok', '0', 'null:'))
 
858
        lines = ['rev-id']
 
859
        encoded_body = bz2.compress('\n'.join(lines))
 
860
        client.add_success_response_with_body(encoded_body, 'ok')
 
861
        client.add_expected_call(
753
862
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',),
754
863
            'error', ('TipChangeRejected', rejection_msg_utf8))
755
864
        client.add_expected_call(
758
867
        branch = self.make_remote_branch(transport, client)
759
868
        branch._ensure_real = lambda: None
760
869
        branch.lock_write()
761
 
        self.addCleanup(branch.unlock)
762
870
        # The 'TipChangeRejected' error response triggered by calling
763
871
        # set_revision_history causes a TipChangeRejected exception.
764
872
        err = self.assertRaises(
784
892
        client.add_error_response('NotStacked')
785
893
        # lock_write
786
894
        client.add_success_response('ok', 'branch token', 'repo token')
 
895
        # query the current revision
 
896
        client.add_success_response('ok', '0', 'null:')
787
897
        # set_last_revision
788
898
        client.add_success_response('ok')
789
899
        # unlock
795
905
        client._calls = []
796
906
        result = branch.set_last_revision_info(1234, 'a-revision-id')
797
907
        self.assertEqual(
798
 
            [('call', 'Branch.set_last_revision_info',
 
908
            [('call', 'Branch.last_revision_info', ('branch/',)),
 
909
             ('call', 'Branch.set_last_revision_info',
799
910
                ('branch/', 'branch token', 'repo token',
800
911
                 '1234', 'a-revision-id'))],
801
912
            client._calls)
855
966
            'Branch.get_stacked_on_url', ('branch/',),
856
967
            'error', ('NotStacked',))
857
968
        client.add_expected_call(
 
969
            'Branch.last_revision_info',
 
970
            ('branch/',),
 
971
            'success', ('ok', '0', 'null:'))
 
972
        client.add_expected_call(
858
973
            'Branch.set_last_revision_info',
859
974
            ('branch/', 'branch token', 'repo token', '1234', 'a-revision-id',),
860
975
            'unknown', 'Branch.set_last_revision_info')
1006
1121
 
1007
1122
    def test_error_from_old_server(self):
1008
1123
        """bzr 0.15 and earlier servers don't recognise the is_readonly verb.
1009
 
        
 
1124
 
1010
1125
        Clients should treat it as a "no" response, because is_readonly is only
1011
1126
        advisory anyway (a transport could be read-write, but then the
1012
1127
        underlying filesystem could be readonly anyway).
1050
1165
        self.assertEqual('bar', t._get_credentials()[0])
1051
1166
 
1052
1167
 
1053
 
class TestRemoteRepository(tests.TestCase):
 
1168
class TestRemoteRepository(TestRemote):
1054
1169
    """Base for testing RemoteRepository protocol usage.
1055
 
    
1056
 
    These tests contain frozen requests and responses.  We want any changes to 
 
1170
 
 
1171
    These tests contain frozen requests and responses.  We want any changes to
1057
1172
    what is sent or expected to be require a thoughtful update to these tests
1058
1173
    because they might break compatibility with different-versioned servers.
1059
1174
    """
1060
1175
 
1061
1176
    def setup_fake_client_and_repository(self, transport_path):
1062
1177
        """Create the fake client and repository for testing with.
1063
 
        
 
1178
 
1064
1179
        There's no real server here; we just have canned responses sent
1065
1180
        back one by one.
1066
 
        
 
1181
 
1067
1182
        :param transport_path: Path below the root of the MemoryTransport
1068
1183
            where the repository will be created.
1069
1184
        """
1072
1187
        client = FakeClient(transport.base)
1073
1188
        transport = transport.clone(transport_path)
1074
1189
        # we do not want bzrdir to make any remote calls
1075
 
        bzrdir = RemoteBzrDir(transport, _client=False)
 
1190
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
1191
            _client=False)
1076
1192
        repo = RemoteRepository(bzrdir, None, _client=client)
1077
1193
        return repo, client
1078
1194
 
1265
1381
 
1266
1382
 
1267
1383
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
1268
 
    
 
1384
 
1269
1385
    def test_null_revision(self):
1270
1386
        # a null revision has the predictable result {}, we should have no wire
1271
1387
        # traffic when calling it with this argument
1335
1451
            self.applyDeprecated, one_four, repo.get_revision_graph, revid)
1336
1452
        self.assertEqual(('AnUnexpectedError',), e.error_tuple)
1337
1453
 
1338
 
        
 
1454
 
1339
1455
class TestRepositoryIsShared(TestRemoteRepository):
1340
1456
 
1341
1457
    def test_is_shared(self):
1392
1508
            client._calls)
1393
1509
 
1394
1510
 
 
1511
class TestRepositorySetMakeWorkingTrees(TestRemoteRepository):
 
1512
 
 
1513
    def test_backwards_compat(self):
 
1514
        self.setup_smart_server_with_call_log()
 
1515
        repo = self.make_repository('.')
 
1516
        self.reset_smart_call_log()
 
1517
        verb = 'Repository.set_make_working_trees'
 
1518
        self.disable_verb(verb)
 
1519
        repo.set_make_working_trees(True)
 
1520
        call_count = len([call for call in self.hpss_calls if
 
1521
            call[0].method == verb])
 
1522
        self.assertEqual(1, call_count)
 
1523
 
 
1524
    def test_current(self):
 
1525
        transport_path = 'quack'
 
1526
        repo, client = self.setup_fake_client_and_repository(transport_path)
 
1527
        client.add_expected_call(
 
1528
            'Repository.set_make_working_trees', ('quack/', 'True'),
 
1529
            'success', ('ok',))
 
1530
        client.add_expected_call(
 
1531
            'Repository.set_make_working_trees', ('quack/', 'False'),
 
1532
            'success', ('ok',))
 
1533
        repo.set_make_working_trees(True)
 
1534
        repo.set_make_working_trees(False)
 
1535
 
 
1536
 
1395
1537
class TestRepositoryUnlock(TestRemoteRepository):
1396
1538
 
1397
1539
    def test_unlock(self):
1501
1643
    def reload_pack_names(self):
1502
1644
        self.calls.append(('pack collection reload_pack_names',))
1503
1645
 
1504
 
    
 
1646
 
1505
1647
class TestRemotePackRepositoryAutoPack(TestRemoteRepository):
1506
1648
    """Tests for RemoteRepository.autopack implementation."""
1507
1649
 
1531
1673
            [('call', 'PackRepository.autopack', ('quack/',)),
1532
1674
             ('pack collection reload_pack_names',)],
1533
1675
            client._calls)
1534
 
        
 
1676
 
1535
1677
    def test_backwards_compatibility(self):
1536
1678
        """If the server does not recognise the PackRepository.autopack verb,
1537
1679
        fallback to the real_repository's implementation.
1587
1729
 
1588
1730
class TestErrorTranslationSuccess(TestErrorTranslationBase):
1589
1731
    """Unit tests for bzrlib.remote._translate_error.
1590
 
    
 
1732
 
1591
1733
    Given an ErrorFromSmartServer (which has an error tuple from a smart
1592
1734
    server) and some context, _translate_error raises more specific errors from
1593
1735
    bzrlib.errors.
1698
1840
 
1699
1841
class TestErrorTranslationRobustness(TestErrorTranslationBase):
1700
1842
    """Unit tests for bzrlib.remote._translate_error's robustness.
1701
 
    
 
1843
 
1702
1844
    TestErrorTranslationSuccess is for cases where _translate_error can
1703
1845
    translate successfully.  This class about how _translate_err behaves when
1704
1846
    it fails to translate: it re-raises the original error.
1732
1874
        self.assertContainsRe(
1733
1875
            self._get_log(keep_log_file=True),
1734
1876
            "Missing key 'branch' in context")
1735
 
        
 
1877
 
1736
1878
    def test_path_missing(self):
1737
1879
        """Some translations (PermissionDenied, ReadError) can determine the
1738
1880
        'path' variable from either the wire or the local context.  If neither
1750
1892
 
1751
1893
class TestStacking(tests.TestCaseWithTransport):
1752
1894
    """Tests for operations on stacked remote repositories.
1753
 
    
 
1895
 
1754
1896
    The underlying format type must support stacking.
1755
1897
    """
1756
1898