From edb5083a5e015baa9681624fe1adf10b783de0d8 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Thu, 21 Feb 2019 20:53:04 -0300 Subject: [PATCH] test that corrupted sd blobs gets delete if fails to decode --- tests/unit/stream/test_stream_descriptor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/stream/test_stream_descriptor.py b/tests/unit/stream/test_stream_descriptor.py index 686eaadef..36353c772 100644 --- a/tests/unit/stream/test_stream_descriptor.py +++ b/tests/unit/stream/test_stream_descriptor.py @@ -109,14 +109,17 @@ class TestRecoverOldStreamDescriptors(AsyncioTestCase): self.assertEqual(sd_hash, descriptor.calculate_old_sort_sd_hash()) self.assertNotEqual(sd_hash, descriptor.calculate_sd_hash()) - async def test_decode_corrupt_blob_raises_proper_exception(self): + async def test_decode_corrupt_blob_raises_proper_exception_and_deletes_corrupt_file(self): loop = asyncio.get_event_loop() tmp_dir = tempfile.mkdtemp() self.addCleanup(lambda: shutil.rmtree(tmp_dir)) sd_hash = '9313d1807551186126acc3662e74d9de29cede78d4f133349ace846273ef116b9bb86be86c54509eb84840e4b032f6b2' with open(os.path.join(tmp_dir, sd_hash), 'wb') as handle: handle.write(b'doesnt work') + blob = BlobFile(loop, tmp_dir, sd_hash) + self.assertTrue(blob.file_exists) with self.assertRaises(InvalidStreamDescriptorError): await StreamDescriptor.from_stream_descriptor_blob( loop, tmp_dir, BlobFile(loop, tmp_dir, sd_hash) ) + self.assertFalse(blob.file_exists)