From: Michael Tremer Date: Sun, 23 Oct 2022 21:08:59 +0000 (+0000) Subject: tests: uploads: Use new functions X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0c066773df606cfb44d1bf3d995a37f779ffc6de;p=pbs.git tests: uploads: Use new functions Signed-off-by: Michael Tremer --- diff --git a/tests/upload.py b/tests/upload.py index 8f96e7b2..8f370065 100755 --- a/tests/upload.py +++ b/tests/upload.py @@ -1,5 +1,6 @@ #!/usr/bin/python3 +import io import os import unittest @@ -35,26 +36,26 @@ class UploadTestCase(test.TestCase): """ 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")