Commit 3a37f90a authored by Jim Fulton's avatar Jim Fulton

Unwritten blobs now can be read and have no data,

Hack os.rename rather than the blob to avoid a testing artifact in the
blob implementation.
parent 11eb7cd5
...@@ -69,24 +69,20 @@ exception will be re-raised and the target file will not exist:: ...@@ -69,24 +69,20 @@ exception will be re-raised and the target file will not exist::
>>> open('to_import', 'wb').write('Some data.') >>> open('to_import', 'wb').write('Some data.')
>>> def failing_link(self, filename): >>> def failing_rename(self, filename):
... raise Exception("I can't link.") ... raise Exception("I can't link.")
>>> blob = Blob() >>> blob = Blob()
>>> blob.open('r') >>> os_rename = os.rename
Traceback (most recent call last): >>> os.rename = failing_rename
BlobError: Blob does not exist.
>>> blob._os_link = failing_link
>>> blob.consumeFile('to_import') >>> blob.consumeFile('to_import')
Traceback (most recent call last): Traceback (most recent call last):
Exception: I can't link. Exception: I can't link.
The blob did not exist before, so it shouldn't exist now:: The blob did not have data before, so it shouldn't have data now::
>>> blob.open('r') >>> blob.open('r').read()
Traceback (most recent call last): ''
BlobError: Blob does not exist.
Case 2: We thave uncommitted data, but the link operation fails. The Case 2: We thave uncommitted data, but the link operation fails. The
exception will be re-raised and the target file will exist with the previous exception will be re-raised and the target file will exist with the previous
...@@ -97,7 +93,6 @@ uncomitted data:: ...@@ -97,7 +93,6 @@ uncomitted data::
>>> blob_writing.write('Uncommitted data') >>> blob_writing.write('Uncommitted data')
>>> blob_writing.close() >>> blob_writing.close()
>>> blob._os_link = failing_link
>>> blob.consumeFile('to_import') >>> blob.consumeFile('to_import')
Traceback (most recent call last): Traceback (most recent call last):
Exception: I can't link. Exception: I can't link.
...@@ -107,3 +102,5 @@ changed:: ...@@ -107,3 +102,5 @@ changed::
>>> blob.open('r').read() >>> blob.open('r').read()
'Uncommitted data' 'Uncommitted data'
>>> os.rename = os_rename
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment