Exemplo n.º 1
0
 def test01_login(self,case_name, request_body, success,code,message,http_code):
     # 使用封装的接口调用登录接口,并接收返回的响应数据
     response = self.login_api.login(request_body,
                                     {"Content-Type": "application/json"})
     # 打印响应数据
     logging.info("登录的结果为:{}".format(response.json()))
     assert_common(self, http_code, success, code, message, response)
Exemplo n.º 2
0
 def test05_delete_emp(self, success, code, message, http_code):
     # 调用封装的删除员工接口哦,发送接口请求
     response = self.emp_api.delete_emp(app_配置信息.EMP_ID, app_配置信息.HEADERS)
     # 打印删除员工的结果为
     logging.info("删除员工的结果为:{}".format(response.json()))
     # 断言
     assert_common(self, http_code, success, code, message, response)
Exemplo n.º 3
0
 def test03_query_emp(self, success, code, message, http_code):
     # 发送查询员工的接口请求:
     response = self.emp_api.query_emp(app_配置信息.EMP_ID, app_配置信息.HEADERS)
     # 打印查询员工的数据
     logging.info("查询员工的结果为:{}".format(response.json()))
     # 断言
     assert_common(self, http_code, success, code, message, response)
Exemplo n.º 4
0
 def test_04_modify_emp(self):
     # 发送修改员工的接口请求
     response = self.emp_api.modify_emp(app_配置信息.EMP_ID,
                                        {"username": "******"},
                                        app_配置信息.HEADERS)
     # 打印查询员工的数据
     logging.info("修改结果:{}".format(response.json()))
     assert_common(self, 200, True, 10000, "操作成功", response)
Exemplo n.º 5
0
 def test04_modify_emp(self, username, success, code, message, http_code):
     # 调用封装的修改员工接口,发送接口请求
     response = self.emp_api.modify_emp(app_配置信息.EMP_ID,
                                        {"username": username},
                                        app_配置信息.HEADERS)
     # 打印数据
     logging.info("修改员工的结果为:{}".format(response.json()))
     # 断言
     assert_common(self, http_code, success, code, message, response)
Exemplo n.º 6
0
 def test_02_add_emp(self):
     #         发送添加员工的接口请求
     response = self.emp_api.add_emp("鲤鱼王11", "138002003777",
                                     app_配置信息.HEADERS)
     #         打印添加员工的结果
     logging.info("添加结果:".format(response.json()))
     # 提取员工令牌保存到全局变量
     app_配置信息.EMP_ID = response.json().get("data").get("id")
     # 打印保存员工ID
     logging.info("保存的员工ID:{}".format(app_配置信息.EMP_ID))
     assert_common(self, 200, True, 10000, "操作成功", response)
Exemplo n.º 7
0
 def test02_add_emp(self, username, mobile, success, code, message,
                    http_code):
     logging.info("app.HEADERS的值是:{}".format(app_配置信息.HEADERS))
     # 发送添加员工的接口请求
     response = self.emp_api.add_emp(username, mobile, app_配置信息.HEADERS)
     # 打印添加员工的结果
     logging.info("添加员工的结果为:{}".format(response.json()))
     # 提取员工中的令牌并把员工令牌保存到全局变量中
     app_配置信息.EMP_ID = response.json().get("data").get("id")
     # 打印保存的员工ID
     logging.info("保存到全局变量的员工的ID为:{}".format(app_配置信息.EMP_ID))
     # 断言
     assert_common(self, http_code, success, code, message, response)
Exemplo n.º 8
0
 def test01_login_success(self):
     # 发送登录的接口请求
     jsonData = {"mobile": "13800000002", "password": "******"}
     response = self.login_api.login(jsonData,
                                     {"Content-Type": "application/json"})
     # 打印登录接口返回的结果
     logging.info("登录接口返回的结果为:{}".format(response.json()))
     # 提取登录返回的令牌
     token = 'Bearer ' + response.json().get('data')
     # 把令牌拼接成HEADERS并保存到全局变量HEADERS
     app_配置信息.HEADERS = {
         "Content-Type": "application/json",
         "Authorization": token
     }
     # 打印请求头
     logging.info("保存到全局变量中的请求头为:{}".format(app_配置信息.HEADERS))
     assert_common(self, 200, True, 10000, "操作成功", response)
Exemplo n.º 9
0
 def test_05_delete_emp(self):
     # 发送删除员工的接口请求
     response = self.emp_api.delete_emp(app_配置信息.EMP_ID, app_配置信息.HEADERS)
     # 打印查询员工的数据
     logging.info("删除结果:{}".format(response.json()))
     assert_common(self, 200, True, 10000, "操作成功", response)