Merge pull request #5172 from tsiegleauq/fix-group-creation

Fix group creation
This commit is contained in:
Emanuel Schütze 2020-01-08 13:34:04 +01:00 committed by GitHub
commit b9e40717de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -159,7 +159,9 @@ class GroupSerializer(ModelSerializer):
Serializer for django.contrib.auth.models.Group objects.
"""
permissions = PermissionRelatedField(many=True, queryset=Permission.objects.all())
permissions = PermissionRelatedField(
many=True, queryset=Permission.objects.all(), required=False
)
class Meta:
model = Group

View File

@ -705,6 +705,18 @@ class GroupCreate(TestCase):
Tests creation of groups via REST API.
"""
def test_creation_simple(self):
self.client.login(username="admin", password="admin")
response = self.client.post(
reverse("group-list"), {"name": "Test name ldr59xq2mvt96rdayhju"},
)
self.assertEqual(response.status_code, status.HTTP_201_CREATED)
self.assertTrue(
Group.objects.filter(name="Test name ldr59xq2mvt96rdayhju").exists()
)
def test_creation(self):
self.client.login(username="admin", password="admin")
# This contains two valid permissions of the users app.