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)")
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
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"))