Skip to content

Commit 941982d

Browse files
committed
[tests] Add missing tests on serializers.py
1 parent 620d535 commit 941982d

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

openwisp_notifications/tests/test_api.py

+29
Original file line numberDiff line numberDiff line change
@@ -892,6 +892,35 @@ def test_organization_notification_setting_update(self):
892892
).exists()
893893
)
894894

895+
with self.subTest('Test email set to False and email not provided'):
896+
url = self._get_path(
897+
'organization_notification_setting',
898+
self.admin.pk,
899+
org.pk,
900+
)
901+
# Set initial state with email=True and web=True
902+
NotificationSetting.objects.filter(
903+
user=self.admin, organization_id=org.pk
904+
).update(web=True, email=True)
905+
906+
# POST data with web=False and omit email
907+
response = self.client.post(
908+
url, data={'web': False}, content_type='application/json'
909+
)
910+
self.assertEqual(response.status_code, 200)
911+
912+
# Check both web and email are updated to False
913+
self.assertTrue(
914+
NotificationSetting.objects.filter(
915+
user=self.admin, organization_id=org.pk, web=False, email=False
916+
).exists()
917+
)
918+
self.assertFalse(
919+
NotificationSetting.objects.filter(
920+
user=self.admin, organization_id=org.pk, email=True
921+
).exists()
922+
)
923+
895924
@patch('openwisp_notifications.tasks.delete_ignore_object_notification.apply_async')
896925
def test_create_ignore_obj_notification_api(self, mocked_task):
897926
org_user = self._get_org_user()

0 commit comments

Comments
 (0)