add some more tests for deleting blob files
This commit is contained in:
parent
533835a732
commit
cf3a0e2e9d
1 changed files with 21 additions and 0 deletions
|
@ -44,9 +44,15 @@ class BlobFileTest(unittest.TestCase):
|
|||
blob_file = BlobFile(self.blob_dir, self.fake_content_hash, self.fake_content_len)
|
||||
self.assertTrue(blob_file.verified)
|
||||
f = blob_file.open_for_reading()
|
||||
self.assertEqual(1, blob_file.readers)
|
||||
c = f.read()
|
||||
self.assertEqual(c, self.fake_content)
|
||||
|
||||
# close reader
|
||||
f.close()
|
||||
self.assertEqual(0, blob_file.readers)
|
||||
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_delete(self):
|
||||
blob_file = BlobFile(self.blob_dir, self.fake_content_hash, self.fake_content_len)
|
||||
|
@ -58,6 +64,21 @@ class BlobFileTest(unittest.TestCase):
|
|||
blob_file = BlobFile(self.blob_dir, self.fake_content_hash)
|
||||
self.assertFalse(blob_file.verified)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_delete_fail(self):
|
||||
# deletes should fail if being written to
|
||||
blob_file = BlobFile(self.blob_dir, self.fake_content_hash, self.fake_content_len)
|
||||
writer, finished_d = blob_file.open_for_writing(peer=1)
|
||||
yield self.assertFailure(blob_file.delete(), ValueError)
|
||||
writer.write(self.fake_content)
|
||||
writer.close()
|
||||
|
||||
# deletes should fail if being read and not closed
|
||||
blob_file = BlobFile(self.blob_dir, self.fake_content_hash, self.fake_content_len)
|
||||
self.assertTrue(blob_file.verified)
|
||||
f = blob_file.open_for_reading()
|
||||
yield self.assertFailure(blob_file.delete(), ValueError)
|
||||
|
||||
@defer.inlineCallbacks
|
||||
def test_too_much_write(self):
|
||||
# writing too much data should result in failure
|
||||
|
|
Loading…
Add table
Reference in a new issue