def test05_emp_del(self, message, http_code, success, code): # 调用删除员工 response_emp_del = self.emp_api.emp_del(app.EMP_ID, app.HEADERS) logging.info("删除的结果为:{}".format(response_emp_del.json())) # 调用工具类的断言接口 assert_common_utils(self, response_emp_del, http_code, success, code, message)
def test03_emp_select(self, message, http_code, success, code): # 调用查询员工 response_emp_select = self.emp_api.emp_select(app.EMP_ID, app.HEADERS) logging.info("查询的结果为:{}".format(response_emp_select.json())) # 调用工具类的断言接口 assert_common_utils(self, response_emp_select, http_code, success, code, message)
def test03_emp_select(self): # 调用查询员工 response_emp_select = self.emp_api.emp_select(app.EMP_ID, app.HEADERS) logging.info("查询的结果为:{}".format(response_emp_select.json())) # 调用工具类的断言接口 assert_common_utils(self, response_emp_select, 200, True, 10000, "操作成功")
def test02_emp_add(self): # 调用添加员工 response_emp_add = self.emp_api.emp_add("葫芦娃去1救爷爷了838", "13423121838", app.HEADERS) logging.info("添加员工结果为:{}".format(response_emp_add.json())) # 获取添加的员工id app.EMP_ID = response_emp_add.json().get("data").get("id") logging.info("添加的员工id为:{}".format(app.EMP_ID)) # 调用工具类的断言接口 assert_common_utils(self, response_emp_add, 200, True, 10000, "操作成功")
def test02_emp_add(self, username, message, mobile, http_code, success, code): # 调用添加员工 response_emp_add = self.emp_api.emp_add(username, mobile, app.HEADERS) logging.info("添加员工结果为:{}".format(response_emp_add.json())) # 获取添加的员工id app.EMP_ID = response_emp_add.json().get("data").get("id") logging.info("添加的员工id为:{}".format(app.EMP_ID)) # 调用工具类的断言接口 assert_common_utils(self, response_emp_add, http_code, success, code, message)
def test04_emp_update(self): # 调用修改员工 response_emp_update = self.emp_api.emp_update(app.EMP_ID, app.HEADERS, "葫芦娃救爷爷葫芦大娃123") logging.info("修改的结果为:{}".format(response_emp_update.json())) # 调用工具类的断言接口 with DBUtils() as db: sql = "select username from bs_user where id={}".format(app.EMP_ID) logging.info("查询的SQL语句为:{}".format(sql)) # 执行sql语句 db.execute(sql) # 获取结果行数 result = db.fetchone() logging.info("修改后SQL结果为:{}".format(result)) # 对返回的查询结果进行断言 self.assertIn("葫芦娃救爷爷葫芦大娃123", result[0]) # 断言结果 assert_common_utils(self, response_emp_update, 200, True, 10000, "操作成功")
def test04_emp_update(self, username, message, http_code, success, code): # 调用修改员工 response_emp_update = self.emp_api.emp_update(app.EMP_ID, app.HEADERS, username) logging.info("修改的结果为:{}".format(response_emp_update.json())) # 调用工具类的断言接口 with DBUtils() as db: sql = "select username from bs_user where id={}".format(app.EMP_ID) logging.info("查询的SQL语句为:{}".format(sql)) # 执行sql语句 db.execute(sql) # 获取结果行数 result = db.fetchone() logging.info("修改后SQL结果为:{}".format(result)) # 对返回的查询结果进行断言 self.assertIn(username, result[0]) # 断言结果 assert_common_utils(self, response_emp_update, http_code, success, code, message)
def test05_emp_del(self): # 调用删除员工 response_emp_del = self.emp_api.emp_del(app.EMP_ID, app.HEADERS) logging.info("删除的结果为:{}".format(response_emp_del.json())) # 调用工具类的断言接口 assert_common_utils(self, response_emp_del, 200, True, 10000, "操作成功")
def test02_username_is_exist(self): response = self.login_api.login("13870000002", "123456") logging.info("用户名不存在的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
def test11_not_parameter(self): response = requests.post("http://182.92.81.159/api/sys/login") logging.info("无参数的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 99999, "抱歉,系统繁忙,请稍后重试")
def test10_more_parameter(self): response = self.login_api.my_login({"mobile": "13800000002", "password": "******","admin":"asas"}) logging.info("多参数的结果:{}".format(response.json())) assert_common_utils(self, response, 200, True, 10000, "操作成功")
def test09_error_password(self): response = self.login_api.my_login({"mobile": "13800000002", "password1": "123456"}) logging.info("错误参数password的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
def test07_lack_password(self): response = self.login_api.my_login({"mobile":"13800000002"}) logging.info("缺少参数mobile的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
def test05_password_is_null(self): response = self.login_api.login("13800000002", "") logging.info("密码为空的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
def test04_username_is_null(self): response = self.login_api.login("", "123456") logging.info("用户名为空的结果:{}".format(response.json())) assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
def test01_login(self,mobile, password, http_code, success, code, message): response = self.login_api.login(mobile,password) logging.info("登录成功结果:{}".format(response.json())) assert_common_utils(self,response,http_code,success,code,message)
def test01_login_success(self): response = self.login_api.login("13800000002","123456") logging.info("登录成功结果:{}".format(response.json())) assert_common_utils(self,response,200,True,10000,"操作成功")