270
270
stream = list(stream)
271
271
self._check_call(args[0], args[1:])
272
272
self._calls.append(('call_with_body_stream', args[0], args[1:], stream))
273
return self._get_next_response()[1]
273
result = self._get_next_response()
274
# The second value returned from call_with_body_stream is supposed to
275
# be a response_handler object, but so far no tests depend on that.
276
response_handler = None
277
return result[1], response_handler
276
280
class FakeMedium(medium.SmartClientMedium):
1825
1829
self.assertEqual([], client._calls)
1832
class TestRepositoryInsertStream(TestRemoteRepository):
1834
def test_unlocked_repo(self):
1835
transport_path = 'quack'
1836
repo, client = self.setup_fake_client_and_repository(transport_path)
1837
client.add_expected_call(
1838
'Repository.insert_stream', ('quack/', ''),
1840
client.add_expected_call(
1841
'Repository.insert_stream', ('quack/', ''),
1843
sink = repo._get_sink()
1844
fmt = repository.RepositoryFormat.get_default_format()
1845
resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
1846
self.assertEqual([], resume_tokens)
1847
self.assertEqual(set(), missing_keys)
1848
client.finished_test()
1850
def test_locked_repo_with_no_lock_token(self):
1851
transport_path = 'quack'
1852
repo, client = self.setup_fake_client_and_repository(transport_path)
1853
client.add_expected_call(
1854
'Repository.lock_write', ('quack/', ''),
1855
'success', ('ok', ''))
1856
client.add_expected_call(
1857
'Repository.insert_stream', ('quack/', ''),
1859
client.add_expected_call(
1860
'Repository.insert_stream', ('quack/', ''),
1863
sink = repo._get_sink()
1864
fmt = repository.RepositoryFormat.get_default_format()
1865
resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
1866
self.assertEqual([], resume_tokens)
1867
self.assertEqual(set(), missing_keys)
1868
client.finished_test()
1870
def test_locked_repo_with_lock_token(self):
1871
transport_path = 'quack'
1872
repo, client = self.setup_fake_client_and_repository(transport_path)
1873
client.add_expected_call(
1874
'Repository.lock_write', ('quack/', ''),
1875
'success', ('ok', 'a token'))
1876
client.add_expected_call(
1877
'Repository.insert_stream_locked', ('quack/', '', 'a token'),
1879
client.add_expected_call(
1880
'Repository.insert_stream_locked', ('quack/', '', 'a token'),
1883
sink = repo._get_sink()
1884
fmt = repository.RepositoryFormat.get_default_format()
1885
resume_tokens, missing_keys = sink.insert_stream([], fmt, [])
1886
self.assertEqual([], resume_tokens)
1887
self.assertEqual(set(), missing_keys)
1888
client.finished_test()
1828
1891
class TestRepositoryTarball(TestRemoteRepository):
1830
1893
# This is a canned tarball reponse we can validate against