SoftTesting/第七周/pytest01.py
2025-04-15 09:22:27 +08:00

17 lines
802 B
Python

import pytest
import requests
class TestIhrmLogin(object):
@pytest.mark.parametrize("mobile,password,ast",[
("13800000002","929itheima.CN032@.20250408",(200,True,"操作成功!")),
("13804789371", "929itheima.CN032@.20250408", (200, False, "用户名或密码错误",20001)),
("13800000002", "123456789", (200, False, "用户名或密码错误", 20001))
])
def test_login(self,mobile,password,ast):
jsondata = {"mobile":mobile,"password":password}
rsp = requests.post("http://ihrm-java.itheima.net/api/sys/login", json=jsondata)
assert rsp.status_code == ast[0]
assert rsp.json().get("success") == ast[1]
assert rsp.json().get("message") == ast[2]
if len(ast)>=4:
assert rsp.json().get("code") == ast[3]