From f291ea515a7496b3779e8ecf7f6b805aca9fc982 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Fri, 27 Jul 2018 00:21:16 -0300 Subject: [PATCH] add test for invalid content --- lbrynet/tests/unit/core/test_HTTPBlobDownloader.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lbrynet/tests/unit/core/test_HTTPBlobDownloader.py b/lbrynet/tests/unit/core/test_HTTPBlobDownloader.py index 80ded1ce1..a06f9e66a 100644 --- a/lbrynet/tests/unit/core/test_HTTPBlobDownloader.py +++ b/lbrynet/tests/unit/core/test_HTTPBlobDownloader.py @@ -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)