def test_register_success(self):
        """
        测试注册成功
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        image_code = Redis().get_image_captcha(settings.CLIENT_IDENTITY)
        sms_code_ajax = SendSmsAjax()
        sms_code_ajax.get({
            'phone': self.mobile,
            'type': 'register',
            'check_code': image_code
        })
        self.assertEqual(sms_code_ajax.get_resp_code(), 0)

        sms_code = MysqlOperation(mobile=self.mobile).get_sms_code()
        register_ajax = RegisterAjax()
        register_ajax.get({
            'login_name': self.mobile,
            'pass_word': 'eJwrSS0uMTQyNgEADVUCiw==',
            'code': sms_code,
            'check_code': image_code
        })

        login_identity = LoginApi().login(login_name=self.mobile,
                                          password='******',
                                          only_get_identity=True)
        self.assertEqual(len(login_identity), 236)
    def test_get_image_code_success(self):
        """
        测试获取图形验证码成功
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        image_code = Redis().get_image_captcha(settings.CLIENT_IDENTITY)
        self.assertEqual(len(image_code), 4)
예제 #3
0
    def test_get_sms_code_image_code_error(self):
        """
        测试获取短信验证码图形验证码错误
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        sms_code_ajax = SendSmsAjax()
        sms_code_ajax.get({'phone':self.mobile,'type':'register','check_code':'1234'})
        self.assertEqual(sms_code_ajax.get_resp_code(),422107)
        self.assertEqual(sms_code_ajax.get_resp_message(),'验证码错误,请重新输入')
예제 #4
0
    def test_get_sms_code_type_error(self):
        """
        测试获取短信验证码类型为空
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        image_code = Redis().get_image_captcha(settings.CLIENT_IDENTITY)
        sms_code_ajax = SendSmsAjax()
        sms_code_ajax.get({'phone':self.mobile,'type':'123','check_code':image_code})
        self.assertEqual(sms_code_ajax.get_resp_code(),400136)
        self.assertEqual(sms_code_ajax.get_resp_message(),'请求参数错误')
예제 #5
0
    def test_get_sms_code_mobile_error(self):
        """
        测试获取短信验证码手机号格式错误
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        image_code = Redis().get_image_captcha(settings.CLIENT_IDENTITY)
        sms_code_ajax = SendSmsAjax()
        sms_code_ajax.get({'phone':'1234','type':'register','check_code':image_code})
        self.assertEqual(sms_code_ajax.get_resp_code(),400126)
        self.assertEqual(sms_code_ajax.get_resp_message(),'手机号格式不合法')
예제 #6
0
    def test_get_sms_code_success(self):
        """
        测试获取短信验证码成功
        :return:
        """
        image_code_ajax = ImageCodeAjax()
        image_code_ajax.get()

        image_code = Redis().get_image_captcha(settings.CLIENT_IDENTITY)
        sms_code_ajax = SendSmsAjax()
        sms_code_ajax.get({'phone':self.mobile,'type':'register','check_code':image_code})
        self.assertEqual(sms_code_ajax.get_resp_code(),0)

        sms_code = MysqlOperation(mobile=self.mobile).get_sms_code()
        self.assertEqual(len(sms_code),4)