@@ -119,20 +119,33 @@ def test_create(self):
119119
120120 def test_refetch (self ):
121121 async_to_sync (fetch_notifications )(None )
122- before = RemoteNotificationSpec .objects .get ()
122+ rn_before = RemoteNotificationSpec .objects .get ()
123+ un_before = self .user_notification .notifications .get ()
123124 async_to_sync (fetch_notifications )(None )
124- after = RemoteNotificationSpec .objects .get ()
125- assertKeysEqual (before , after , ['id' , 'created' , 'updated' , 'active_until' ])
125+ rn_after = RemoteNotificationSpec .objects .get ()
126+ assertKeysEqual (rn_before , rn_after , ['id' , 'created' , 'updated' , 'active_until' ])
127+ un_after = self .user_notification .notifications .get ()
128+ assertKeysEqual (un_before , un_after , ['id' , 'created' , 'user' , 'type' , 'remotenotificationspec_id' , 'visible_until' , 'read' , 'additional_content' ])
126129
127130 def test_delete (self ):
128131 async_to_sync (fetch_notifications )(None )
129132 self .notification_import_data = []
130133 async_to_sync (fetch_notifications )(None )
134+
135+ # RemoteNotificationSpec is set to inactive
131136 after = RemoteNotificationSpec .objects .get ()
132137 notification = self .user_notification .notifications .get (remotenotificationspec = after )
133138 assert after .active_until < timezone .now ().date ()
134139 assert notification .visible_until < timezone .now ()
135140
141+ # User notifications are set to invisible
142+ un1 = self .user_notification .notifications .get (remotenotificationspec = after )
143+ assert un1 .visible_until < timezone .now ()
144+
145+ # No new notifications are created
146+ u = create_user ()
147+ assert u .notifications .all ().count () == 0
148+
136149
137150@pytest .mark .django_db ()
138151class TestNotificationTriggers :
0 commit comments