예제 #1
0
    def test_05_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_count(self, http_code, success, code, message, response)
예제 #2
0
 def test_04_modify_emp(self):
     #         发送修改员工的接口
     response = self.emp_api.modify_emp(app.EMP_ID, app.HEADERS,
                                        {"username": "******"})
     # 打印修改员工的数据
     logging.info("修改员工:{}".format(response.json()))
     assert_count(self, 200, True, 10000, "操作成功", response)
예제 #3
0
    def test_05_delete_emp(self):
        #         发送删除员工接口
        response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS)

        # 打印删除员工的结果
        logging.info("删除员工:{}".format(response.json()))
        assert_count(self, 200, True, 10000, "操作成功", response)
예제 #4
0
 def test_04_modify_emp(self, username, success, code, message, http_code):
     #         发送修改员工的接口
     response = self.emp_api.modify_emp(app.EMP_ID, app.HEADERS,
                                        {"username": username})
     # 打印修改员工的数据
     logging.info("修改员工:{}".format(response.json()))
     assert_count(self, http_code, success, code, message, response)
예제 #5
0
    def test_02_mobile_is_empty(self):
        response = self.login_api.login({"mobile": "", "password": "******"},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("手机号码为空结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 20001, "用户名或密码错误", response)
예제 #6
0
    def test_07_more_params(self):
        response = self.login_api.login({"mobile": "13800000002", "password": "******", "more_params": "1"},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("多参结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, True, 10000, "操作成功", response)
예제 #7
0
    def test_06_params_is_null(self):
        response = self.login_api.login(None,
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("传入null结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 99999, "抱歉,系统繁忙,请稍后重试!", response)
예제 #8
0
    def test_05_params_is_none(self):
        response = self.login_api.login({},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("无参结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 20001, "用户名或密码错误", response)
예제 #9
0
    def test_04_password_is_error(self):
        response = self.login_api.login({"mobile": "13800000002", "password": "******"},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("密码错误:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 20001, "用户名或密码错误", response)
예제 #10
0
    def test_03_mobile_is_not_exists(self):
        response = self.login_api.login({"mobile": "13800123456", "password": "******"},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("手机号码不存在结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 20001, "用户名或密码错误", response)
예제 #11
0
    def test_09_less_password(self):
        response = self.login_api.login({"mobile": "13800000002"},
                                        {"Content-Type": "application/json"})

        # 打印响应结果
        logging.info("少参结果:{}".format(response.json()))

        # 断言
        assert_count(self, 200, False, 20001, "用户名或密码错误", response)
예제 #12
0
 def test_02_add_emp(self):
     # logging.info("app.HEADERS的值是:{}".format(app.HEADERS))
     # 发送添加员工的接口请求
     response = self.emp_api.add_emp("祖冲之11", "13891755432", app.HEADERS)
     # 提取员工的令牌保存到全局变量
     app.EMP_ID = response.json().get("data").get("id")
     # 打印保存的员工ID
     logging.info("全局变量的ID为:{}".format(app.EMP_ID))
     # 断言
     assert_count(self, 200, True, 10000, "操作成功", response)
예제 #13
0
    def test_01_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_count(self, http_code, success, code, message, response)
예제 #14
0
 def test_02_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)
     # 提取员工的令牌保存到全局变量
     app.EMP_ID = response.json().get("data").get("id")
     # 打印保存的员工ID
     logging.info("全局变量的ID为:{}".format(app.EMP_ID))
     # 断言
     assert_count(self, http_code, success, code, message, response)
예제 #15
0
    def test_01_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并保存到全局变量
        app.HEADERS = {
            "Content-Type": "application/json",
            "Authorization": token
        }
        # 打印请求头
        logging.info("全局变量的请求头:{}".format(app.HEADERS))

        # 断言
        assert_count(self, 200, True, 10000, "操作成功", response)
예제 #16
0
 def test_03_query_emp(self):
     #         发送查询员工的接口
     response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS)
     #         打印查询员工的数据
     logging.info("查询员工的结果:{}".format(response.json()))
     assert_count(self, 200, True, 10000, "操作成功", response)
예제 #17
0
 def test_03_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_count(self, http_code, success, code, message, response)