def check_call_received(request): response_dict = {} try: response_dict["status"] = "failed" number = request.session['authenticate_phonenumber']['number'] start_time = request.session['authenticate_phonenumber']['start_time'] if (start_time + AUTHENTICATION_CALL_TIMEOUT) >= datetime.now(): if check_and_delete_authentication_call(number): response_dict["status"] = "received" logger.info("check_call_received: call received.") else: response_dict["status"] = "waiting" except KeyError: pass return HttpResponse(content = simplejson.dumps(response_dict), content_type = "application/json")
def test_check_and_delete_authentication_call(self): AuthenticationCall.objects.all().delete() AuthenticationCall(number = "01601234567").save() call_received = check_and_delete_authentication_call(" 0160 1234567 ") self.assertTrue(call_received)