import requests
class flow_workupdate():
#1.用户注册
def regist(self):
url="http://localhost:8080/jwshoplogin/user/register.do"
useinfo={"username":"樊S2",
"password":"123456",
"phone":"18911271199",
"email":"87878111@qq.com",
"question":"我最爱的食物",
"answer":"奶茶"}
response=requests.post(url,data=useinfo).text
r=response.find("注册成功")
if r>1:
print("用户注册接口测试通过")
else:
print("用户注册接口测试不通过") # 2.用户登录 def login(self):
url = "http://localhost:8080/jwshoplogin/user/login.do"
useinfo = {"username": "樊S2",
"password": "123456"} response = requests.post(url, data=useinfo).text
print(response)
r = response.find("登录成功")
if r > 1:
print("登录接口测试通过")
else:
print("登录接口测试不通过") #3.获取用户信息def infomation(self): url ="http://localhost:8080/jwshoplogin/user/get_information.do" response = requests.post(url).text print(response) r = response.find("data") if r > 1: print("获取用户信息接口测试通过") else: print("获取用户信息接口测试不通过")代码结果:用户注册接口测试不通过
{"status":0,"msg":"登录成功","data":{"id":33,"username":"樊S2","password":null,"email":"87878111@qq.com","phone":"18911271199","question":"我最爱的食物","answer":"奶茶","role":0,"createTime":1558085040000,"updateTime":1558085040000}}
登录接口测试通过
{"status":10,"msg":"未登录,需要强制登录status=10"}
获取用户信息接口测试不通过 问题是:为什么我之前登录了,会显示未登录呢?
在学课程 Python测试开发全栈核心课程 互联网测试工程师必修课
|