add test for invalid content

This commit is contained in:
Victor Shyba 2018-07-27 00:21:16 -03:00
parent 56522f39c0
commit f291ea515a

View file

@ -36,6 +36,14 @@ class HTTPBlobDownloaderTest(unittest.TestCase):
self.assertEqual(self.blob.get_is_verified(), True)
self.assertEqual(self.blob.writers, {})
@defer.inlineCallbacks
def test_download_invalid_content(self):
self.client.collect.side_effect = bad_collect
yield self.downloader.start()
self.assertEqual(self.blob.get_length(), self.response.length)
self.assertEqual(self.blob.get_is_verified(), False)
self.assertEqual(self.blob.writers, {})
@defer.inlineCallbacks
def test_peer_finished_first_causing_a_write_on_closed_handle(self):
self.client.collect.side_effect = lambda response, write: defer.fail(IOError('I/O operation on closed file'))
@ -69,4 +77,7 @@ class HTTPBlobDownloaderTest(unittest.TestCase):
def collect(response, write):
write('f' * response.length)
defer.succeed(None)
def bad_collect(response, write):
write('0' * response.length)