From: Michael Tremer Date: Tue, 18 Oct 2022 14:39:46 +0000 (+0000) Subject: tests: uploads: Add a test for quotas X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3a1751316fd9cda9e5e01b6bc0a385754e816f1;p=pbs.git tests: uploads: Add a test for quotas Signed-off-by: Michael Tremer --- diff --git a/tests/test.py b/tests/test.py index 1ffa3124..40782a56 100644 --- a/tests/test.py +++ b/tests/test.py @@ -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") diff --git a/tests/upload.py b/tests/upload.py index 8f3a2caa..d34d62d9 100755 --- a/tests/upload.py +++ b/tests/upload.py @@ -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()