def test12_none_null(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login(None) # 打印登陆的数据 print("无参-传递null:", response.json()) # 断言 assert_common_util(self, response, 200, False, 99999, "抱歉,系统繁忙,请稍后重试")
def test05_delete_emp(self,success,code,message,status_code): # 调用删除员工接口 response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS) # 打印删除的结果 print("删除的结果为:", response.json()) # 断言 assert_common_util(self, response, status_code, success, code, message)
def test05_mobile_is_empty(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({"mobile": "", "password": "******"}) # 打印登陆的数据 print("手机号码为空的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test04_modify_emp(self,request_body, success,code,message,status_code): # 调用修改员工接口,并传递请求体、员工id,请求头,实现修改员工 response = self.emp_api.modify_emp(app.EMP_ID, request_body, app.HEADERS) # 打印修改员工的结果 print("修改员工的结果", response.json()) # 断言 assert_common_util(self, response, status_code, success, code, message)
def test11_none_params1(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({}) # 打印登陆的数据 print("无参-传递{}:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test03_query_emp(self): # 调用封装的查询员工接口,并传给员工ID和请求头给查询员工接口 response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS) # 打印查询员工的结果 print("查询员工的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, True, 10000, "操作成功")
def test03_query_emp(self,success,code,message,status_code): # 调用封装的查询员工接口,并传给员工ID和请求头给查询员工接口 response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS) # 打印查询员工的结果 print("查询员工的结果为:", response.json()) # 断言 assert_common_util(self, response, status_code, success, code, message)
def test10_less_params_password(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({"mobile": "123123123"}) # 打印登陆的数据 print("少参-缺少password:"******"用户名或密码错误")
def test09_less_params_mobile(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({"password": "******"}) # 打印登陆的数据 print("少参-缺少mobile:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test05_delete_emp(self): # 调用删除员工接口 response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS) # 打印删除的结果 print("删除的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, True, 10000, "操作成功")
def test01_login(self,case_name, request_body, success, code, message, status_code): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login(request_body) # 打印登陆的数据 print(case_name) print("登陆结果为:", response.json()) # 断言 assert_common_util(self, response, status_code, success, code, message)
def test04_modify_emp(self): # 调用修改员工接口,并传递请求体、员工id,请求头,实现修改员工 response = self.emp_api.modify_emp(app.EMP_ID, {"username": "******"}, app.HEADERS) # 打印修改员工的结果 print("修改员工的结果", response.json()) # 断言 assert_common_util(self, response, 200, True, 10000, "操作成功")
def test02_add_emp(self,request_body, success,code,message,status_code): # 使用封装的添加员工接口添加员工 response = self.emp_api.add_emp(request_body, app.HEADERS) # 打印添加的结果 print("添加员工的结果为:", response.json()) # 断言添加员工 assert_common_util(self, response, status_code, success, code, message) # 提取员工ID,并把员工ID保存到全局变量 app.EMP_ID = response.json().get("data").get("id")
def test08_password_has_special_chars(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mobile": "13800000002", "password": "******" }) # 打印登陆的数据 print("密码中有特殊字符的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test07_password_length_is_not_enough(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mobile": "13800000002", "password": "******" }) # 打印登陆的数据 print("密码错误的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test04_mobile_length_less_11(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mobile": "1400000", "password": "******" }) # 打印登陆的数据 print("手机号码长度小于11位的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test01_login_success(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mobile": "13800000002", "password": "******" }) # 打印登陆的数据 print("登陆成功的结果为:", response.json()) # 断言 assert_common_util(self, response, 200, True, 10000, "操作成功")
def test13_incorrect_params(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mboile": "13800000002", "password": "******" }) # 打印登陆的数据 print("错误参数:", response.json()) # 断言 assert_common_util(self, response, 200, False, 20001, "用户名或密码错误")
def test14_more_params(self): # 使用实例化的login_api发送登陆接口请求 response = self.login_api.login({ "mobile": "13800000002", "password": "******", "more": "111" }) # 打印登陆的数据 print("错误参数:", response.json()) # 断言 assert_common_util(self, response, 200, True, 10000, "操作成功")
def test02_add_emp(self): # 先调用添加员工接口,调用时输入添加员工接口所需要的请求体数据、请求头 jsonData = { "username": "******", "mobile": "15856786813", "timeOfEntry": "2020-07-07", "formOfEmployment": 1, "workNumber": "12312313", "departmentName": "销售", "departmentId": "1266699057968001024", "correctionTime": "2020-07-28T16:00:00.000Z" } print("app.HEADERS: ", app.HEADERS) response = self.emp_api.add_emp(jsonData, app.HEADERS) # 打印添加的结果 print("添加员工的结果为:", response.json()) # 断言添加员工 assert_common_util(self, response, 200, True, 10000, "操作成功") # 提取员工ID,并把员工ID保存到全局变量 app.EMP_ID = response.json().get("data").get("id")