]> git.ipfire.org Git - pbs.git/commitdiff
tests: uploads: Add a test for quotas
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 14:39:46 +0000 (14:39 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 18 Oct 2022 14:39:46 +0000 (14:39 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
tests/test.py
tests/upload.py

index 1ffa3124ee51d43ec81b92e7af5928ddae716799..40782a56dfcfdc4adde7ddfc4a4009b98497b352 100644 (file)
@@ -125,6 +125,9 @@ class TestCase(unittest.IsolatedAsyncioTestCase):
                        "email" : [b"joe.tester@ipfire.org"],
                })
 
+               # Set a quota
+               self.user.quota = 104857600 # 100 MiB
+
                # Create a distribution
                self.distro = self.backend.distros.create("Default Test Distribution", "test1")
 
index 8f3a2caa508ff4379464ef143274b3a5e6213a47..d34d62d984ca34452f744fcc466dfa987d9e6353 100755 (executable)
@@ -6,6 +6,7 @@ import unittest
 import test
 
 from buildservice import uploads
+from buildservice import users
 
 class UploadTestCase(test.TestCase):
        """
@@ -57,6 +58,19 @@ class UploadTestCase(test.TestCase):
                # Check the digest
                self.assertTrue(await upload.check_digest("blake2b", digest))
 
+       async def test_quota(self):
+               """
+                       Tries to create an upload that exceeds the quota
+               """
+               # Create an upload that is 200 MiB large
+               with self.db.transaction():
+                       with self.assertRaises(users.QuotaExceededError):
+                               self.backend.uploads.create(
+                                       "test.blob",
+                                       size=209715200,
+                                       user=self.user,
+                               )
+
 
 if __name__ == "__main__":
        unittest.main()