File tree 1 file changed +29
-0
lines changed
openwisp_notifications/tests
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -892,6 +892,35 @@ def test_organization_notification_setting_update(self):
892
892
).exists ()
893
893
)
894
894
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
+
895
924
@patch ('openwisp_notifications.tasks.delete_ignore_object_notification.apply_async' )
896
925
def test_create_ignore_obj_notification_api (self , mocked_task ):
897
926
org_user = self ._get_org_user ()
You can’t perform that action at this time.
0 commit comments