Unverified Commit 942367fc authored by Agate's avatar Agate 💬
Browse files

Ensure 0 quota on user is honored

parent 1a752287
......@@ -258,7 +258,11 @@ class User(AbstractUser):
return self.actor
def get_upload_quota(self):
return self.upload_quota or preferences.get("users__upload_quota")
return (
self.upload_quota
if self.upload_quota is not None
else preferences.get("users__upload_quota")
)
def get_quota_status(self):
data = self.actor.get_current_usage()
......
......@@ -185,18 +185,17 @@ def test_get_channels_groups(factories):
]
def test_user_quota_default_to_preference(factories, preferences):
preferences["users__upload_quota"] = 42
user = factories["users.User"]()
assert user.get_upload_quota() == 42
def test_user_quota_set_on_user(factories, preferences):
preferences["users__upload_quota"] = 42
@pytest.mark.parametrize(
"default_quota, user_quota, expected",
[(1000, None, 1000), (1000, 42, 42), (1000, 0, 0)],
)
def test_user_quota_set_on_user(
default_quota, user_quota, expected, factories, preferences
):
preferences["users__upload_quota"] = default_quota
user = factories["users.User"](upload_quota=66)
assert user.get_upload_quota() == 66
user = factories["users.User"](upload_quota=user_quota)
assert user.get_upload_quota() == expected
def test_user_get_quota_status(factories, preferences, mocker):
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment