def testUnknownNotificationIsParsedCorrectly(self): urn = rdf_client.ClientURN(self.client_id).Add("foo/bar") n = user_plugin.ApiNotification().InitFromNotification( rdf_flows.Notification(type="ViewObject", subject=urn)) self.assertEqual(n.reference.type, "UNKNOWN") self.assertEqual(n.reference.unknown.subject_urn, urn) n = user_plugin.ApiNotification().InitFromNotification( rdf_flows.Notification(type="FlowStatus", subject="foo/bar")) self.assertEqual(n.reference.type, "UNKNOWN") self.assertEqual(n.reference.unknown.subject_urn, "foo/bar")
def InitFromObj_(self, notification_type, reference, message=None): self.CreateUser(self.token.username) notification.Notify(self.token.username, notification_type, message or "", reference) ns = self.GetUserNotifications(self.token.username) if data_store.RelationalDBReadEnabled(): # Treat the notification as an object coming from REL_DB. return user_plugin.ApiNotification().InitFromUserNotification(ns[0]) else: # Treat the notification as an old-style notification object. return user_plugin.ApiNotification().InitFromNotification(ns[0])
def InitFromObj_(self, notification_type, reference, message=None): self.CreateUser(self.context.username) notification.Notify(self.context.username, notification_type, message or "", reference) ns = self.GetUserNotifications(self.context.username) # Treat the notification as an object coming from REL_DB. return user_plugin.ApiNotification().InitFromUserNotification(ns[0])
def testNotificationWithoutSubject(self): n = user_plugin.ApiNotification().InitFromNotification( rdf_flows.Notification(type="ViewObject")) self.assertEqual(n.reference.type, "UNKNOWN")