Exemple #1
0
    def test04_modify_emp(self, username, http_code, success, code, message):
        # 发送修改员工的请求
        response = self.emp_api.modify_emp(app.EMPID, app.HEADERS, username)
        # 打印修改的结果
        logging.info("修改员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(http_code, success, code, message, response, self)
    def test04_modify_emp(self):
        # 发送修改员工的请求
        response = self.emp_api.modify_emp(app.EMPID, app.HEADERS, "贝克汉姆")
        # 打印修改的结果
        logging.info("修改员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)
Exemple #3
0
 def test05_delete_emp(self, http_code, success, code, message):
     # 发送删除员工的请求
     response = self.emp_api.delete_emp(
         app.EMPID,
         app.HEADERS,
     )
     # 打印删除的结果
     logging.info("删除的结果为:{}".format(response.json()))
     # 断言
     assert_common(http_code, success, code, message, response, self)
 def test05_delete_emp(self):
     # 发送删除员工的请求
     from test_ihrm_project import app
     response = self.emp_api.delete_emp(
         app.EMPID,
         app.HEADERS,
     )
     # 打印删除的结果
     logging.info("删除的结果为:{}".format(response.json()))
     # 断言
     assert_common(200, True, 10000, "操作成功", response, self)
 def test02_add_emp(self):
     # 添加员工
     response = self.emp_api.add_emp(app.HEADERS, "王者荣耀仑supe21566",
                                     "1784752343")
     # 打印添加的结果
     logging.info("添加员工的结果为:{}".format(response.json()))
     # 提取添加员工中的id
     emp_id = response.json().get("data").get("id")
     app.EMPID = emp_id  # 保存emp_id到全局变量app.py中
     # 断言
     assert_common(200, True, 10000, "操作成功", response, self)
 def test06_mobile_has_special_char(self):
     # 定义请求头
     headers = {"Content-Type": "application/json"}
     jsonData = {"mobile": "138(0000002", "password": "******"}
     # 发送登录请求
     response = self.login_api.login(jsonData, headers)
     # 打印登录的结果
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 断言
     assert_common(200, False, 20001, "用户名或密码错误", response, self)
 def test04_mobile_is_empty(self):
     # 定义请求头
     headers = {"Content-Type": "application/json"}
     jsonData = {"mobile": "", "password": "******"}
     # 发送登录请求
     response = self.login_api.login(jsonData, headers)
     # 打印登录的结果
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 断言
     assert_common(200, False, 20001, "用户名或密码错误", response, self)
 def test12_None(self):
     # 定义请求头
     headers = {"Content-Type": "application/json"}
     jsonData = None
     # 发送登录请求
     response = self.login_api.login(jsonData, headers)
     # 打印登录的结果
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 断言
     assert_common(200, False, 99999, "抱歉,系统繁忙,请稍后重试!", response, self)
 def test10_none_params(self):
     # 定义请求头
     headers = {"Content-Type": "application/json"}
     jsonData = {}
     # 发送登录请求
     response = self.login_api.login(jsonData, headers)
     # 打印登录的结果
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 断言
     assert_common(200, False, 20001, "用户名或密码错误", response, self)
Exemple #10
0
 def test02_add_emp(self, username, mobile, http_code, success, code,
                    message):
     # 添加员工
     response = self.emp_api.add_emp(app.HEADERS, username, mobile)
     # 打印添加的结果
     logging.info("添加员工的结果为:{}".format(response.json()))
     # 提取添加员工中的id
     emp_id = response.json().get("data").get("id")
     app.EMPID = emp_id  # 保存emp_id到全局变量app.py中
     # 断言
     assert_common(http_code, success, code, message, response, self)
 def test07_more_params(self):
     # 定义请求头
     headers = {"Content-Type": "application/json"}
     jsonData = {
         "mobile": "13800000002",
         "password": "******",
         "more_params": "1"
     }
     # 发送登录请求
     response = self.login_api.login(jsonData, headers)
     # 打印登录的结果
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 断言
     assert_common(200, True, 10000, "操作成功", response, self)
    def test01_login_success(abc):
        # IHRM项目可以直接发送登录请求
        headers = {"Content-Type": "application/json"}  # 定义请求头
        jsonData = {"mobile": "13800000002", "password": "******"}
        # 发送登录请求
        response = abc.login_api.login(jsonData, headers)
        # 打印登录的结果cvf
        result = response.json()
        logging.info("登录的结果为:{}".format(result))
        # # 断言登录的结果
        # self.assertEqual(200, response.status_code)  # 断言响应状态码
        # self.assertEqual(True, result.get("success"))  # 断言success
        # self.assertEqual(10000, result.get("code"))  # 断言code
        # self.assertIn("操作成功", result.get("message"))  # 断言message

        # 使用封装的通用断言函数实现优化断言
        assert_common(200, True, 10000, "操作成功", response, abc)
    def test01_employee_manage(self):
        # 实现员工的增删改查
        # 登录
        response = self.login_api.login(
            {
                "mobile": "13800000003",
                "password": "******"
            }, {"Content-Type": "application/json"})
        # 打印登录的数据
        logging.info("登录的结果为:{}".format(response.json()))
        # 提取令牌
        token = response.json().get("data")
        # 保存令牌到请求头当中
        headers = {
            "Content-Type": "application/json",
            "Authorization": "Bearer " + token
        }
        # 打印令牌
        logging.info("请求头中令牌:{}".format(headers))

        # 添加员工
        response = self.emp_api.add_emp(headers, "王者耀super084", "17835793213")
        # 打印添加的结果
        logging.info("添加员工的结果为:{}".format(response.json()))
        # 提取添加员工中的id
        emp_id = response.json().get("data").get("id")
        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)

        # 查询员工
        # 发送查询员工的请求
        response = self.emp_api.query_emp(emp_id, headers)
        logging.info("查询员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)

        # 修改员工
        # 发送修改员工的请求
        response = self.emp_api.modify_emp(emp_id, headers, "贝克汉姆")
        # 打印修改的结果
        logging.info("修改员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)

        # 删除员工
        # 发送删除员工的请求
        response = self.emp_api.delete_emp(emp_id, headers)
        # 打印删除的结果
        logging.info("删除的结果为:{}".format(response.json()))
        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)
 def test01_login(abc, case_name, jsonData, http_code, success, code,
                  message):
     # IHRM项目可以直接发送登录请求
     headers = {"Content-Type": "application/json"}  # 定义请求头
     jsonData = jsonData
     # 发送登录请求
     response = abc.login_api.login(jsonData, headers)
     # 打印登录的结果cvf
     result = response.json()
     logging.info("登录的结果为:{}".format(result))
     # 使用封装的通用断言函数实现优化断言
     assert_common(
         http_code,
         success,
         code,
         message,
         response,
         abc,
     )
    def test03_query_emp(self):
        response = self.emp_api.query_emp(app.EMPID, app.HEADERS)
        logging.info("查询员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(200, True, 10000, "操作成功", response, self)
Exemple #16
0
    def test03_query_emp(self, http_code, success, code, message):
        response = self.emp_api.query_emp(app.EMPID, app.HEADERS)
        logging.info("查询员工的结果为:{}".format(response.json()))

        # 断言
        assert_common(http_code, success, code, message, response, self)