Exemplo n.º 1
0
def login_h5(email, password):
    '''h5的登陆'''
    login_pwd = md5_encryption(password)
    login_pars = {"account": email, "password": login_pwd}
    r = requests.post(login_url, params=login_pars)
    # pprint(r.json())
    status_code = r.status_code
    ret = r.json()['ret']
    msg = r.json()['msg']
    try:
        assert 200 == status_code
        assert '0' == ret
        assert '登录成功' == msg
    except AssertionError:
        # raise AssertionError('登录失败' + msg)
        raise AssertionError(msg)
    return r.cookies['t_skey']  # 获取t_skey是为了免登录,处于“登陆”状态
Exemplo n.º 2
0
 def test_login_account_error(self):
     '''账号:错误账号'''
     account = '13540'
     password = md5_encryption('123456')
     querystring = {"account": account, "password": password}
     response = requests.post(login_url, params=querystring)
     # pprint(response.json())
     status_code = response.status_code
     ret = response.json()['ret']
     msg = response.json()['msg']
     try:
         self.assertEqual(200, status_code)
         self.assertEqual('111105', ret)
         self.assertEqual('输入正确的邮箱或手机号', msg)
     except AssertionError:
         # raise AssertionError('登录失败' + msg)
         raise AssertionError(msg)
Exemplo n.º 3
0
 def test_login_password_error(self):
     '''密码:错误'''
     account = '13510278144'
     password = md5_encryption('2222')
     querystring = {"account": account, "password": password}
     response = requests.post(login_url, params=querystring)
     # pprint(response.json())
     status_code = response.status_code
     ret = response.json()['ret']
     msg = response.json()['msg']
     try:
         self.assertEqual(200, status_code)
         self.assertEqual('111104', ret)
         self.assertEqual('用户名或密码错误,请重新输入', msg)
     except AssertionError:
         # raise AssertionError('登录失败' + msg)
         raise AssertionError(msg)
Exemplo n.º 4
0
 def test_login_success(self):
     '''正常登陆测试'''
     account = 13510278144
     password = md5_encryption('123456')
     querystring = {"account": account, "password": password}
     response = requests.post(login_url, params=querystring)
     # pprint(response.json())
     status_code = response.status_code
     ret = response.json()['ret']
     msg = response.json()['msg']
     bindphone = response.json()['data']['bindphone']
     try:
         self.assertEqual(200, status_code)
         self.assertEqual('0', ret)
         self.assertEqual('登录成功', msg)
         self.assertEqual('13510278144', bindphone)
     except AssertionError:
         # raise AssertionError('登录失败' + msg)
         raise AssertionError(msg)