示例#1
0
    def test_reset_notifications(self):
        sess_id = self.login_actor()
        notifs = self.get_notifications_info(sess_id)
        ids = [n['id'] for n in notifs]

        req = {'session_id': sess_id, 'ids': ids,
            'new_messages': []}
        resp = self.modify_notifications(**req)
        self.check_response_ok(resp)
        notifs = self.get_notifications_info(sess_id)
        for n_info in notifs:
            self.assertEquals([], n_info['messages'])

        req = {'session_id': sess_id, 'ids': ids}
        resp = self.reset_notifications(**req)
        self.check_response_ok(resp)
        notifs = self.get_notifications_info(sess_id)
        n = Notifier()
        for n_info in notifs:
            self.assertNotEquals([], n_info['messages'])
            found = False
            for n_exp in n.default_email_notif_struct(n_info['event']):
                if n_exp in n_info['messages']:
                    found = True
                    break
            self.assertTrue(found)
示例#2
0
 def _create_default_notifications(self, curs, env, events):
     notifier = Notifier()
     for event in events:
         e_msgs = notifier.default_email_notif_struct(event)
         n = Notification(environment_id=env.id, event=event,
             is_active=True, type=Notification.TYPE_EMAIL,
             messages=e_msgs)
         mapping.save(curs, n)
示例#3
0
 def reset_notifications(self, data, req_info, session, curs=None):
     n_ids = data['ids']
     f = NotificatonFilter(session.environment_id, {'ids': n_ids},
         {}, None)
     objs = f.filter_objs(curs, for_update=True)
     n = Notifier()
     for o in objs:
         if o.type == Notification.TYPE_EMAIL:
             msg_struct = n.default_email_notif_struct(o.event)
             o.serialized_messages = json.dumps(msg_struct)
             mapping.save(curs, o)
     return response_ok()