def test_notify_user(self): l = create_user('Lorenzo') pp = create_event('Ping pong', l, timezone.now(), max_num_participants=2) # Create notification notification = NotificationRating(date=timezone.now(), event=pp, user=l) notification.save() # Create link user-notification in the notification interface usernotif = UserNotification(content_object=notification, user=l, object_id=notification.id) usernotif.save() assert usernotif # Query the notification table notifications_of_l = UserNotification.objects.filter(user=l) self.assertEqual(len(notifications_of_l), 1) pingpong_usernotif = notifications_of_l[0] # Extract the RatingNotification from the UserNotificatio instance notification_from_query = pingpong_usernotif.content_object self.assertEqual(notification, notification_from_query)
def create_notification(user, event): # Create notification notification = NotificationRating(date=timezone.now(), event=event, user=user) notification.save() # Create link user-notification in the notification interface usernotif = UserNotification(content_object=notification, user=user, object_id=notification.id) usernotif.save() return usernotif.content_object
def create_notification(username, eventname, location='ILC'): user = create_user(username) event = create_event(eventname, user, timezone.now(), max_num_participants=2) # Create notification notification = NotificationRating(date=timezone.now(), event=event, user=user) notification.save() # Create link user-notification in the notification interface usernotif = UserNotification(content_object=notification, user=user, object_id=notification.id) usernotif.save() return usernotif