示例#1
0
 def test_notification_unicode(self):
     notice = Notification()
     self.assertEquals(str(notice), "None (, )")
     notice.notify_type = u"テスト"
     notice.media = "yyy"
     if six.PY2:
         self.assertEquals(str(notice), u"None (テスト, yyy)".encode("utf-8"))
     else:
         self.assertEquals(str(notice), "None (テスト, yyy)")
示例#2
0
文件: model.py 项目: beproud/bpnotify
    def _send(self, target, notify_type, media, extra_data={}):
        from beproud.django.notify.models import Notification

        notification = Notification(
            notify_type=notify_type,
            media=media,
            extra_data=extra_data,
        )
        notification.target = target

        try:
            notification.save()
            return 1
        except (TypeError, DatabaseError):
            # extra_data could not be serialized to JSON or
            # there was some kind of Database error
            # TODO: logging
            return 0
示例#3
0
    def _send(self, target, notify_type, media, extra_data={}):
        from beproud.django.notify.models import Notification

        notification = Notification(
            notify_type=notify_type,
            media=media,
            extra_data=extra_data,
        )
        notification.target = target

        try:
            notification.save()
            return 1
        except (TypeError, DatabaseError):
            # extra_data could not be serialized to JSON or
            # there was some kind of Database error
            # TODO: logging
            return 0
示例#4
0
 def test_notification_unicode(self):
     notice = Notification()
     self.assertEquals(str(notice), "None (, )")
     notice.notify_type = u"テスト"
     notice.media = "yyy"
     self.assertEquals(str(notice), u"None (テスト, yyy)".encode("utf-8"))