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_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)
def test_get_sms_code_image_code_null(self): """ 测试获取短信验证码图形验证码为空 :return: """ sms_code_ajax = SendSmsAjax() sms_code_ajax.get({'phone':self.mobile,'type':'register','check_code':None}) self.assertEqual(sms_code_ajax.get_resp_code(),801002) self.assertEqual(sms_code_ajax.get_resp_message(),'验证码错误,请重新输入')
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(),'验证码错误,请重新输入')
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(),'请求参数错误')
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(),'手机号格式不合法')