Exemplo n.º 1
0
def status_callback(request):
    form = StatusCallbackForm(request.POST or None)
    if form.is_valid():
        form.save(ip_address=request.get_host())
    else:
        post = pprint.pformat(request.POST)
        errors = [(k, unicode(v[0])) for k, v in form.errors.items()]
        logging.error('Callback error: %s, %s' % (errors, post))
    return HttpResponse('OK')
Exemplo n.º 2
0
def status_callback(request):
    form = StatusCallbackForm(request.POST or None)
    if form.is_valid():
        form.save(ip_address=request.get_host())
    else:
        post = pprint.pformat(request.POST)
        errors = [(k, str(v[0])) for k, v in form.errors.items()]
        logging.error('Callback error: %s, %s' % (errors, post))
    return HttpResponse('OK')
Exemplo n.º 3
0
def test_missing_from():
    message = Message.objects.create(body='foo', connection=connection)
    data = {
        'api_id': 12345,
        'apiMsgId': '996f364775e24b8432f45d77da8eca47',
        'cliMsgId': message.id,
        'timestamp': 1218007814,
        'to': 279995631564,
        'from': '',
        'status': '003',
        'charge': '0.300000',
    }
    form = StatusCallbackForm(data)
    assert_true(form.is_valid(), [(k, unicode(v[0])) for k, v in form.errors.items()])
    status = form.save(ip_address='127.0.0.1')
    assert_equals(status.sender, '')
Exemplo n.º 4
0
 def test_missing_from(self):
     message = Message.objects.create(body='foo', connection=self.connection)
     data = {
         'api_id': 12345,
         'apiMsgId': '996f364775e24b8432f45d77da8eca47',
         'cliMsgId': message.id,
         'timestamp': 1218007814,
         'to': 279995631564,
         'from': '',
         'status': '003',
         'charge': '0.300000',
     }
     form = StatusCallbackForm(data)
     self.assertTrue(form.is_valid(), [(k, str(v[0])) for k, v in form.errors.items()])
     status = form.save(ip_address='127.0.0.1')
     self.assertEqual(status.sender, '')
Exemplo n.º 5
0
    def test_status(self):
        message = Message.objects.create(body='foo', connection=self.connection)

        data = {
            'api_id': 12345,
            'apiMsgId': '996f364775e24b8432f45d77da8eca47',
            'cliMsgId': message.id,
            'timestamp': 1218007814,
            'to': 279995631564,
            'from': 27833001171,
            'status': '003',
            'charge': '0.300000',
        }
        form = StatusCallbackForm(data)
        self.assertTrue(form.is_valid(), [(k, str(v[0])) for k, v in form.errors.items()])
        status = form.save(ip_address='127.0.0.1')
        self.assertTrue(status.message_id, message.id)