def test_SetUserDetail_BloodGroup_A(self):
     #设置用户详细信息:血型0为A型
     setUserDetail = self.stub.SetUserDetail(
         account_pb2.User(Id=self.accountID, BloodGroup=0))
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     #设置成功,返回值为:0
     self.assertEqual(setUserDetail.Success, 0)
     self.assertEqual(getCachedUser.BloodGroup, 0)
 def test_SetUserDetail_Gender_Less(self):
     #设置用户详细信息:性别少于0时默认为2
     setUserDetail = self.stub.SetUserDetail(
         account_pb2.User(Id=self.accountID, Gender=-1))
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     #设置成功,返回值为:0
     self.assertEqual(setUserDetail.Success, 0)
     self.assertEqual(getCachedUser.Gender, 2)
 def test_SetUserDetail_Introduction_Null(self):
     #设置用户详细信息:介绍为空
     setUserDetail = self.stub.SetUserDetail(
         account_pb2.User(Id=self.accountID, Introduction=''))
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     #设置成功,返回值为:0
     self.assertEqual(setUserDetail.Success, 0)
     self.assertEqual(getCachedUser.Introduction, '')
 def test_SetUserDetail_Birthday(self):
     #设置用户详细信息:生日为时间戳
     setUserDetail = self.stub.SetUserDetail(
         account_pb2.User(Id=self.accountID, Birthday=123456))
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     #设置成功,返回值为:0
     self.assertEqual(setUserDetail.Success, 0)
     self.assertEqual(getCachedUser.Birthday, 123456)
Ejemplo n.º 5
0
 def test_SetFavorite_TradeExperience(self):
     #设置交易经验,字符与空字符
     setFavorite1 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID, TradeExperience='我123abc!@#'))
     setFavorite2 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID, TradeExperience=''))
     #设置成功,返回值为:0
     self.assertEqual(setFavorite1.Success, 0)
     self.assertEqual(setFavorite2.Success, 0)
 def test_SetUserDetail_Introduction(self):
     #设置用户详细信息:介绍包括:中文、字母、数字、特殊字符
     setUserDetail = self.stub.SetUserDetail(
         account_pb2.User(Id=self.accountID, Introduction='介绍this123!@#'))
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     #设置成功,返回值为:0
     self.assertEqual(setUserDetail.Success, 0)
     self.assertEqual(getCachedUser.Introduction, '介绍this123!@#')
Ejemplo n.º 7
0
 def test_SetFavorite_RiskPropensity(self):
     #设置风险趋势。字符与空字符
     setFavorite1 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID, RiskPropensity='我123abc!@#'))
     setFavorite2 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID, RiskPropensity=''))
     #设置成功,返回值为:0
     self.assertEqual(setFavorite1.Success, 0)
     self.assertEqual(setFavorite2.Success, 0)
Ejemplo n.º 8
0
 def test_GetCachedUserRange(self):
     GetUserList = self.stub.GetUserList(
         account_pb2.GetUserListRequest(List=[
             account_pb2.User(Id=self.accountID),
             account_pb2.User(Id=self.accountID1)
         ]))
     self.assertEqual(GetUserList.List[0].User.AccountEmail,
                      userData['AccountEmail'])
     self.assertEqual(GetUserList.List[1].User.AccountEmail,
                      "*****@*****.**")
Ejemplo n.º 9
0
 def tearDown(self):
     #清空测试环境
     #注销测试账号
     # pass
     unregister = self.stub.DeleteUserById(
         account_pb2.User(Id=self.accountID))
     #断言注销账号成功,返回0
     self.assertEqual(unregister.Success, 0)
     unregister1 = self.stub.DeleteUserById(
         account_pb2.User(Id=self.accountID1))
     #断言注销账号成功,返回0
     self.assertEqual(unregister1.Success, 0)
 def test_RegisterByMobile(self):
     #通过手机号码注册一个测试账号。为了保证手机号码未注册,故此处使用不存在的11位手机号。保证注册成功即可
     register = self.stub.RegisterByMobile(
         account_pb2.RegisterUserRequest(
             User=account_pb2.User(AccountMobile='98745612300',
                                   UserPassword=userData['UserPasswd'])))
     self.assertEqual(register.AccountMobile, '98745612300')
     self.accountID = register.Id
     #注销测试账号
     unregister = self.stub.DeleteUserById(
         account_pb2.User(Id=self.accountID))
     #断言注销账号成功,返回0
     self.assertEqual(unregister.Success, 0)
Ejemplo n.º 11
0
    def setUp(self):
        #连接account测试服务器
        channel = grpc.insecure_channel(userData['account_host'] + ':' + userData['account_port'])
        self.stub = account_pb2_grpc.AccountSrvStub(channel)
        #注册一个测试账号
        register = self.stub.RegisterByEmail(account_pb2.RegisterUserRequest(User = account_pb2.User( AccountEmail = userData['AccountEmail'] ,UserPassword = userData['UserPasswd'])))
        self.assertEqual(register.AccountStatus, userData['AccountStatus'])
        self.accountID = register.Id

        #设置测试账号的昵称
        setNickName = self.stub.SetNickName(account_pb2.User(Id = self.accountID,NickName = userData['NickName']))
        #检查设置成功后,返回值为:0
        self.assertEqual(setNickName.Success, 0)
 def test_RegisterByMobileOrEmail_email(self):
     #注册一个测试账号
     register = self.stub.RegisterByMobileOrEmail(
         account_pb2.RegisterByMobileOrEmailRequest(
             User=account_pb2.User(AccountEmail=userData['AccountEmail'],
                                   UserPassword=userData['UserPasswd'])))
     self.assertEqual(register.AccountStatus, userData['AccountStatus'])
     self.assertEqual(register.AccountEmail, userData['AccountEmail'])
     self.accountID = register.Id
     #注销测试账号
     unregister = self.stub.DeleteUserById(
         account_pb2.User(Id=self.accountID))
     #断言注销账号成功,返回0
     self.assertEqual(unregister.Success, 0)
 def test_RegisterByMobileOrEmail_emailNullPWD(self):
     #注册一个测试账号,不输入密码。返回密码无效
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.RegisterByMobileOrEmail,
         account_pb2.RegisterByMobileOrEmailRequest(User=account_pb2.User(
             AccountEmail='*****@*****.**')))
 def test_GetCachedUserListByNickName(self):
     #通过昵称获取用户列表相关信息
     GetCachedUserListByNickName = self.stub.GetCachedUserListByNickName(
         account_pb2.User(NickName=userData['NickName']))
     #返回用户列表
     self.assertEqual(GetCachedUserListByNickName.List[0].User.NickName,
                      userData['NickName'])
 def test_Login_nullAccount(self):
     #新注册的账号需要先激活才能登录
     #发送验证码邮件到邮箱
     sendActivationEmail = self.stub.SendActivationEmail(
         account_pb2.SendActivationEmailRequest(
             UserId=self.accountID,
             ActivationCode=userData['ActivationCode'],
             Email=userData['SendActivationEmail'],
             Subject=userData['Subject']))
     #断言验证码邮件发送成功,返回0
     self.assertEqual(sendActivationEmail.Success, 0)
     #获取验证码
     getActivationByObj = self.stub.GetActivationByObj(
         account_pb2.ActivationRequest(ObjectId=self.accountID))
     vercode = getActivationByObj.VerCode
     activationCode = getActivationByObj.ActivationCode
     #激活账号。
     #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
     validateEmailLink = self.stub.ValidateEmailLink(
         account_pb2.ValidateEmailLinkRequest(UserId=self.accountID,
                                              VerCode=vercode,
                                              ActivationCode=activationCode,
                                              Token=str(uuid.uuid1())))
     self.assertEqual(validateEmailLink.Success, 0)
     #账号为空,返回无效的用户
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.Login,
         account_pb2.LoginRequest(
             User=account_pb2.User(UserPassword='******'),
             Token=str(uuid.uuid1())))
 def test_RegisterByMobile_lessPWD(self):
     #注册一个测试账号,超短密码。返回用户无效
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.RegisterByMobile,
         account_pb2.RegisterUserRequest(User=account_pb2.User(
             AccountMobile='18888888888', UserPassword='******')))
 def test_UpdatePassword_SpecialChar(self):
     #修改密码为带特殊字符
     self.stub.UpdatePassword(
         account_pb2.UpdatePasswordRequest(User=account_pb2.User(
             Id=self.accountID, UserPassword=userData['UserPasswd']),
                                           NewPassword="******",
                                           Token=str(uuid.uuid1())))
 def test_RegisterByMobile_nullPWD(self):
     #注册一个测试账号,不输入密码。返回密码无效
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['PasswdInvalid_returnCode'],
         self.stub.RegisterByMobile,
         account_pb2.RegisterUserRequest(User=account_pb2.User(
             AccountMobile='18888888888')))
 def test_Login(self):
     #新注册的账号需要先激活才能登录
     #发送验证码邮件到邮箱
     sendActivationEmail = self.stub.SendActivationEmail(
         account_pb2.SendActivationEmailRequest(
             UserId=self.accountID,
             ActivationCode=userData['ActivationCode'],
             Email=userData['SendActivationEmail'],
             Subject=userData['Subject']))
     #断言验证码邮件发送成功,返回0
     self.assertEqual(sendActivationEmail.Success, 0)
     #获取验证码
     getActivationByObj = self.stub.GetActivationByObj(
         account_pb2.ActivationRequest(ObjectId=self.accountID))
     vercode = getActivationByObj.VerCode
     activationCode = getActivationByObj.ActivationCode
     #激活账号。
     #AccountStatus: 0 新申请, 1 审核中, 2 正常, 3 锁定(此时交易员才可提取服务费), 4 注销, 5 未激活,6 注销
     validateEmailLink = self.stub.ValidateEmailLink(
         account_pb2.ValidateEmailLinkRequest(UserId=self.accountID,
                                              VerCode=vercode,
                                              ActivationCode=activationCode,
                                              Token=str(uuid.uuid1())))
     self.assertEqual(validateEmailLink.Success, 0)
     #登录成功
     Login = self.stub.Login(
         account_pb2.LoginRequest(User=account_pb2.User(
             AccountEmail=userData['AccountEmail'],
             UserPassword=userData['UserPasswd']),
                                  Token=str(uuid.uuid1())))
     self.assertEqual(Login.Id, self.accountID)
     self.assertEqual(Login.AccountEmail, userData['AccountEmail'])
Ejemplo n.º 20
0
 def test_RegisterByEmail_lessPWD(self):
     #注册一个测试账号,超短密码。返回用户无效
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.RegisterByEmail,
         account_pb2.RegisterUserRequest(User=account_pb2.User(
             AccountEmail='*****@*****.**', UserPassword='******')))
 def test_MarketingRegisterByMobile(self):
     #注册一个测试账号
     MarketingRegister = self.stub.MarketingRegisterByMobile(
         account_pb2.MarketingRegisterByMobileRequest(
             User=account_pb2.User(AccountMobile=userData['AccountMobile'],
                                   UserPassword=userData['UserPasswd'])))
     self.assertEqual(MarketingRegister.IsMobileVerified, True)
 def test_GetCachedUserByNickName(self):
     #通过昵称获取账号相关信息
     getCachedUser = self.stub.GetCachedUserByNickName(
         account_pb2.User(NickName=userData['NickName'])).User
     #断言该账号用户id为setup步骤注册时生成的id
     self.assertEqual(getCachedUser.Id, self.accountID)
     self.assertEqual(getCachedUser.AccountEmail, userData['AccountEmail'])
     self.assertEqual(getCachedUser.NickName, userData['NickName'])
 def setUp(self):
     #连接account测试服务器
     channel = grpc.insecure_channel(userData['account_host'] + ':' + userData['account_port'])
     self.stub = account_pb2_grpc.AccountSrvStub(channel)
      #注册一个测试账号
     register = self.stub.RegisterByEmail(account_pb2.RegisterUserRequest(User = account_pb2.User(AccountEmail = userData['AccountEmail'] ,UserPassword = userData['UserPasswd'])))
     self.assertEqual(register.AccountStatus, userData['AccountStatus'])
     self.accountID = register.Id
 def tearDown(self):
     #本用例由于空密码未注册成功,所以不需要注销账号。故注销账号步骤单独写到注销成功的测试方法里
     #清空测试环境
     #注销测试账号
     unregister = self.stub.DeleteUserById(
         account_pb2.User(Id=self.accountID))
     #断言注销账号成功,返回0
     self.assertEqual(unregister.Success, 0)
 def test_UpdatePassword(self):
     #修改密码成功
     self.stub.UpdatePassword(
         account_pb2.UpdatePasswordRequest(
             User=account_pb2.User(Id=self.accountID,
                                   UserPassword=userData['UserPasswd']),
             NewPassword=userData['newPasswd'],
             Token=str(uuid.uuid1())))
 def test_UpdatePassword_Null(self):
     #修改密码为:大于16个字符。
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.UpdatePassword,
         account_pb2.UpdatePasswordRequest(User=account_pb2.User(
             Id=self.accountID, UserPassword=userData['UserPasswd']),
                                           NewPassword="",
                                           Token=str(uuid.uuid1())))
 def test_SetNickName_MoreStr(self):
     #设置昵称大于65个字符
     self.assertRaisesRegex(
         grpc._channel._Rendezvous, userData['UserInvalid_returnCode'],
         self.stub.SetNickName,
         account_pb2.User(
             NickName=
             '11111111111111111111111111111111111111111111111111111111111123456'
         ))
Ejemplo n.º 28
0
 def test_SetFavorite_MultiPar(self):
     #设置风险趋势,多个入参
     setFavorite1 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID,
                          TradeVariety='我123abc!@#',
                          TradeExperience='我123abc!@#'))
     setFavorite2 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID,
                          TradeVariety='我123abc!@#',
                          RiskPropensity='我123abc!@#'))
     setFavorite3 = self.stub.SetFavorite(
         account_pb2.User(Id=self.accountID,
                          TradeVariety='我123abc!@#',
                          TradeExperience='我123abc!@#',
                          RiskPropensity='我123abc!@#'))
     #设置成功,返回值为:0
     self.assertEqual(setFavorite1.Success, 0)
     self.assertEqual(setFavorite2.Success, 0)
     self.assertEqual(setFavorite3.Success, 0)
 def test_SetNickName_withMaxStr(self):
     #设置64个字符的昵称
     setNickName = self.stub.SetNickName(
         account_pb2.User(
             Id=self.accountID,
             NickName=
             '1111111111111111111111111111111111111111111111111111111111112345'
         ))
     #检查设置成功后,返回值为:0
     self.assertEqual(setNickName.Success, 0)
Ejemplo n.º 30
0
 def test_GetCachedUserById(self):
     getCachedUser = self.stub.GetCachedUserById(
         account_pb2.User(Id=self.accountID)).User
     self.assertEqual(getCachedUser.Id, self.accountID)
     self.assertEqual(getCachedUser.AccountEmail, userData['AccountEmail'])
     self.assertEqual(getCachedUser.IsMobileVerified,
                      userData['IsMobileVerified'])
     self.assertEqual(getCachedUser.Gender, userData['Gender'])
     self.assertEqual(getCachedUser.AccountStatus,
                      userData['AccountStatus'])
     self.assertEqual(getCachedUser.UserType, userData['UserType'])
     self.assertEqual(getCachedUser.EnableMemberApply,
                      userData['EnableMemberApply'])