From 06a2f5a23f52936476275bd04036f07c151dbb8b Mon Sep 17 00:00:00 2001 From: Kira Miller Date: Mon, 7 Oct 2024 19:58:35 +0000 Subject: [PATCH] fix: updating serializer --- enterprise/api/v1/serializers.py | 2 +- tests/test_enterprise/api/test_views.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/enterprise/api/v1/serializers.py b/enterprise/api/v1/serializers.py index 945e4e795..4aec17e9c 100644 --- a/enterprise/api/v1/serializers.py +++ b/enterprise/api/v1/serializers.py @@ -639,7 +639,7 @@ class Meta: model = models.EnterpriseGroup fields = ( 'enterprise_customer', 'name', 'uuid', 'applies_to_all_contexts', - 'accepted_members_count', 'group_type') + 'accepted_members_count', 'group_type', 'created') accepted_members_count = serializers.SerializerMethodField() diff --git a/tests/test_enterprise/api/test_views.py b/tests/test_enterprise/api/test_views.py index e14bff222..155934902 100644 --- a/tests/test_enterprise/api/test_views.py +++ b/tests/test_enterprise/api/test_views.py @@ -8495,6 +8495,22 @@ def test_successful_update_group(self): assert response.json().get('enterprise_customer') == str(new_uuid) assert len(EnterpriseGroup.objects.filter(enterprise_customer=str(new_uuid))) == 1 + def test_successful_update_group_name(self): + """ + Test patching an existing group record display name + """ + # url: 'http://testserver/enterprise/api/v1/enterprise_group/' + url = settings.TEST_SERVER + reverse( + 'enterprise-group-detail', + kwargs={'pk': self.group_1.uuid}, + ) + old_name = self.group_1.name + new_name = "new_name" + + request_data = {'name': new_name} + response = self.client.patch(url, data=request_data) + assert response.json().get('name') == str(new_name) + def test_successful_delete_group(self): """ Test deleting a group record