def test_decode(self): raw_to_clean = { # basic character test u"associa\x09\x7bo": u"associa\u00e7\u00e3o", # extended character test u"a\x09\x1b\x75car": u"a\u00e7\u00facar", # no decode u"no decode needed": u"no decode needed", } for raw, expected in raw_to_clean.items(): cleaned = convert_raw_string(raw) self.assertEqual(cleaned, expected) print "Cleaned text: %s" % cleaned
def sms_in(request): """ sender - the number of the person sending the sms receiver - the number the sms was sent to msgdata - the message """ sender = request.GET.get("sender", None) receiver = request.GET.get("receiver", None) msgdata = request.GET.get("msgdata", None) if sender is None or msgdata is None: return HttpResponse(status=400) else: cleaned_text = convert_raw_string(msgdata) incoming_sms(sender, cleaned_text, "SISLOG", raw_text=msgdata) return HttpResponse()