def test009_erorr_parame(self): reponse = self.login_api.login_parmae({ "mbile": "13800000002", "password": "******" }) logging.info("错参的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, 200, False, 20001, "用户名或密码错误")
def test001_login_success(self): app.init_logger() reponse = self.login_token.get_login("13800000002","123456") logging.info("登录结果为:{}".format(reponse.json())) token = "Bearer " + reponse.json().get("data") logging.info("获取的令牌为:{}".format(token)) headers = {"Content-Type":"application/json","Authorization":token} reponse1 = requests.get("http://182.92.81.159/api/company/department",headers=headers) logging.info("获取的部门信息为:{}".format(reponse1.json().get("data").get("depts"))) #添加部门 reponse2 = requests.post("http://182.92.81.159/api/company/department", json={"name":"乔巴","code":"9527"},headers=headers,) logging.info("添加的结果为:{}".format(reponse2.json().get("data"))) assert_conmm_utils(self,reponse2,200,True,10000,"操作成功!") # # #查询部门 # reponse3 = requests.get() # def obtion_department_info(self): # pass # def test002_add_department(self): # pass # def test003_index_department(self): # pass # def test004_delete_department(self): # pass
def test008_many_parmae(self): reponse = self.login_api.login_parmae({ "mobile": "13800000002", "password": "******", "a": "1" }) logging.info("多参的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, 200, True, 10000, "操作成功!")
def test02_add_emp(self,username,mobile,http_code,success,code,message): reponse_add_emp = self.login_api.add_emp(username,mobile,app.HEADERS) logging.info("添加员工结果为:{}".format(reponse_add_emp.json())) assert_conmm_utils(self,reponse_add_emp,http_code,success,code,message) emp_id = reponse_add_emp.json().get("data").get("id") app.EMP_ID = emp_id logging.info("保存的员工id:{}".format(reponse_add_emp.json()))
def test04_put_emp(self,username,http_code,success,code,message): reponse_set_emp =self.login_api.put_emp(app.EMP_ID,username,headers=app.HEADERS) logging.info("修改员工结果为:{}".format(reponse_set_emp.json())) #连接数据库 with SqlUtils() as db: # conn = pymysql.connect(host="182.92.81.159",user="******",password="******",database="ihrm",) # cursor = conn.cursor() sql = "select username from bs_user where id={};".format(app.EMP_ID) db.execute(sql) logging.info("要查询的语句为:{}".format(sql)) result = db.fetchone() logging.info("查询结果为:{}".format(result)) self.assertEqual(username,result[0]) assert_conmm_utils(self,reponse_set_emp, http_code,success,code,message)
def test05_delete_emp(self,http_code,success,code,message): reponse_delete_emp =self.login_api.delete_emp(app.EMP_ID,headers=app.HEADERS) logging.info("删除员工结果为:{}".format(reponse_delete_emp.json())) assert_conmm_utils(self,reponse_delete_emp,http_code,success,code,message)
def test010_none_paeame(self): reponse = self.login_api.login_parmae(None) logging.info("无参的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, 200, False, 99999, "抱歉,系统繁忙,请稍后重试!")
def test007_less_password_parame(self): reponse = self.login_api.login_parmae({"mobile": "13800000002"}) logging.info("缺少password的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, 200, False, 20001, "用户名或密码错误")
def test006_less_mobile_parame(self): reponse = self.login_api.login_parmae({"password": "******"}) logging.info("缺少mobile的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, 200, False, 20001, "用户名或密码错误")
def test001_login_is_success(self, case_name, mobile, password, http_code, success, code, message): app.init_logger() reponse = self.login_api.login_auto(mobile, password) logging.info("登陆成功的结果为:{}".format(reponse.json())) assert_conmm_utils(self, reponse, http_code, success, code, message)