def test_02_add_emp(self, username, mobile, http_code, code, success, message): response = self.emp_api.add_emp(app.HEADERS, username, mobile) logging.info("添加员工的结果是:{}".format(response.json())) assert_comment(http_code, code, success, message, response, self) emp_id = response.json().get("data").get("id") app.EMP_ID = emp_id
def test07_more_params(self): data = { "mobile": "13800000002", "password": "******", "more_params": "1" } headers = {"Content-Type": "application/json"} response = self.login_api.login(data, headers) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self)
def test_01_login(self): response = self.login_api.login({"mobile": "13800000002", "password": "******"}, {"Content-Type": "application/json"}) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self) # 获取令牌 token = response.json().get('data') headers = {"Content-Type": "application/json", "Authorization": "Bearer " + token} app.HEADERS = headers
def test01_emp_mange(self): response = self.login_api.login( { "mobile": "13800000002", "password": "******" }, {"Content-Type": "application/json"}) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self) # 获取令牌 token = response.json().get('data') headers = { "Content-Type": "application/json", "Authorization": "Bearer " + token } response = self.emp_api.add_emp(headers, "小偷家族55", "17512345676") logging.info("添加员工的结果是:{}".format(response.json())) emp_id = response.json().get("data").get("id") # 提取添加员工响应数据中的id response = self.emp_api.query_emp(emp_id, headers) logging.info("查询员工的结果是:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self) response = self.emp_api.modify_emp(emp_id, headers, "古力娜扎") logging.info("修改员工的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self) response = self.emp_api.delete_emp(emp_id, headers) logging.info("删除员工的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self)
def test12_input_none(self): data = None headers = {"Content-Type": "application/json"} response = self.login_api.login(data, headers) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 99999, False, "抱歉,系统繁忙,请稍后重试!", response, self)
def test11_wrong_params(self): data = {"mobile": "13800000002", "paasssword": "123456"} headers = {"Content-Type": "application/json"} response = self.login_api.login(data, headers) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 20001, False, "用户名或密码错误", response, self)
def test10_null_params(self): data = {} headers = {"Content-Type": "application/json"} response = self.login_api.login(data, headers) logging.info("登录的结果为:{}".format(response.json())) assert_comment(200, 20001, False, "用户名或密码错误", response, self)
def test_05_delete_emp(self, http_code, code, success, message): response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS) logging.info("删除员工的结果为:{}".format(response.json())) assert_comment(http_code, code, success, message, response, self)
def test_04_mpdify_emp(self, username, http_code, code, success, message): response = self.emp_api.modify_emp(app.EMP_ID, app.HEADERS, username) logging.info("修改员工的结果为:{}".format(response.json())) assert_comment(http_code, code, success, message, response, self)
def test_03_query_emp(self, http_code, code, success, message): response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS) logging.info("查询员工的结果是:{}".format(response.json())) assert_comment(http_code, code, success, message, response, self)
def test_login(self, case_name, data, http_code, code, success, message): headers = {"Content-Type": "application/json"} response = self.login_api.login(data, headers) logging.info("登录的结果为:{}".format(response.json())) assert_comment(http_code, code, success, message, response, self)
def test_05_delete_emp(self): response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS) logging.info("删除员工的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self)
def test_04_mpdify_emp(self): response = self.emp_api.modify_emp(app.EMP_ID, app.HEADERS, "古力娜扎") logging.info("修改员工的结果为:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self)
def test_03_query_emp(self): response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS) logging.info("查询员工的结果是:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self)
def test_02_add_emp(self): response = self.emp_api.add_emp(app.HEADERS, "小偷家族77", "17512345677") logging.info("添加员工的结果是:{}".format(response.json())) assert_comment(200, 10000, True, "操作成功", response, self) emp_id = response.json().get("data").get("id") app.EMP_ID = emp_id