funkwhale/api/tests/manage/test_serializers.py

39 wiersze
1.1 KiB
Python
Czysty Zwykły widok Historia

from funkwhale_api.manage import serializers
2018-09-22 12:29:30 +00:00
def test_manage_upload_action_delete(factories):
uploads = factories["music.Upload"](size=5)
s = serializers.ManageUploadActionSerializer(queryset=None)
2018-09-22 12:29:30 +00:00
s.handle_delete(uploads.__class__.objects.all())
2018-09-22 12:29:30 +00:00
assert uploads.__class__.objects.count() == 0
2018-06-19 18:11:40 +00:00
def test_user_update_permission(factories):
user = factories["users.User"](
permission_library=False,
permission_upload=False,
permission_federation=True,
permission_settings=True,
is_active=True,
)
s = serializers.ManageUserSerializer(
user,
2018-09-28 19:05:43 +00:00
data={
"is_active": False,
"permissions": {"federation": False, "upload": True},
"upload_quota": 12,
},
2018-06-19 18:11:40 +00:00
)
s.is_valid(raise_exception=True)
s.save()
user.refresh_from_db()
assert user.is_active is False
2018-09-28 19:05:43 +00:00
assert user.upload_quota == 12
2018-06-19 18:11:40 +00:00
assert user.permission_federation is False
assert user.permission_upload is True
assert user.permission_library is False
assert user.permission_settings is True