#!/usr/bin/python3
+import io
import os
import unittest
"""
Creates an upload of a certain size, but then tries to write more data
"""
+ payload = io.BytesIO(b"01234567890123456789")
+
with self.db.transaction():
upload = self.backend.uploads.create("test.blob", size=20, user=self.user)
# Try to write more than 20 bytes
with self.assertRaises(OverflowError):
- await upload.write(b"012345678901234567890123456789")
+ await upload.copyfrom(payload)
async def test_check_digest(self):
"""
Creates an upload and checks if the digest matches
"""
+ payload = io.BytesIO(b"01234567890123456789")
+
with self.db.transaction():
upload = self.backend.uploads.create("test.blob", size=20, user=self.user)
# Write some payload
- await upload.write(b"01234567890123456789")
-
- # Complete the upload
- with self.db.transaction():
- await upload.completed()
+ await upload.copyfrom(payload)
digest = bytes.fromhex("185c728c3fccb51875d74e21fec19f4cdfad8d5aa347a7a75c06473"
"af6f73835b5a00515a34f0e09725d5b1e0715ce43a1a57d966a92400efd215e45dd19c09c")