28
from StringIO import StringIO
28
from cStringIO import StringIO
32
from bzrlib import bzrdir, errors, pack, smart, tests
39
from bzrlib.branch import BranchReferenceFormat
40
import bzrlib.smart.branch
41
import bzrlib.smart.bzrdir
42
import bzrlib.smart.repository
33
43
from bzrlib.smart.request import (
34
44
FailedSmartServerResponse,
35
46
SmartServerResponse,
36
47
SuccessfulSmartServerResponse,
38
import bzrlib.smart.bzrdir
39
import bzrlib.smart.branch
40
import bzrlib.smart.repository
41
49
from bzrlib.tests import (
44
52
TestScenarioApplier,
54
from bzrlib.transport import chroot, get_transport
46
55
from bzrlib.util import bencode
81
class TestCaseWithChrootedTransport(tests.TestCaseWithTransport):
84
tests.TestCaseWithTransport.setUp(self)
85
self._chroot_server = None
87
def get_transport(self, relpath=None):
88
if self._chroot_server is None:
89
backing_transport = tests.TestCaseWithTransport.get_transport(self)
90
self._chroot_server = chroot.ChrootServer(backing_transport)
91
self._chroot_server.setUp()
92
self.addCleanup(self._chroot_server.tearDown)
93
t = get_transport(self._chroot_server.get_url())
94
if relpath is not None:
72
99
class TestCaseWithSmartMedium(tests.TestCaseWithTransport):
98
125
self.assertNotEqual(None,
99
126
SmartServerResponse(('ok', )))
102
class TestSmartServerRequestFindRepository(tests.TestCaseWithTransport):
128
def test__str__(self):
129
"""SmartServerResponses can be stringified."""
131
"<SmartServerResponse status=OK args=('args',) body='body'>",
132
str(SuccessfulSmartServerResponse(('args',), 'body')))
134
"<SmartServerResponse status=ERR args=('args',) body='body'>",
135
str(FailedSmartServerResponse(('args',), 'body')))
138
class TestSmartServerRequest(tests.TestCaseWithMemoryTransport):
140
def test_translate_client_path(self):
141
transport = self.get_transport()
142
request = SmartServerRequest(transport, 'foo/')
143
self.assertEqual('./', request.translate_client_path('foo/'))
145
errors.InvalidURLJoin, request.translate_client_path, 'foo/..')
147
errors.PathNotChild, request.translate_client_path, '/')
149
errors.PathNotChild, request.translate_client_path, 'bar/')
150
self.assertEqual('./baz', request.translate_client_path('foo/baz'))
152
def test_transport_from_client_path(self):
153
transport = self.get_transport()
154
request = SmartServerRequest(transport, 'foo/')
157
request.transport_from_client_path('foo/').base)
160
class TestSmartServerRequestFindRepository(tests.TestCaseWithMemoryTransport):
103
161
"""Tests for BzrDir.find_repository."""
105
163
def test_no_repository(self):
108
166
request = self._request_class(backing)
109
167
self.make_bzrdir('.')
110
168
self.assertEqual(SmartServerResponse(('norepository', )),
111
request.execute(backing.local_abspath('')))
113
171
def test_nonshared_repository(self):
114
172
# nonshared repositorys only allow 'find' to return a handle when the
117
175
backing = self.get_transport()
118
176
request = self._request_class(backing)
119
177
result = self._make_repository_and_result()
120
self.assertEqual(result, request.execute(backing.local_abspath('')))
178
self.assertEqual(result, request.execute(''))
121
179
self.make_bzrdir('subdir')
122
180
self.assertEqual(SmartServerResponse(('norepository', )),
123
request.execute(backing.local_abspath('subdir')))
181
request.execute('subdir'))
125
183
def _make_repository_and_result(self, shared=False, format=None):
126
184
"""Convenience function to setup a repository.
150
208
backing = self.get_transport()
151
209
request = self._request_class(backing)
152
210
result = self._make_repository_and_result(shared=True)
153
self.assertEqual(result, request.execute(backing.local_abspath('')))
211
self.assertEqual(result, request.execute(''))
154
212
self.make_bzrdir('subdir')
155
213
result2 = SmartServerResponse(result.args[0:1] + ('..', ) + result.args[2:])
156
214
self.assertEqual(result2,
157
request.execute(backing.local_abspath('subdir')))
215
request.execute('subdir'))
158
216
self.make_bzrdir('subdir/deeper')
159
217
result3 = SmartServerResponse(result.args[0:1] + ('../..', ) + result.args[2:])
160
218
self.assertEqual(result3,
161
request.execute(backing.local_abspath('subdir/deeper')))
219
request.execute('subdir/deeper'))
163
221
def test_rich_root_and_subtree_encoding(self):
164
222
"""Test for the format attributes for rich root and subtree support."""
168
226
# check the test will be valid
169
227
self.assertEqual('yes', result.args[2])
170
228
self.assertEqual('yes', result.args[3])
171
self.assertEqual(result, request.execute(backing.local_abspath('')))
229
self.assertEqual(result, request.execute(''))
173
231
def test_supports_external_lookups_no_v2(self):
174
232
"""Test for the supports_external_lookups attribute."""
177
235
result = self._make_repository_and_result(format='dirstate-with-subtree')
178
236
# check the test will be valid
179
237
self.assertEqual('no', result.args[4])
180
self.assertEqual(result, request.execute(backing.local_abspath('')))
183
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithTransport):
238
self.assertEqual(result, request.execute(''))
241
class TestSmartServerRequestInitializeBzrDir(tests.TestCaseWithMemoryTransport):
185
243
def test_empty_dir(self):
186
244
"""Initializing an empty dir should succeed and do it."""
187
245
backing = self.get_transport()
188
246
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
189
247
self.assertEqual(SmartServerResponse(('ok', )),
190
request.execute(backing.local_abspath('.')))
191
249
made_dir = bzrdir.BzrDir.open_from_transport(backing)
192
250
# no branch, tree or repository is expected with the current
193
251
# default formart.
200
258
backing = self.get_transport()
201
259
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
202
260
self.assertRaises(errors.NoSuchFile,
203
request.execute, backing.local_abspath('subdir'))
261
request.execute, 'subdir')
205
263
def test_initialized_dir(self):
206
264
"""Initializing an extant bzrdir should fail like the bzrdir api."""
208
266
request = smart.bzrdir.SmartServerRequestInitializeBzrDir(backing)
209
267
self.make_bzrdir('subdir')
210
268
self.assertRaises(errors.FileExists,
211
request.execute, backing.local_abspath('subdir'))
214
class TestSmartServerRequestOpenBranch(tests.TestCaseWithTransport):
269
request.execute, 'subdir')
272
class TestSmartServerRequestOpenBranch(TestCaseWithChrootedTransport):
216
274
def test_no_branch(self):
217
275
"""When there is no branch, ('nobranch', ) is returned."""
219
277
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
220
278
self.make_bzrdir('.')
221
279
self.assertEqual(SmartServerResponse(('nobranch', )),
222
request.execute(backing.local_abspath('')))
224
282
def test_branch(self):
225
283
"""When there is a branch, 'ok' is returned."""
227
285
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
228
286
self.make_branch('.')
229
287
self.assertEqual(SmartServerResponse(('ok', '')),
230
request.execute(backing.local_abspath('')))
232
290
def test_branch_reference(self):
233
291
"""When there is a branch reference, the reference URL is returned."""
235
293
request = smart.bzrdir.SmartServerRequestOpenBranch(backing)
236
294
branch = self.make_branch('branch')
237
295
checkout = branch.create_checkout('reference',lightweight=True)
238
# TODO: once we have an API to probe for references of any sort, we
240
reference_url = backing.abspath('branch') + '/'
296
reference_url = BranchReferenceFormat().get_reference(checkout.bzrdir)
241
297
self.assertFileEqual(reference_url, 'reference/.bzr/branch/location')
242
298
self.assertEqual(SmartServerResponse(('ok', reference_url)),
243
request.execute(backing.local_abspath('reference')))
246
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithTransport):
299
request.execute('reference'))
302
class TestSmartServerRequestRevisionHistory(tests.TestCaseWithMemoryTransport):
248
304
def test_empty(self):
249
305
"""For an empty branch, the body is empty."""
251
307
request = smart.branch.SmartServerRequestRevisionHistory(backing)
252
308
self.make_branch('.')
253
309
self.assertEqual(SmartServerResponse(('ok', ), ''),
254
request.execute(backing.local_abspath('')))
256
312
def test_not_empty(self):
257
313
"""For a non-empty branch, the body is empty."""
266
322
self.assertEqual(
267
323
SmartServerResponse(('ok', ), ('\x00'.join([r1, r2]))),
268
request.execute(backing.local_abspath('')))
271
class TestSmartServerBranchRequest(tests.TestCaseWithTransport):
327
class TestSmartServerBranchRequest(tests.TestCaseWithMemoryTransport):
273
329
def test_no_branch(self):
274
330
"""When there is a bzrdir and no branch, NotBranchError is raised."""
276
332
request = smart.branch.SmartServerBranchRequest(backing)
277
333
self.make_bzrdir('.')
278
334
self.assertRaises(errors.NotBranchError,
279
request.execute, backing.local_abspath(''))
281
337
def test_branch_reference(self):
282
338
"""When there is a branch reference, NotBranchError is raised."""
285
341
branch = self.make_branch('branch')
286
342
checkout = branch.create_checkout('reference',lightweight=True)
287
343
self.assertRaises(errors.NotBranchError,
288
request.execute, backing.local_abspath('checkout'))
291
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithTransport):
344
request.execute, 'checkout')
347
class TestSmartServerBranchRequestLastRevisionInfo(tests.TestCaseWithMemoryTransport):
293
349
def test_empty(self):
294
350
"""For an empty branch, the result is ('ok', '0', 'null:')."""
296
352
request = smart.branch.SmartServerBranchRequestLastRevisionInfo(backing)
297
353
self.make_branch('.')
298
354
self.assertEqual(SmartServerResponse(('ok', '0', 'null:')),
299
request.execute(backing.local_abspath('')))
301
357
def test_not_empty(self):
302
358
"""For a non-empty branch, the result is ('ok', 'revno', 'revid')."""
312
368
self.assertEqual(
313
369
SmartServerResponse(('ok', '2', rev_id_utf8)),
314
request.execute(backing.local_abspath('')))
317
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithTransport):
373
class TestSmartServerBranchRequestGetConfigFile(tests.TestCaseWithMemoryTransport):
319
375
def test_default(self):
320
376
"""With no file, we get empty content."""
324
380
# there should be no file by default
326
382
self.assertEqual(SmartServerResponse(('ok', ), content),
327
request.execute(backing.local_abspath('')))
329
385
def test_with_content(self):
330
386
# SmartServerBranchGetConfigFile should return the content from
335
391
branch = self.make_branch('.')
336
392
branch.control_files.put_utf8('branch.conf', 'foo bar baz')
337
393
self.assertEqual(SmartServerResponse(('ok', ), 'foo bar baz'),
338
request.execute(backing.local_abspath('')))
341
class TestSmartServerBranchRequestSetLastRevision(tests.TestCaseWithTransport):
397
class TestSmartServerBranchRequestSetLastRevision(tests.TestCaseWithMemoryTransport):
343
399
def test_empty(self):
344
400
backing = self.get_transport()
351
407
self.assertEqual(SmartServerResponse(('ok',)),
353
backing.local_abspath(''), branch_token, repo_token,
409
'', branch_token, repo_token,
367
423
self.assertEqual(
368
424
SmartServerResponse(('NoSuchRevision', revision_id)),
370
backing.local_abspath(''), branch_token, repo_token,
426
'', branch_token, repo_token,
389
445
self.assertEqual(
390
446
SmartServerResponse(('ok',)),
392
backing.local_abspath(''), branch_token, repo_token,
448
'', branch_token, repo_token,
394
450
self.assertEqual([rev_id_utf8], tree.branch.revision_history())
413
469
self.assertEqual(
414
470
SmartServerResponse(('ok',)),
416
backing.local_abspath(''), branch_token, repo_token,
472
'', branch_token, repo_token,
418
474
self.assertEqual([rev_id_utf8], tree.branch.revision_history())
420
476
tree.branch.unlock()
423
class TestSmartServerBranchRequestLockWrite(tests.TestCaseWithTransport):
479
class TestSmartServerBranchRequestLockWrite(tests.TestCaseWithMemoryTransport):
426
tests.TestCaseWithTransport.setUp(self)
482
tests.TestCaseWithMemoryTransport.setUp(self)
428
484
def test_lock_write_on_unlocked_branch(self):
429
485
backing = self.get_transport()
430
486
request = smart.branch.SmartServerBranchRequestLockWrite(backing)
431
487
branch = self.make_branch('.', format='knit')
432
488
repository = branch.repository
433
response = request.execute(backing.local_abspath(''))
489
response = request.execute('')
434
490
branch_nonce = branch.control_files._lock.peek().get('nonce')
435
491
repository_nonce = repository.control_files._lock.peek().get('nonce')
436
492
self.assertEqual(
448
504
branch.lock_write()
449
505
branch.leave_lock_in_place()
451
response = request.execute(backing.local_abspath(''))
507
response = request.execute('')
452
508
self.assertEqual(
453
509
SmartServerResponse(('LockContention',)), response)
462
518
branch.leave_lock_in_place()
463
519
branch.repository.leave_lock_in_place()
465
response = request.execute(backing.local_abspath(''),
521
response = request.execute('',
466
522
branch_token, repo_token)
467
523
self.assertEqual(
468
524
SmartServerResponse(('ok', branch_token, repo_token)), response)
477
533
branch.leave_lock_in_place()
478
534
branch.repository.leave_lock_in_place()
480
response = request.execute(backing.local_abspath(''),
536
response = request.execute('',
481
537
branch_token+'xxx', repo_token)
482
538
self.assertEqual(
483
539
SmartServerResponse(('TokenMismatch',)), response)
489
545
branch.repository.lock_write()
490
546
branch.repository.leave_lock_in_place()
491
547
branch.repository.unlock()
492
response = request.execute(backing.local_abspath(''))
548
response = request.execute('')
493
549
self.assertEqual(
494
550
SmartServerResponse(('LockContention',)), response)
497
553
backing = self.get_readonly_transport()
498
554
request = smart.branch.SmartServerBranchRequestLockWrite(backing)
499
555
branch = self.make_branch('.')
500
response = request.execute('')
556
root = self.get_transport().clone('/')
557
path = urlutils.relative_url(root.base, self.get_transport().base)
558
response = request.execute(path)
501
559
error_name, lock_str, why_str = response.args
502
560
self.assertFalse(response.is_successful())
503
561
self.assertEqual('LockFailed', error_name)
506
class TestSmartServerBranchRequestUnlock(tests.TestCaseWithTransport):
564
class TestSmartServerBranchRequestUnlock(tests.TestCaseWithMemoryTransport):
509
tests.TestCaseWithTransport.setUp(self)
567
tests.TestCaseWithMemoryTransport.setUp(self)
511
569
def test_unlock_on_locked_branch_and_repo(self):
512
570
backing = self.get_transport()
521
579
branch.leave_lock_in_place()
522
580
branch.repository.leave_lock_in_place()
524
response = request.execute(backing.local_abspath(''),
582
response = request.execute('',
525
583
branch_token, repo_token)
526
584
self.assertEqual(
527
585
SmartServerResponse(('ok',)), response)
536
594
request = smart.branch.SmartServerBranchRequestUnlock(backing)
537
595
branch = self.make_branch('.', format='knit')
538
596
response = request.execute(
539
backing.local_abspath(''), 'branch token', 'repo token')
597
'', 'branch token', 'repo token')
540
598
self.assertEqual(
541
599
SmartServerResponse(('TokenMismatch',)), response)
551
609
# Issue branch lock_write request on the unlocked branch (with locked
553
611
response = request.execute(
554
backing.local_abspath(''), 'branch token', repo_token)
612
'', 'branch token', repo_token)
555
613
self.assertEqual(
556
614
SmartServerResponse(('TokenMismatch',)), response)
559
class TestSmartServerRepositoryRequest(tests.TestCaseWithTransport):
617
class TestSmartServerRepositoryRequest(tests.TestCaseWithMemoryTransport):
561
619
def test_no_repository(self):
562
620
"""Raise NoRepositoryPresent when there is a bzrdir and no repo."""
569
627
self.make_repository('.', shared=True)
570
628
self.make_bzrdir('subdir')
571
629
self.assertRaises(errors.NoRepositoryPresent,
572
request.execute, backing.local_abspath('subdir'))
630
request.execute, 'subdir')
575
633
class TestSmartServerRepositoryGetParentMap(tests.TestCaseWithTransport):
581
639
tree = self.make_branch_and_memory_tree('.')
583
641
self.assertEqual(None,
584
request.execute(backing.local_abspath(''), 'missing-id'))
642
request.execute('', 'missing-id'))
585
643
# Note that it returns a body (of '' bzipped).
586
644
self.assertEqual(
587
645
SuccessfulSmartServerResponse(('ok', ), bz2.compress('')),
588
646
request.do_body('\n\n0\n'))
591
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithTransport):
649
class TestSmartServerRepositoryGetRevisionGraph(tests.TestCaseWithMemoryTransport):
593
651
def test_none_argument(self):
594
652
backing = self.get_transport()
603
661
# the lines of revision_id->revision_parent_list has no guaranteed
604
662
# order coming out of a dict, so sort both our test and response
605
663
lines = sorted([' '.join([r2, r1]), r1])
606
response = request.execute(backing.local_abspath(''), '')
664
response = request.execute('', '')
607
665
response.body = '\n'.join(sorted(response.body.split('\n')))
609
667
self.assertEqual(
623
681
self.assertEqual(SmartServerResponse(('ok', ), rev_id_utf8),
624
request.execute(backing.local_abspath(''), rev_id_utf8))
682
request.execute('', rev_id_utf8))
626
684
def test_no_such_revision(self):
627
685
backing = self.get_transport()
635
693
# Note that it still returns body (of zero bytes).
636
694
self.assertEqual(
637
695
SmartServerResponse(('nosuchrevision', 'missingrevision', ), ''),
638
request.execute(backing.local_abspath(''), 'missingrevision'))
641
class TestSmartServerRequestHasRevision(tests.TestCaseWithTransport):
696
request.execute('', 'missingrevision'))
699
class TestSmartServerRequestHasRevision(tests.TestCaseWithMemoryTransport):
643
701
def test_missing_revision(self):
644
702
"""For a missing revision, ('no', ) is returned."""
646
704
request = smart.repository.SmartServerRequestHasRevision(backing)
647
705
self.make_repository('.')
648
706
self.assertEqual(SmartServerResponse(('no', )),
649
request.execute(backing.local_abspath(''), 'revid'))
707
request.execute('', 'revid'))
651
709
def test_present_revision(self):
652
710
"""For a present revision, ('yes', ) is returned."""
661
719
self.assertTrue(tree.branch.repository.has_revision(rev_id_utf8))
662
720
self.assertEqual(SmartServerResponse(('yes', )),
663
request.execute(backing.local_abspath(''), rev_id_utf8))
666
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithTransport):
721
request.execute('', rev_id_utf8))
724
class TestSmartServerRepositoryGatherStats(tests.TestCaseWithMemoryTransport):
668
726
def test_empty_revid(self):
669
727
"""With an empty revid, we get only size an number and revisions"""
674
732
size = stats['size']
675
733
expected_body = 'revisions: 0\nsize: %d\n' % size
676
734
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
677
request.execute(backing.local_abspath(''), '', 'no'))
735
request.execute('', '', 'no'))
679
737
def test_revid_with_committers(self):
680
738
"""For a revid we get more infos."""
698
756
'size: %d\n' % size)
699
757
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
700
request.execute(backing.local_abspath(''),
701
759
rev_id_utf8, 'no'))
703
761
def test_not_empty_repository_with_committers(self):
724
782
'size: %d\n' % size)
725
783
self.assertEqual(SmartServerResponse(('ok', ), expected_body),
726
request.execute(backing.local_abspath(''),
727
785
rev_id_utf8, 'yes'))
730
class TestSmartServerRepositoryIsShared(tests.TestCaseWithTransport):
788
class TestSmartServerRepositoryIsShared(tests.TestCaseWithMemoryTransport):
732
790
def test_is_shared(self):
733
791
"""For a shared repository, ('yes', ) is returned."""
735
793
request = smart.repository.SmartServerRepositoryIsShared(backing)
736
794
self.make_repository('.', shared=True)
737
795
self.assertEqual(SmartServerResponse(('yes', )),
738
request.execute(backing.local_abspath(''), ))
796
request.execute('', ))
740
798
def test_is_not_shared(self):
741
799
"""For a shared repository, ('no', ) is returned."""
743
801
request = smart.repository.SmartServerRepositoryIsShared(backing)
744
802
self.make_repository('.', shared=False)
745
803
self.assertEqual(SmartServerResponse(('no', )),
746
request.execute(backing.local_abspath(''), ))
749
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithTransport):
804
request.execute('', ))
807
class TestSmartServerRepositoryLockWrite(tests.TestCaseWithMemoryTransport):
752
tests.TestCaseWithTransport.setUp(self)
810
tests.TestCaseWithMemoryTransport.setUp(self)
754
812
def test_lock_write_on_unlocked_repo(self):
755
813
backing = self.get_transport()
756
814
request = smart.repository.SmartServerRepositoryLockWrite(backing)
757
815
repository = self.make_repository('.', format='knit')
758
response = request.execute(backing.local_abspath(''))
816
response = request.execute('')
759
817
nonce = repository.control_files._lock.peek().get('nonce')
760
818
self.assertEqual(SmartServerResponse(('ok', nonce)), response)
761
819
# The repository is now locked. Verify that with a new repository
770
828
repository.lock_write()
771
829
repository.leave_lock_in_place()
772
830
repository.unlock()
773
response = request.execute(backing.local_abspath(''))
831
response = request.execute('')
774
832
self.assertEqual(
775
833
SmartServerResponse(('LockContention',)), response)
783
841
self.assertEqual('LockFailed', response.args[0])
786
class TestSmartServerRepositoryUnlock(tests.TestCaseWithTransport):
844
class TestSmartServerRepositoryUnlock(tests.TestCaseWithMemoryTransport):
789
tests.TestCaseWithTransport.setUp(self)
847
tests.TestCaseWithMemoryTransport.setUp(self)
791
849
def test_unlock_on_locked_repo(self):
792
850
backing = self.get_transport()
795
853
token = repository.lock_write()
796
854
repository.leave_lock_in_place()
797
855
repository.unlock()
798
response = request.execute(backing.local_abspath(''), token)
856
response = request.execute('', token)
799
857
self.assertEqual(
800
858
SmartServerResponse(('ok',)), response)
801
859
# The repository is now unlocked. Verify that with a new repository
808
866
backing = self.get_transport()
809
867
request = smart.repository.SmartServerRepositoryUnlock(backing)
810
868
repository = self.make_repository('.', format='knit')
811
response = request.execute(backing.local_abspath(''), 'some token')
869
response = request.execute('', 'some token')
812
870
self.assertEqual(
813
871
SmartServerResponse(('TokenMismatch',)), response)
822
880
# make some extraneous junk in the repository directory which should
824
882
self.build_tree(['.bzr/repository/extra-junk'])
825
response = request.execute(backing.local_abspath(''), 'bz2')
883
response = request.execute('', 'bz2')
826
884
self.assertEqual(('ok',), response.args)
827
885
# body should be a tbz2
828
886
body_file = StringIO(response.body)
837
895
"extraneous file present in tar file")
840
class TestSmartServerRepositoryStreamKnitData(tests.TestCaseWithTransport):
898
class TestSmartServerRepositoryStreamKnitData(tests.TestCaseWithMemoryTransport):
842
900
def test_fetch_revisions(self):
843
901
backing = self.get_transport()
851
909
r1 = tree.commit('2nd commit', rev_id=rev_id2_utf8)
854
response = request.execute(backing.local_abspath(''), rev_id2_utf8)
912
response = request.execute('', rev_id2_utf8)
855
913
self.assertEqual(('ok',), response.args)
856
from cStringIO import StringIO
857
914
unpacker = pack.ContainerReader(StringIO(response.body))
859
916
for [name], read_bytes in unpacker.iter_records():
869
926
request = smart.repository.SmartServerRepositoryStreamKnitDataForRevisions(backing)
870
927
repo = self.make_repository('.')
871
928
rev_id1_utf8 = u'\xc8'.encode('utf-8')
872
response = request.execute(backing.local_abspath(''), rev_id1_utf8)
929
response = request.execute('', rev_id1_utf8)
873
930
self.assertEqual(
874
931
SmartServerResponse(('NoSuchRevision', rev_id1_utf8)),
878
class TestSmartServerRepositoryStreamRevisionsChunked(tests.TestCaseWithTransport):
935
class TestSmartServerRepositoryStreamRevisionsChunked(tests.TestCaseWithMemoryTransport):
880
937
def test_fetch_revisions(self):
881
938
backing = self.get_transport()
890
947
tree.commit('2nd commit', rev_id=rev_id2_utf8)
893
response = request.execute(backing.local_abspath(''))
950
response = request.execute('')
894
951
self.assertEqual(None, response)
895
952
response = request.do_body("%s\n%s\n1" % (rev_id2_utf8, rev_id1_utf8))
896
953
self.assertEqual(('ok',), response.args)
897
from cStringIO import StringIO
898
954
parser = pack.ContainerPushParser()
900
956
for stream_bytes in response.body_stream:
913
969
repo = self.make_repository('.')
914
970
rev_id1_utf8 = u'\xc8'.encode('utf-8')
915
response = request.execute(backing.local_abspath(''))
971
response = request.execute('')
916
972
self.assertEqual(None, response)
917
973
response = request.do_body("%s\n\n1" % (rev_id1_utf8,))
918
974
self.assertEqual(