Ejemplo n.º 1
0
    def test04_modify_emp(self, username, http_code, success, code, message):
        # 调用修改员工
        response_modify = self.emp_aip.modify_emp(app.EMPID, username,
                                                  app.HEADERS)
        logging.info("修改员工的结果为:{}".format(response_modify))

        # 建立连接
        with DBUtils() as db:

            # 执行SQL语句(根据添加员工返回的EMPID,查询数据库员工表表的username)
            # 查询语句
            SQL1 = "select username from bs_user where id={};".format(
                app.EMPID)
            logging.info("要查询的SQL语句为:{}".format(SQL1))
            # 执行语句
            db.execute(SQL1)
            # 获取结果
            result1 = db.fetchone()
            logging.info("SQL查询出来的结果为:{}".format(result1))
            # 断言修改结果是否正确
            self.assertEqual(username, result1[0])

        # 断言结果: 响应状态码,success,code,message
        assert_common_utils(self, response_modify, http_code, success, code,
                            message)
Ejemplo n.º 2
0
 def test08_less_password(self):
     # 调用登陆接口
     response = self.login_api.login_params({"mobile":"13800000002"})
     # 打印结果
     logging.info("测试缺少password的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 3
0
 def test09_add_params(self):
     # 调用登陆接口
     response = self.login_api.login_params({"mobile": "13800000002", "password": "******", "add_params": "sss"})
     # 打印结果
     logging.info("测试增加1个参数的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, True, 10000, "操作成功")
Ejemplo n.º 4
0
 def test01_login(self,mobile,password,http_code,success,code,message):
     # 调用登录接口
     response1 = self.login_api.login(mobile,password)
     # 打印结果
     logging.info("参数化登录结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self,response1,http_code,success,code,message)
Ejemplo n.º 5
0
 def test07_less_mobile(self):
     # 调用登陆接口
     response = self.login_api.login_params({"password": "******"})
     # 打印结果
     logging.info("测试缺少mobile的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 6
0
 def test05_delete_emp(self, http_code, success, code, message):
     # 调用删除员工
     response_delete = self.emp_api.delete_emp(app.EMPID, app.HEADERS)
     logging.info("删除员工的结果为:{}".format(response_delete.json()))
     # 断言结果:响应状态码,success,code,message
     assert_common_utils(self, response_delete, http_code, success, code,
                         message)
 def test05_delete_emp(self):
     # 调用删除员工
     response_delete = self.emp_api.delete_emp(app.EMPID,
                                               headers=app.HEADERS)
     logging.info("删除员工的结果为:{}".format(response_delete.json()))
     # 断言结果:响应状态码,success,code,message
     assert_common_utils(self, response_delete, 200, True, 10000, "操作成功")
Ejemplo n.º 8
0
 def test06_password_is_empty(self):
     # 调用登录接口
     response1 = self.login_api.login("13800000002", "")
     # 打印结果
     logging.info("密码为空结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 9
0
 def test08_less_password(self):
     response1 = requests.post("http://182.92.81.159/api/sys/login",
                               json={"mobile": "13800000002"})
     # 打印结果
     logging.info("缺少password结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 10
0
 def test04_none_params(self):
     response1 = requests.post("http://182.92.81.159/api/sys/login")
     # 打印结果
     logging.info("无参结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, False, 99999,
                         "抱歉,系统繁忙,请稍后重试")
Ejemplo n.º 11
0
 def test05_username_is_empty(self):
     # 调用登录接口
     response1 = self.login_api.login("", "1234567")
     # 打印结果
     logging.info("用户名为空结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 12
0
 def test02_username_is_not_exist(self):
     # 调用登录接口
     response1 = self.login_api.login("19900000002", "123456")
     # 打印结果
     logging.info("用户名不存在结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 13
0
 def test01_login_success(self):
     # 调用登录接口
     response1 = self.login_api.login("13800000002", "123456")
     # 打印结果
     logging.info("登录结果为:{}".format(response1))
     # 断言登录结果
     assert_common_utils(self, response1, 200, True, 10000, "操作成功")
Ejemplo n.º 14
0
 def test06_delete_emp(self, http_code, success, code, message):
     # 调用删除员工
     response_delete = self.emp_aip.delete_emp(app.EMPID, app.HEADERS)
     logging.info("删除员工的结果为:{}".format(response_delete))
     # 断言结果: 响应状态码,success,code,message
     assert_common_utils(self, response_delete, http_code, success, code,
                         message)
Ejemplo n.º 15
0
 def test03_query_emp(self, http_code, success, code, message):
     # 调用查询员工
     response_query = self.emp_api.query_emp(app.EMPID, headers=app.HEADERS)
     logging.info("查询员工的结果为:{}".format(response_query.json()))
     # 断言结果:响应状态码,success,code,message
     assert_common_utils(self, response_query, http_code, success, code,
                         message)
Ejemplo n.º 16
0
    def test_emp_manage(self):
        #完成登录
        login_resp = self.login_api.login(self.session,'13800000002','123456')
        logging.info("login_resp={}".format(login_resp.json()))
        assert_common_utils(self, login_resp, 200, True, 10000, '操作成功')
        #登录成功后,获取cookie数据,并拼接为token
        b_token = "Bearer " + login_resp.json().get('data')
        logging.info("token={}".format(b_token))

        #添加员工
        add_resp = self.emp_api.add_emp(self.session,"tom","13012341118")
        logging.info("add_resp={}".format(add_resp.json()))
        assert_common_utils(self, add_resp, 200, True, 10000, '操作成功')

        #获取员工ID
        userid = add_resp.json().get('data').get('id')
        logging.info("userid={}".format(userid))
        #查询员工
        query_resp = self.emp_api.query_emp(self.session,userid)
        logging.info("query_resp={}".format(query_resp.json()))
        #断言
        assert_common_utils(self, query_resp, 200, True, 10000, '操作成功')

        #修改员工
        modify_data = {"username":"******"}
        modify_resp = self.emp_api.modify_emp(self.session,userid,modify_data)
        logging.info("modify_resp={}".format(modify_resp.json()))
        # 断言
        assert_common_utils(self, modify_resp, 200, True, 10000, '操作成功')

        #删除员工
        delete_resp = self.emp_api.delete_emp(self.session,userid)
        logging.info("delete_resp={}".format(delete_resp.json()))
        # 断言
        assert_common_utils(self, delete_resp, 200, True, 10000, '操作成功')
Ejemplo n.º 17
0
    def test04_modify_emp(self, username, http_code, success, code, message):
        # 调用修改员工
        response_modify = self.emp_api.modify_emp(app.EMPID,
                                                  username,
                                                  headers=app.HEADERS)
        logging.info("修改员工结果为:{}".format(response_modify.json()))

        # 建立连接 username:readuser
        # password:iHRM_user_2019
        with DBUtils() as db:
            # 执行SQL语句
            # 根据添加员工返回的id查询数据库中员工表的username,这样就能获取到修改之后的数据
            sql = "select username from bs_user where id = {};".format(
                app.EMPID)
            logging.info("要查询的SQL语句为:{}".format(sql))
            # 执行查询的sql语句
            db.execute(sql)
            # 获取返回结果
            result = db.fetchone()
            logging.info("SQL查询出来的结果为:{}".format(result))  # ('new_tom',)
            # 断言修改结果是否正确
            # 注意:如果是用fetchall()取出的数据,那么取出result时,需要有两个下标result[0][0]
            self.assertEqual(username, result[0])

        # 断言结果:响应状态码,success,code,message
        assert_common_utils(self, response_modify, http_code, success, code,
                            message)
Ejemplo n.º 18
0
 def test10_error_params(self):
     # 调用登陆接口
     response = self.login_api.login_params({"mobile": "13800000002", "passwod": "123456"})
     # 打印结果
     logging.info("测试错误参数的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 19
0
 def test03_query_emp(self, http_code, success, code, message):
     # 调用查询员工
     response_query = self.emp_aip.query_emp(app.EMPID, app.HEADERS)
     logging.info("查询员工的结果为:{}".format(response_query))
     # 断言结果: 响应状态码,success,code,message
     assert_common_utils(self, response_query, http_code, success, code,
                         "message")
Ejemplo n.º 20
0
 def test06_password_is_empty(self):
     # 调用登陆接口
     response = self.login_api.login("13800000002", "")
     # 打印结果
     logging.info("密码为空的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 21
0
 def test03_password_is_error(self):
     # 调用登陆接口
     response = self.login_api.login("13800000002", "1234567")
     # 打印结果
     logging.info("测试密码错误的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 22
0
 def test05_username_is_null(self):
     # 调用登陆接口
     response = self.login_api.login("", "1234567")
     # 打印结果
     logging.info("用户名为空的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 23
0
 def test02_username_is_not_exist(self):
     # 调用登陆接口
     response = self.login_api.login("13900000002", "123456")
     # 打印结果
     logging.info("测试用户名不存在的结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 24
0
 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, "操作成功")
Ejemplo n.º 25
0
 def test05_delete_emp(self):
     # 5 实现删除员工接口
     # 发送删除员工接口请求
     response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS)
     # 打印删除员工的结果
     logging.info("删除员工的结果为:{}".format(response.json()))
     # 断言
     assert_common_utils(self, response, 200, True, 10000, "操作成功")
Ejemplo n.º 26
0
 def test03_query_emp(self):
     # 3 实现查询员工接口
     # 发送查询员工的接口请求
     response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS)
     # 打印查询员工的结果
     logging.info("查询员工的结果为:{}".format(response.json()))
     # 断言
     assert_common_utils(self, response, 200, True, 10000, "操作成功")
Ejemplo n.º 27
0
 def test07_less_mobile(self):
     # 注意:无参有点特殊,我们按照现有的封装方法,无法对无参进行封装测试
     # 只能单独处理
     response = self.login_api.login_params({"password": "******"})
     # 打印结果
     logging.info("缺少mobile结果为:{}".format(response.json()))
     # 断言登陆结果
     assert_common_utils(self, response, 200, False, 20001, "用户名或密码错误")
Ejemplo n.º 28
0
 def test03_query_emp(self, http_code, success, code, message):
     # 3 实现查询员工接口
     # 发送查询员工的接口请求
     response = self.emp_api.query_emp(app.EMP_ID, app.HEADERS)
     # 打印查询员工的结果
     logging.info("查询员工的结果为:{}".format(response.json()))
     # 断言
     assert_common_utils(self, response, http_code, success, code, message)
Ejemplo n.º 29
0
 def test05_delete_emp(self, http_code, success, code, message):
     # 5 实现删除员工接口
     # 发送删除员工接口请求
     response = self.emp_api.delete_emp(app.EMP_ID, app.HEADERS)
     # 打印删除员工的结果
     logging.info("删除员工的结果为:{}".format(response.json()))
     # 断言
     assert_common_utils(self, response, http_code, success, code, message)
Ejemplo n.º 30
0
 def test05_modify_emp(self):
     # 调用修改员工
     response_modify = self.emp_api.modify_emp(app.EMPID,
                                               "new_tom",
                                               headers=app.HEADERS)
     logging.info("修改员工结果为:{}".format(response_modify.json()))
     # 断言结果:响应状态码,success,code,message
     assert_common_utils(self, response_modify, 200, True, 10000, "操作成功")