]> git.ipfire.org Git - pbs.git/commitdiff
tests: uploads: Use new functions
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Oct 2022 21:08:59 +0000 (21:08 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 23 Oct 2022 21:08:59 +0000 (21:08 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/upload.py

index 8f96e7b218d7e43cf4dcdf9d3f056b40834292f4..8f3700655da48f23c03678edf545ee217a06cda6 100755 (executable)
@@ -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")