280
280
self.expecting_body = True
281
281
return result[1], FakeProtocol(result[2], self)
283
def call_with_body_bytes(self, method, args, body):
284
self._check_call(method, args)
285
self._calls.append(('call_with_body_bytes', method, args, body))
286
result = self._get_next_response()
287
return result[1], FakeProtocol(result[2], self)
283
289
def call_with_body_bytes_expecting_body(self, method, args, body):
284
290
self._check_call(method, args)
285
291
self._calls.append(('call_with_body_bytes_expecting_body', method,
852
858
class RemoteBranchTestCase(RemoteBzrDirTestCase):
860
def lock_remote_branch(self, branch):
861
"""Trick a RemoteBranch into thinking it is locked."""
862
branch._lock_mode = 'w'
863
branch._lock_count = 2
864
branch._lock_token = 'branch token'
865
branch._repo_lock_token = 'repo token'
866
branch.repository._lock_mode = 'w'
867
branch.repository._lock_count = 2
868
branch.repository._lock_token = 'repo token'
854
870
def make_remote_branch(self, transport, client):
855
871
"""Make a RemoteBranch using 'client' as its _SmartClient.
995
1011
self.assertEqual({}, result)
1014
class TestBranchSetTagsBytes(RemoteBranchTestCase):
1016
def test_trivial(self):
1017
transport = MemoryTransport()
1018
client = FakeClient(transport.base)
1019
client.add_expected_call(
1020
'Branch.get_stacked_on_url', ('quack/',),
1021
'error', ('NotStacked',))
1022
client.add_expected_call(
1023
'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
1025
transport.mkdir('quack')
1026
transport = transport.clone('quack')
1027
branch = self.make_remote_branch(transport, client)
1028
self.lock_remote_branch(branch)
1029
branch._set_tags_bytes('tags bytes')
1030
self.assertFinished(client)
1031
self.assertEqual('tags bytes', client._calls[-1][-1])
1033
def test_backwards_compatible(self):
1034
transport = MemoryTransport()
1035
client = FakeClient(transport.base)
1036
client.add_expected_call(
1037
'Branch.get_stacked_on_url', ('quack/',),
1038
'error', ('NotStacked',))
1039
client.add_expected_call(
1040
'Branch.set_tags_bytes', ('quack/', 'branch token', 'repo token'),
1041
'unknown', ('Branch.set_tags_bytes',))
1042
transport.mkdir('quack')
1043
transport = transport.clone('quack')
1044
branch = self.make_remote_branch(transport, client)
1045
self.lock_remote_branch(branch)
1046
class StubRealBranch(object):
1049
def _set_tags_bytes(self, bytes):
1050
self.calls.append(('set_tags_bytes', bytes))
1051
real_branch = StubRealBranch()
1052
branch._real_branch = real_branch
1053
branch._set_tags_bytes('tags bytes')
1054
# Call a second time, to exercise the 'remote version already inferred'
1056
branch._set_tags_bytes('tags bytes')
1057
self.assertFinished(client)
1059
[('set_tags_bytes', 'tags bytes')] * 2, real_branch.calls)
998
1062
class TestBranchLastRevisionInfo(RemoteBranchTestCase):
1000
1064
def test_empty_branch(self):
1342
1406
errors.NoSuchRevision, branch.set_last_revision_info, 123, 'revid')
1343
1407
branch.unlock()
1345
def lock_remote_branch(self, branch):
1346
"""Trick a RemoteBranch into thinking it is locked."""
1347
branch._lock_mode = 'w'
1348
branch._lock_count = 2
1349
branch._lock_token = 'branch token'
1350
branch._repo_lock_token = 'repo token'
1351
branch.repository._lock_mode = 'w'
1352
branch.repository._lock_count = 2
1353
branch.repository._lock_token = 'repo token'
1355
1409
def test_backwards_compatibility(self):
1356
1410
"""If the server does not support the Branch.set_last_revision_info
1357
1411
verb (which is new in 1.4), then the client falls back to VFS methods.