forked from LBRYCommunity/lbry-sdk
add test for invalid content
This commit is contained in:
parent
56522f39c0
commit
f291ea515a
1 changed files with 12 additions and 1 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue