/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 15:36:48 UTC
  • mfrom: (4048 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4050.
  • Revision ID: jelmer@samba.org-20090225153648-7r5mk20nr9dttqbf
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"
253
227
        self.expecting_body = True
254
228
        return result[1], FakeProtocol(result[2], self)
255
229
 
 
230
    def call_with_body_stream(self, args, stream):
 
231
        # Explicitly consume the stream before checking for an error, because
 
232
        # that's what happens a real medium.
 
233
        stream = list(stream)
 
234
        self._check_call(args[0], args[1:])
 
235
        self._calls.append(('call_with_body_stream', args[0], args[1:], stream))
 
236
        return self._get_next_response()[1]
 
237
 
256
238
 
257
239
class FakeMedium(medium.SmartClientMedium):
258
240
 
278
260
        self.assertTrue(result)
279
261
 
280
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
 
281
275
class Test_ClientMedium_remote_path_from_transport(tests.TestCase):
282
276
    """Tests for the behaviour of client_medium.remote_path_from_transport."""
283
277
 
310
304
        cloned_transport = base_transport.clone(relpath)
311
305
        result = client_medium.remote_path_from_transport(cloned_transport)
312
306
        self.assertEqual(expected, result)
313
 
        
 
307
 
314
308
    def test_remote_path_from_transport_http(self):
315
309
        """Remote paths for HTTP transports are calculated differently to other
316
310
        transports.  They are just relative to the client base, not the root
332
326
        """
333
327
        client_medium = medium.SmartClientMedium('dummy base')
334
328
        self.assertFalse(client_medium._is_remote_before((99, 99)))
335
 
    
 
329
 
336
330
    def test__remember_remote_is_before(self):
337
331
        """Calling _remember_remote_is_before ratchets down the known remote
338
332
        version.
367
361
        client.add_expected_call(
368
362
            'Branch.get_stacked_on_url', ('quack/',),
369
363
            'error', ('NotStacked',))
370
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
364
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
365
            _client=client)
371
366
        result = bzrdir.open_branch()
372
367
        self.assertIsInstance(result, RemoteBranch)
373
368
        self.assertEqual(bzrdir, result.bzrdir)
379
374
        transport = transport.clone('quack')
380
375
        client = FakeClient(transport.base)
381
376
        client.add_error_response('nobranch')
382
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
377
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
378
            _client=client)
383
379
        self.assertRaises(errors.NotBranchError, bzrdir.open_branch)
384
380
        self.assertEqual(
385
381
            [('call', 'BzrDir.open_branch', ('quack/',))],
395
391
        transport = MemoryTransport()
396
392
        # no requests on the network - catches other api calls being made.
397
393
        client = FakeClient(transport.base)
398
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
394
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
395
            _client=client)
399
396
        # patch the open_branch call to record that it was called.
400
397
        bzrdir.open_branch = open_branch
401
398
        self.assertEqual((None, "a-branch"), bzrdir._get_tree_branch())
416
413
        client.add_expected_call(
417
414
            'Branch.get_stacked_on_url', ('~hello/',),
418
415
            'error', ('NotStacked',))
419
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
416
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
417
            _client=client)
420
418
        result = bzrdir.open_branch()
421
419
        client.finished_test()
422
420
 
435
433
        client = FakeClient(transport.base)
436
434
        client.add_success_response(
437
435
            'ok', '', rich_response, subtree_response, external_lookup)
438
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
436
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
437
            _client=client)
439
438
        result = bzrdir.open_repository()
440
439
        self.assertEqual(
441
440
            [('call', 'BzrDir.find_repositoryV2', ('quack/',))],
460
459
            RemoteBzrDirFormat.probe_transport, OldServerTransport())
461
460
 
462
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
 
463
535
class TestBzrDirOpenRepository(tests.TestCase):
464
536
 
465
537
    def test_backwards_compat_1_2(self):
467
539
        transport.mkdir('quack')
468
540
        transport = transport.clone('quack')
469
541
        client = FakeClient(transport.base)
470
 
        client.add_unknown_method_response('RemoteRepository.find_repositoryV2')
 
542
        client.add_unknown_method_response('BzrDir.find_repositoryV2')
471
543
        client.add_success_response('ok', '', 'no', 'no')
472
 
        bzrdir = RemoteBzrDir(transport, _client=client)
 
544
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
545
            _client=client)
473
546
        repo = bzrdir.open_repository()
474
547
        self.assertEqual(
475
548
            [('call', 'BzrDir.find_repositoryV2', ('quack/',)),
509
582
 
510
583
    def make_remote_branch(self, transport, client):
511
584
        """Make a RemoteBranch using 'client' as its _SmartClient.
512
 
        
 
585
 
513
586
        A RemoteBzrDir and RemoteRepository will also be created to fill out
514
587
        the RemoteBranch, albeit with stub values for some of their attributes.
515
588
        """
516
589
        # we do not want bzrdir to make any remote calls, so use False as its
517
590
        # _client.  If it tries to make a remote call, this will fail
518
591
        # immediately.
519
 
        bzrdir = RemoteBzrDir(transport, _client=False)
 
592
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
593
            _client=False)
520
594
        repo = RemoteRepository(bzrdir, None, _client=client)
521
595
        return RemoteBranch(bzrdir, repo, _client=client)
522
596
 
562
636
    """Test Branch._get_stacked_on_url rpc"""
563
637
 
564
638
    def test_get_stacked_on_invalid_url(self):
565
 
        raise tests.KnownFailure('opening a branch requires the server to open the fallback repository')
566
 
        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
567
649
        client = FakeClient(transport.base)
568
650
        client.add_expected_call(
569
 
            'Branch.get_stacked_on_url', ('.',),
570
 
            'success', ('ok', 'file:///stacked/on'))
571
 
        bzrdir = RemoteBzrDir(transport, _client=client)
572
 
        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)
573
662
        result = branch.get_stacked_on_url()
574
 
        self.assertEqual(
575
 
            'file:///stacked/on', result)
 
663
        self.assertEqual(vfs_url, result)
576
664
 
577
665
    def test_backwards_compatible(self):
578
666
        # like with bzr1.6 with no Branch.get_stacked_on_url rpc
595
683
            'unknown', ('Branch.get_stacked_on_url',))
596
684
        # this will also do vfs access, but that goes direct to the transport
597
685
        # and isn't seen by the FakeClient.
598
 
        bzrdir = RemoteBzrDir(self.get_transport('stacked'), _client=client)
 
686
        bzrdir = RemoteBzrDir(self.get_transport('stacked'),
 
687
            remote.RemoteBzrDirFormat(), _client=client)
599
688
        branch = bzrdir.open_branch()
600
689
        result = branch.get_stacked_on_url()
601
690
        self.assertEqual('../base', result)
624
713
        client.add_expected_call(
625
714
            'Branch.get_stacked_on_url', ('stacked/',),
626
715
            'success', ('ok', '../base'))
627
 
        bzrdir = RemoteBzrDir(self.get_transport('stacked'), _client=client)
 
716
        bzrdir = RemoteBzrDir(self.get_transport('stacked'),
 
717
            remote.RemoteBzrDirFormat(), _client=client)
628
718
        branch = bzrdir.open_branch()
629
719
        result = branch.get_stacked_on_url()
630
720
        self.assertEqual('../base', result)
653
743
            'Branch.lock_write', ('branch/', '', ''),
654
744
            'success', ('ok', 'branch token', 'repo token'))
655
745
        client.add_expected_call(
 
746
            'Branch.last_revision_info',
 
747
            ('branch/',),
 
748
            'success', ('ok', '0', 'null:'))
 
749
        client.add_expected_call(
656
750
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'null:',),
657
751
            'success', ('ok',))
658
752
        client.add_expected_call(
683
777
            'Branch.lock_write', ('branch/', '', ''),
684
778
            'success', ('ok', 'branch token', 'repo token'))
685
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(
686
787
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id2',),
687
788
            'success', ('ok',))
688
789
        client.add_expected_call(
712
813
            'Branch.lock_write', ('branch/', '', ''),
713
814
            'success', ('ok', 'branch token', 'repo token'))
714
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(
715
825
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',),
716
826
            'error', ('NoSuchRevision', 'rev-id'))
717
827
        client.add_expected_call(
742
852
            'Branch.lock_write', ('branch/', '', ''),
743
853
            'success', ('ok', 'branch token', 'repo token'))
744
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(
745
862
            'Branch.set_last_revision', ('branch/', 'branch token', 'repo token', 'rev-id',),
746
863
            'error', ('TipChangeRejected', rejection_msg_utf8))
747
864
        client.add_expected_call(
750
867
        branch = self.make_remote_branch(transport, client)
751
868
        branch._ensure_real = lambda: None
752
869
        branch.lock_write()
753
 
        self.addCleanup(branch.unlock)
754
870
        # The 'TipChangeRejected' error response triggered by calling
755
871
        # set_revision_history causes a TipChangeRejected exception.
756
872
        err = self.assertRaises(
776
892
        client.add_error_response('NotStacked')
777
893
        # lock_write
778
894
        client.add_success_response('ok', 'branch token', 'repo token')
 
895
        # query the current revision
 
896
        client.add_success_response('ok', '0', 'null:')
779
897
        # set_last_revision
780
898
        client.add_success_response('ok')
781
899
        # unlock
787
905
        client._calls = []
788
906
        result = branch.set_last_revision_info(1234, 'a-revision-id')
789
907
        self.assertEqual(
790
 
            [('call', 'Branch.set_last_revision_info',
 
908
            [('call', 'Branch.last_revision_info', ('branch/',)),
 
909
             ('call', 'Branch.set_last_revision_info',
791
910
                ('branch/', 'branch token', 'repo token',
792
911
                 '1234', 'a-revision-id'))],
793
912
            client._calls)
847
966
            'Branch.get_stacked_on_url', ('branch/',),
848
967
            'error', ('NotStacked',))
849
968
        client.add_expected_call(
 
969
            'Branch.last_revision_info',
 
970
            ('branch/',),
 
971
            'success', ('ok', '0', 'null:'))
 
972
        client.add_expected_call(
850
973
            'Branch.set_last_revision_info',
851
974
            ('branch/', 'branch token', 'repo token', '1234', 'a-revision-id',),
852
975
            'unknown', 'Branch.set_last_revision_info')
998
1121
 
999
1122
    def test_error_from_old_server(self):
1000
1123
        """bzr 0.15 and earlier servers don't recognise the is_readonly verb.
1001
 
        
 
1124
 
1002
1125
        Clients should treat it as a "no" response, because is_readonly is only
1003
1126
        advisory anyway (a transport could be read-write, but then the
1004
1127
        underlying filesystem could be readonly anyway).
1042
1165
        self.assertEqual('bar', t._get_credentials()[0])
1043
1166
 
1044
1167
 
1045
 
class TestRemoteRepository(tests.TestCase):
 
1168
class TestRemoteRepository(TestRemote):
1046
1169
    """Base for testing RemoteRepository protocol usage.
1047
 
    
1048
 
    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
1049
1172
    what is sent or expected to be require a thoughtful update to these tests
1050
1173
    because they might break compatibility with different-versioned servers.
1051
1174
    """
1052
1175
 
1053
1176
    def setup_fake_client_and_repository(self, transport_path):
1054
1177
        """Create the fake client and repository for testing with.
1055
 
        
 
1178
 
1056
1179
        There's no real server here; we just have canned responses sent
1057
1180
        back one by one.
1058
 
        
 
1181
 
1059
1182
        :param transport_path: Path below the root of the MemoryTransport
1060
1183
            where the repository will be created.
1061
1184
        """
1064
1187
        client = FakeClient(transport.base)
1065
1188
        transport = transport.clone(transport_path)
1066
1189
        # we do not want bzrdir to make any remote calls
1067
 
        bzrdir = RemoteBzrDir(transport, _client=False)
 
1190
        bzrdir = RemoteBzrDir(transport, remote.RemoteBzrDirFormat(),
 
1191
            _client=False)
1068
1192
        repo = RemoteRepository(bzrdir, None, _client=client)
1069
1193
        return repo, client
1070
1194
 
1257
1381
 
1258
1382
 
1259
1383
class TestRepositoryGetRevisionGraph(TestRemoteRepository):
1260
 
    
 
1384
 
1261
1385
    def test_null_revision(self):
1262
1386
        # a null revision has the predictable result {}, we should have no wire
1263
1387
        # traffic when calling it with this argument
1327
1451
            self.applyDeprecated, one_four, repo.get_revision_graph, revid)
1328
1452
        self.assertEqual(('AnUnexpectedError',), e.error_tuple)
1329
1453
 
1330
 
        
 
1454
 
1331
1455
class TestRepositoryIsShared(TestRemoteRepository):
1332
1456
 
1333
1457
    def test_is_shared(self):
1384
1508
            client._calls)
1385
1509
 
1386
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
 
1387
1537
class TestRepositoryUnlock(TestRemoteRepository):
1388
1538
 
1389
1539
    def test_unlock(self):
1493
1643
    def reload_pack_names(self):
1494
1644
        self.calls.append(('pack collection reload_pack_names',))
1495
1645
 
1496
 
    
 
1646
 
1497
1647
class TestRemotePackRepositoryAutoPack(TestRemoteRepository):
1498
1648
    """Tests for RemoteRepository.autopack implementation."""
1499
1649
 
1523
1673
            [('call', 'PackRepository.autopack', ('quack/',)),
1524
1674
             ('pack collection reload_pack_names',)],
1525
1675
            client._calls)
1526
 
        
 
1676
 
1527
1677
    def test_backwards_compatibility(self):
1528
1678
        """If the server does not recognise the PackRepository.autopack verb,
1529
1679
        fallback to the real_repository's implementation.
1579
1729
 
1580
1730
class TestErrorTranslationSuccess(TestErrorTranslationBase):
1581
1731
    """Unit tests for bzrlib.remote._translate_error.
1582
 
    
 
1732
 
1583
1733
    Given an ErrorFromSmartServer (which has an error tuple from a smart
1584
1734
    server) and some context, _translate_error raises more specific errors from
1585
1735
    bzrlib.errors.
1690
1840
 
1691
1841
class TestErrorTranslationRobustness(TestErrorTranslationBase):
1692
1842
    """Unit tests for bzrlib.remote._translate_error's robustness.
1693
 
    
 
1843
 
1694
1844
    TestErrorTranslationSuccess is for cases where _translate_error can
1695
1845
    translate successfully.  This class about how _translate_err behaves when
1696
1846
    it fails to translate: it re-raises the original error.
1724
1874
        self.assertContainsRe(
1725
1875
            self._get_log(keep_log_file=True),
1726
1876
            "Missing key 'branch' in context")
1727
 
        
 
1877
 
1728
1878
    def test_path_missing(self):
1729
1879
        """Some translations (PermissionDenied, ReadError) can determine the
1730
1880
        'path' variable from either the wire or the local context.  If neither
1742
1892
 
1743
1893
class TestStacking(tests.TestCaseWithTransport):
1744
1894
    """Tests for operations on stacked remote repositories.
1745
 
    
 
1895
 
1746
1896
    The underlying format type must support stacking.
1747
1897
    """
1748
1898