/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
1
# Copyright (C) 2006 Canonical Ltd
2
#
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
17
"""Tests for the smart wire/domain protococl."""
18
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
19
from bzrlib import bzrdir, errors, smart, tests
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
20
from bzrlib.smart.request import SmartServerResponse
21
import bzrlib.smart.bzrdir
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
22
import bzrlib.smart.branch
2018.5.40 by Robert Collins
Implement a remote Repository.has_revision method.
23
import bzrlib.smart.repository
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
24
25
2018.5.59 by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil).
26
class TestCaseWithSmartMedium(tests.TestCaseWithTransport):
27
28
    def setUp(self):
29
        super(TestCaseWithSmartMedium, self).setUp()
30
        # We're allowed to set  the transport class here, so that we don't use
31
        # the default or a parameterized class, but rather use the
32
        # TestCaseWithTransport infrastructure to set up a smart server and
33
        # transport.
34
        self.transport_server = smart.server.SmartTCPServer_for_testing
35
36
    def get_smart_medium(self):
37
        """Get a smart medium to use in tests."""
38
        return self.get_transport().get_smart_medium()
39
40
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
41
class TestSmartServerResponse(tests.TestCase):
42
43
    def test__eq__(self):
44
        self.assertEqual(SmartServerResponse(('ok', )),
45
            SmartServerResponse(('ok', )))
46
        self.assertEqual(SmartServerResponse(('ok', ), 'body'),
47
            SmartServerResponse(('ok', ), 'body'))
48
        self.assertNotEqual(SmartServerResponse(('ok', )),
49
            SmartServerResponse(('notok', )))
50
        self.assertNotEqual(SmartServerResponse(('ok', ), 'body'),
51
            SmartServerResponse(('ok', )))
2018.5.41 by Robert Collins
Fix SmartServerResponse.__eq__ to handle None.
52
        self.assertNotEqual(None,
53
            SmartServerResponse(('ok', )))
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
54
55
2018.5.34 by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository.
56
class TestSmartServerRequestFindRepository(tests.TestCaseWithTransport):
57
58
    def test_no_repository(self):
59
        """When there is no repository to be found, ('norepository', ) is returned."""
60
        backing = self.get_transport()
61
        request = smart.bzrdir.SmartServerRequestFindRepository(backing)
62
        self.make_bzrdir('.')
63
        self.assertEqual(SmartServerResponse(('norepository', )),
64
            request.execute(backing.local_abspath('')))
65
66
    def test_nonshared_repository(self):
67
        # nonshared repositorys only allow 'find' to return a handle when the 
68
        # path the repository is being searched on is the same as that that 
69
        # the repository is at.
70
        backing = self.get_transport()
71
        request = smart.bzrdir.SmartServerRequestFindRepository(backing)
72
        self.make_repository('.')
73
        self.assertEqual(SmartServerResponse(('ok', '')),
74
            request.execute(backing.local_abspath('')))
75
        self.make_bzrdir('subdir')
76
        self.assertEqual(SmartServerResponse(('norepository', )),
77
            request.execute(backing.local_abspath('subdir')))
78
79
    def test_shared_repository(self):
80
        """When there is a shared repository, we get 'ok', 'relpath-to-repo'."""
81
        backing = self.get_transport()
82
        request = smart.bzrdir.SmartServerRequestFindRepository(backing)
83
        self.make_repository('.', shared=True)
84
        self.assertEqual(SmartServerResponse(('ok', '')),
85
            request.execute(backing.local_abspath('')))
86
        self.make_bzrdir('subdir')
87
        self.assertEqual(SmartServerResponse(('ok', '..')),
88
            request.execute(backing.local_abspath('subdir')))
89
        self.make_bzrdir('subdir/deeper')
90
        self.assertEqual(SmartServerResponse(('ok', '../..')),
91
            request.execute(backing.local_abspath('subdir/deeper')))
92
93
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
94
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithTransport):
95
96
    def test_empty_dir(self):
97
        """Initializing an empty dir should succeed and do it."""
98
        backing = self.get_transport()
99
        request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
100
        self.assertEqual(SmartServerResponse(('ok', )),
101
            request.execute(backing.local_abspath('.')))
102
        made_dir = bzrdir.BzrDir.open_from_transport(backing)
103
        # no branch, tree or repository is expected with the current 
104
        # default formart.
105
        self.assertRaises(errors.NoWorkingTree, made_dir.open_workingtree)
106
        self.assertRaises(errors.NotBranchError, made_dir.open_branch)
107
        self.assertRaises(errors.NoRepositoryPresent, made_dir.open_repository)
108
109
    def test_missing_dir(self):
110
        """Initializing a missing directory should fail like the bzrdir api."""
111
        backing = self.get_transport()
112
        request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
113
        self.assertRaises(errors.NoSuchFile,
114
            request.execute, backing.local_abspath('subdir'))
115
116
    def test_initialized_dir(self):
117
        """Initializing an extant bzrdir should fail like the bzrdir api."""
118
        backing = self.get_transport()
119
        request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
120
        self.make_bzrdir('subdir')
121
        self.assertRaises(errors.FileExists,
122
            request.execute, backing.local_abspath('subdir'))
123
124
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
125
class TestSmartServerRequestOpenBranch(tests.TestCaseWithTransport):
126
127
    def test_no_branch(self):
128
        """When there is no branch, ('nobranch', ) is returned."""
129
        backing = self.get_transport()
130
        request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
131
        self.make_bzrdir('.')
132
        self.assertEqual(SmartServerResponse(('nobranch', )),
133
            request.execute(backing.local_abspath('')))
134
135
    def test_branch(self):
136
        """When there is a branch, 'ok' is returned."""
137
        backing = self.get_transport()
138
        request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
139
        self.make_branch('.')
140
        self.assertEqual(SmartServerResponse(('ok', '')),
141
            request.execute(backing.local_abspath('')))
142
143
    def test_branch_reference(self):
144
        """When there is a branch reference, the reference URL is returned."""
145
        backing = self.get_transport()
146
        request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
147
        branch = self.make_branch('branch')
148
        checkout = branch.create_checkout('reference',lightweight=True)
149
        # TODO: once we have an API to probe for references of any sort, we
150
        # can use it here.
151
        reference_url = backing.abspath('branch') + '/'
152
        self.assertFileEqual(reference_url, 'reference/.bzr/branch/location')
153
        self.assertEqual(SmartServerResponse(('ok', reference_url)),
154
            request.execute(backing.local_abspath('reference')))
155
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
156
157
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithTransport):
158
159
    def test_empty(self):
160
        """For an empty branch, the body is empty."""
161
        backing = self.get_transport()
162
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
163
        self.make_branch('.')
164
        self.assertEqual(SmartServerResponse(('ok', ), ''),
165
            request.execute(backing.local_abspath('')))
166
167
    def test_not_empty(self):
168
        """For a non-empty branch, the body is empty."""
169
        backing = self.get_transport()
170
        request = smart.branch.SmartServerRequestRevisionHistory(backing)
171
        tree = self.make_branch_and_memory_tree('.')
172
        tree.lock_write()
173
        tree.add('')
174
        r1 = tree.commit('1st commit')
175
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
176
        tree.unlock()
177
        self.assertEqual(SmartServerResponse(('ok', ),
178
            ('\x00'.join([r1, r2])).encode('utf8')),
179
            request.execute(backing.local_abspath('')))
180
2018.5.49 by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to
181
182
class TestSmartServerBranchRequest(tests.TestCaseWithTransport):
183
184
    def test_no_branch(self):
185
        """When there is a bzrdir and no branch, NotBranchError is raised."""
186
        backing = self.get_transport()
187
        request = smart.branch.SmartServerBranchRequest(backing)
188
        self.make_bzrdir('.')
189
        self.assertRaises(errors.NotBranchError,
190
            request.execute, backing.local_abspath(''))
191
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
192
    def test_branch_reference(self):
193
        """When there is a branch reference, NotBranchError is raised."""
194
        backing = self.get_transport()
2018.5.49 by Wouter van Heyst
Refactor SmartServerBranchRequest out from SmartServerRequestRevisionHistory to
195
        request = smart.branch.SmartServerBranchRequest(backing)
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
196
        branch = self.make_branch('branch')
197
        checkout = branch.create_checkout('reference',lightweight=True)
198
        self.assertRaises(errors.NotBranchError,
199
            request.execute, backing.local_abspath('checkout'))
200
201
2018.5.50 by Wouter van Heyst
Add SmartServerBranchRequestLastRevisionInfo method.
202
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithTransport):
203
204
    def test_empty(self):
205
        """For an empty branch, the result is ('ok', '0', '')."""
206
        backing = self.get_transport()
207
        request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
208
        self.make_branch('.')
209
        self.assertEqual(SmartServerResponse(('ok', '0', '')),
210
            request.execute(backing.local_abspath('')))
211
212
    def test_not_empty(self):
213
        """For a non-empty branch, the result is ('ok', 'revno', 'revid')."""
214
        backing = self.get_transport()
215
        request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
216
        tree = self.make_branch_and_memory_tree('.')
217
        tree.lock_write()
218
        tree.add('')
219
        r1 = tree.commit('1st commit')
220
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
221
        tree.unlock()
222
        self.assertEqual(
223
            SmartServerResponse(('ok', '2', u'\xc8'.encode('utf8'))),
224
            request.execute(backing.local_abspath('')))
225
226
2018.12.3 by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it.
227
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithTransport):
2018.5.59 by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil).
228
229
    def test_default(self):
230
        """With no file, we get empty content."""
231
        backing = self.get_transport()
232
        request = smart.branch.SmartServerBranchGetConfigFile(backing)
233
        branch = self.make_branch('.')
234
        # there should be no file by default
235
        content = ''
236
        self.assertEqual(SmartServerResponse(('ok', ), content),
237
            request.execute(backing.local_abspath('')))
238
239
    def test_with_content(self):
240
        # SmartServerBranchGetConfigFile should return the content from
241
        # branch.control_files.get('branch.conf') for now - in the future it may
242
        # perform more complex processing. 
243
        backing = self.get_transport()
244
        request = smart.branch.SmartServerBranchGetConfigFile(backing)
245
        branch = self.make_branch('.')
246
        branch.control_files.put_utf8('branch.conf', 'foo bar baz')
247
        self.assertEqual(SmartServerResponse(('ok', ), 'foo bar baz'),
248
            request.execute(backing.local_abspath('')))
249
250
2018.12.3 by Andrew Bennetts
Add a Branch.set_last_revision smart method, and make RemoteBranch.set_revision_history use it.
251
class TestSmartServerBranchRequestSetLastRevision(tests.TestCaseWithTransport):
252
253
    def test_empty(self):
254
        backing = self.get_transport()
255
        request = smart.branch.SmartServerBranchRequestSetLastRevision(backing)
256
        self.make_branch('.')
257
        self.assertEqual(SmartServerResponse(('ok',)),
258
            request.execute(backing.local_abspath(''), ''))
259
260
    def test_not_present_revision_id(self):
261
        backing = self.get_transport()
262
        request = smart.branch.SmartServerBranchRequestSetLastRevision(backing)
263
        self.make_branch('.')
264
        revision_id = 'non-existent revision'
265
        self.assertEqual(SmartServerResponse(('NoSuchRevision', revision_id)),
266
            request.execute(backing.local_abspath(''), revision_id))
267
268
    def test_revision_id_present(self):
269
        backing = self.get_transport()
270
        request = smart.branch.SmartServerBranchRequestSetLastRevision(backing)
271
        tree = self.make_branch_and_memory_tree('.')
272
        tree.lock_write()
273
        tree.add('')
274
        r1 = tree.commit('1st commit', rev_id=u'\xc8')
275
        r2 = tree.commit('2nd commit')
276
        tree.unlock()
277
        self.assertEqual(
278
            SmartServerResponse(('ok',)),
279
            request.execute(backing.local_abspath(''), u'\xc8'.encode('utf8')))
280
        self.assertEqual([u'\xc8'], tree.branch.revision_history())
281
282
    def test_revision_id_present2(self):
283
        backing = self.get_transport()
284
        request = smart.branch.SmartServerBranchRequestSetLastRevision(backing)
285
        tree = self.make_branch_and_memory_tree('.')
286
        tree.lock_write()
287
        tree.add('')
288
        r1 = tree.commit('1st commit', rev_id=u'\xc8')
289
        r2 = tree.commit('2nd commit')
290
        tree.unlock()
291
        tree.branch.set_revision_history([])
292
        self.assertEqual(
293
            SmartServerResponse(('ok',)),
294
            request.execute(backing.local_abspath(''), u'\xc8'.encode('utf8')))
295
        self.assertEqual([u'\xc8'], tree.branch.revision_history())
296
297
2018.5.56 by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil).
298
class TestSmartServerRepositoryRequest(tests.TestCaseWithTransport):
299
300
    def test_no_repository(self):
301
        """Raise NoRepositoryPresent when there is a bzrdir and no repo."""
302
        # we test this using a shared repository above the named path,
303
        # thus checking the right search logic is used - that is, that
304
        # its the exact path being looked at and the server is not
305
        # searching.
306
        backing = self.get_transport()
2018.5.58 by Wouter van Heyst
Small test fixes to reflect naming and documentation
307
        request = smart.repository.SmartServerRepositoryRequest(backing)
2018.5.56 by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil).
308
        self.make_repository('.', shared=True)
309
        self.make_bzrdir('subdir')
310
        self.assertRaises(errors.NoRepositoryPresent,
2018.5.58 by Wouter van Heyst
Small test fixes to reflect naming and documentation
311
            request.execute, backing.local_abspath('subdir'))
2018.5.56 by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil).
312
313
2018.5.67 by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins)
314
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithTransport):
315
316
    def test_none_argument(self):
317
        backing = self.get_transport()
318
        request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing)
319
        tree = self.make_branch_and_memory_tree('.')
320
        tree.lock_write()
321
        tree.add('')
322
        r1 = tree.commit('1st commit')
323
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
324
        tree.unlock()
325
326
        # the lines of revision_id->revision_parent_list has no guaranteed
327
        # order coming out of a dict, so sort both our test and response
328
        lines = sorted([' '.join([r2, r1]), r1])
329
        response = request.execute(backing.local_abspath(''), '')
330
        response.body = '\n'.join(sorted(response.body.split('\n')))
331
332
        self.assertEqual(SmartServerResponse(('ok', ),
333
            '\n'.join(lines).encode('utf8')),
334
            response)
335
336
    def test_specific_revision_argument(self):
337
        backing = self.get_transport()
338
        request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing)
339
        tree = self.make_branch_and_memory_tree('.')
340
        tree.lock_write()
341
        tree.add('')
342
        r1 = tree.commit('1st commit', rev_id=u'\xc9')
343
        r2 = tree.commit('2nd commit', rev_id=u'\xc8')
344
        tree.unlock()
345
346
        self.assertEqual(SmartServerResponse(('ok', ),
347
            u'\xc9'.encode('utf8')),
348
            request.execute(backing.local_abspath(''), u'\xc9'.encode('utf8')))
349
    
350
    def test_no_such_revision(self):
351
        backing = self.get_transport()
352
        request = smart.repository.SmartServerRepositoryGetRevisionGraph(backing)
353
        tree = self.make_branch_and_memory_tree('.')
354
        tree.lock_write()
355
        tree.add('')
356
        r1 = tree.commit('1st commit')
357
        tree.unlock()
358
359
        self.assertEqual(SmartServerResponse(
360
            ('nosuchrevision', 'missingrevision', )),
361
            request.execute(backing.local_abspath(''), 'missingrevision'))
362
2018.5.56 by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil).
363
class TestSmartServerRequestHasRevision(tests.TestCaseWithTransport):
364
365
    def test_missing_revision(self):
366
        """For a missing revision, ('no', ) is returned."""
367
        backing = self.get_transport()
368
        request = smart.repository.SmartServerRequestHasRevision(backing)
369
        self.make_repository('.')
370
        self.assertEqual(SmartServerResponse(('no', )),
371
            request.execute(backing.local_abspath(''), 'revid'))
372
373
    def test_present_revision(self):
374
        """For a present revision, ('ok', ) is returned."""
375
        backing = self.get_transport()
376
        request = smart.repository.SmartServerRequestHasRevision(backing)
377
        tree = self.make_branch_and_memory_tree('.')
378
        tree.lock_write()
379
        tree.add('')
380
        r1 = tree.commit('a commit', rev_id=u'\xc8abc')
381
        tree.unlock()
382
        self.assertTrue(tree.branch.repository.has_revision(u'\xc8abc'))
383
        self.assertEqual(SmartServerResponse(('ok', )),
384
            request.execute(backing.local_abspath(''),
385
                u'\xc8abc'.encode('utf8')))
386
387
2018.10.2 by v.ladeuil+lp at free
gather_stats server side and request registration
388
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithTransport):
389
390
    def test_empty_revid(self):
391
        """With an empty revid, we get only size an number and revisions"""
392
        backing = self.get_transport()
393
        request = smart.repository.SmartServerRepositoryGatherStats(backing)
394
        repository = self.make_repository('.')
395
        stats = repository.gather_stats()
396
        size = stats['size']
397
        expected_body = 'revisions: 0\nsize: %d\n' % size
398
        self.assertEqual(SmartServerResponse(('ok', ), expected_body),
399
                         request.execute(backing.local_abspath(''), '', 'no'))
400
401
    def test_revid_with_committers(self):
402
        """For a revid we get more infos."""
403
        backing = self.get_transport()
404
        rev_id = u'\xc8abc'
405
        request = smart.repository.SmartServerRepositoryGatherStats(backing)
406
        tree = self.make_branch_and_memory_tree('.')
407
        tree.lock_write()
408
        tree.add('')
409
        # Let's build a predictable result
410
        tree.commit('a commit', timestamp=123456.2, timezone=3600)
411
        tree.commit('a commit', timestamp=654321.4, timezone=0, rev_id=rev_id)
412
        tree.unlock()
413
414
        stats = tree.branch.repository.gather_stats()
415
        size = stats['size']
416
        expected_body = ('firstrev: 123456.200 3600\n'
417
                         'latestrev: 654321.400 0\n'
418
                         'revisions: 2\n'
419
                         'size: %d\n' % size)
420
        self.assertEqual(SmartServerResponse(('ok', ), expected_body),
421
                         request.execute(backing.local_abspath(''),
422
                                         rev_id.encode('utf8'), 'no'))
423
424
    def test_not_empty_repository_with_committers(self):
425
        """For a revid and requesting committers we get the whole thing."""
426
        backing = self.get_transport()
427
        rev_id = u'\xc8abc'
428
        request = smart.repository.SmartServerRepositoryGatherStats(backing)
429
        tree = self.make_branch_and_memory_tree('.')
430
        tree.lock_write()
431
        tree.add('')
432
        # Let's build a predictable result
433
        tree.commit('a commit', timestamp=123456.2, timezone=3600,
434
                    committer='foo')
435
        tree.commit('a commit', timestamp=654321.4, timezone=0,
436
                    committer='bar', rev_id=rev_id)
437
        tree.unlock()
438
        stats = tree.branch.repository.gather_stats()
439
440
        size = stats['size']
441
        expected_body = ('committers: 2\n'
442
                         'firstrev: 123456.200 3600\n'
443
                         'latestrev: 654321.400 0\n'
444
                         'revisions: 2\n'
445
                         'size: %d\n' % size)
446
        self.assertEqual(SmartServerResponse(('ok', ), expected_body),
447
                         request.execute(backing.local_abspath(''),
448
                                         rev_id.encode('utf8'), 'yes'))
449
450
2018.5.57 by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil).
451
class TestSmartServerRepositoryIsShared(tests.TestCaseWithTransport):
452
453
    def test_is_shared(self):
454
        """For a shared repository, ('yes', ) is returned."""
455
        backing = self.get_transport()
456
        request = smart.repository.SmartServerRepositoryIsShared(backing)
457
        self.make_repository('.', shared=True)
458
        self.assertEqual(SmartServerResponse(('yes', )),
459
            request.execute(backing.local_abspath(''), ))
460
461
    def test_is_not_shared(self):
2018.5.58 by Wouter van Heyst
Small test fixes to reflect naming and documentation
462
        """For a shared repository, ('no', ) is returned."""
2018.5.57 by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil).
463
        backing = self.get_transport()
464
        request = smart.repository.SmartServerRepositoryIsShared(backing)
465
        self.make_repository('.', shared=False)
466
        self.assertEqual(SmartServerResponse(('no', )),
467
            request.execute(backing.local_abspath(''), ))
468
2018.5.56 by Robert Collins
Factor out code we expect to be common in SmartServerRequestHasRevision to SmartServerRepositoryRequest (Robert Collins, Vincent Ladeuil).
469
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
470
class TestHandlers(tests.TestCase):
471
    """Tests for the request.request_handlers object."""
472
473
    def test_registered_methods(self):
474
        """Test that known methods are registered to the correct object."""
475
        self.assertEqual(
2018.5.59 by Robert Collins
Get BranchConfig working somewhat on RemoteBranches (Robert Collins, Vincent Ladeuil).
476
            smart.request.request_handlers.get('Branch.get_config_file'),
477
            smart.branch.SmartServerBranchGetConfigFile)
478
        self.assertEqual(
2018.5.51 by Wouter van Heyst
Test and implement RemoteBranch.last_revision_info()
479
            smart.request.request_handlers.get('Branch.last_revision_info'),
480
            smart.branch.SmartServerBranchRequestLastRevisionInfo)
481
        self.assertEqual(
2018.5.38 by Robert Collins
Implement RemoteBranch.revision_history().
482
            smart.request.request_handlers.get('Branch.revision_history'),
483
            smart.branch.SmartServerRequestRevisionHistory)
484
        self.assertEqual(
2018.5.34 by Robert Collins
Get test_remote.BasicRemoteObjectTests.test_open_remote_branch passing by implementing a remote method BzrDir.find_repository.
485
            smart.request.request_handlers.get('BzrDir.find_repository'),
486
            smart.bzrdir.SmartServerRequestFindRepository)
487
        self.assertEqual(
2018.5.42 by Robert Collins
Various hopefully improvements, but wsgi is broken, handing over to spiv :).
488
            smart.request.request_handlers.get('BzrDirFormat.initialize'),
489
            smart.bzrdir.SmartServerRequestInitializeBzrDir)
490
        self.assertEqual(
2018.6.1 by Robert Collins
Implement a BzrDir.open_branch smart server method for opening a branch without VFS.
491
            smart.request.request_handlers.get('BzrDir.open_branch'),
492
            smart.bzrdir.SmartServerRequestOpenBranch)
2018.5.40 by Robert Collins
Implement a remote Repository.has_revision method.
493
        self.assertEqual(
2018.10.2 by v.ladeuil+lp at free
gather_stats server side and request registration
494
            smart.request.request_handlers.get('Repository.gather_stats'),
495
            smart.repository.SmartServerRepositoryGatherStats)
496
        self.assertEqual(
2018.5.67 by Wouter van Heyst
Implement RemoteRepository.get_revision_graph (Wouter van Heyst, Robert Collins)
497
            smart.request.request_handlers.get('Repository.get_revision_graph'),
498
            smart.repository.SmartServerRepositoryGetRevisionGraph)
499
        self.assertEqual(
2018.5.40 by Robert Collins
Implement a remote Repository.has_revision method.
500
            smart.request.request_handlers.get('Repository.has_revision'),
501
            smart.repository.SmartServerRequestHasRevision)
2018.5.57 by Robert Collins
Implement RemoteRepository.is_shared (Robert Collins, Vincent Ladeuil).
502
        self.assertEqual(
503
            smart.request.request_handlers.get('Repository.is_shared'),
504
            smart.repository.SmartServerRepositoryIsShared)