示例#1
0
 def test10_login_errorParams(self):
     response = requests.post("http://182.92.81.159/api/sys/login",
                              json={
                                  "mbile": "13800000002",
                                  "password": "******"
                              })
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
 def test02_add_emp(self, username, mobile, status_code, success, code, message):
     add_emp_info = [username, mobile]
     response_add = self.emp_api.add_emp(add_emp_info[0], add_emp_info[1], app.Header)
     # 断言
     assert_fn(self, response_add, status_code, success, code, message)
     print(response_add.json())
     # 获取新增员工ID
     emp_id = response_add.json().get("data").get("id")
     app.Emp_id = emp_id
示例#3
0
 def test09_login_moreParams(self):
     response = requests.post("http://182.92.81.159/api/sys/login",
                              json={
                                  "mobile": "13800000002",
                                  "password": "******",
                                  "add": "123"
                              })
     assert_fn(self, response, 200, True, 10000, "操作成功!")
     print(response.json())
示例#4
0
 def test01_login_success(self):
     response = self.depart_api.login("13800000002", "123456")
     print(response.json())
     # 获取令牌
     token = "Bearer " + response.json().get("data")
     # 设置请求头,将令牌放入请求头中
     headers = {"Content-Type": "application/json", "Authorization": token}
     app.Header = headers
     # 断言
     assert_fn(self, response, 200, True, 10000, "操作成功")
 def test05_delete_emp(self, status_code, success, code, message):
     response_delete = self.emp_api.delete_emp(app.Emp_id, app.Header)
     # 断言
     assert_fn(self, response_delete, status_code, success, code, message)
     print(response_delete.json())
     # 与数据库比对
     with DbUtils("182.92.81.159", "readuser", "iHRM_user_2019", "ihrm") as db:
         sql = "select * from bs_user where id = {}".format(app.Emp_id)
         db.execute(sql)
         result = db.fetchone()
         self.assertEqual(None, result)
 def test04_modify_emp(self, username, status_code, success, code, message):
     response_modify = self.emp_api.modify_emp(app.Emp_id, username, app.Header)
     # 断言
     assert_fn(self, response_modify, status_code, success, code, message)
     print(response_modify.json())
     # 与数据库比对
     with DbUtils("182.92.81.159", "readuser", "iHRM_user_2019", "ihrm") as db:
         sql = "select username from bs_user where id = {}".format(app.Emp_id)
         db.execute(sql)
         result = db.fetchone()
         self.assertEqual("new_jojo", result[0])
 def test03_search_emp(self, status_code, success, code, message):
     response_search = self.emp_api.search_emp(app.Emp_id, app.Header)
     # 断言
     assert_fn(self, response_search, status_code, success, code, message)
     print(response_search.json())
     # 与数据库比对--调用utils里面的方法
     with DbUtils("182.92.81.159", "readuser", "iHRM_user_2019", "ihrm") as db:
         sql = "select username from bs_user where id = {}".format(app.Emp_id)
         db.execute(sql)
         result = db.fetchone()
         self.assertEqual("jojo", result[0])
示例#8
0
 def test02_add_depart(self):
     response = self.depart_api.add_depart("挖坑1部", "1320", app.Header)
     # 断言
     assert_fn(self, response, 200, True, 10000, "操作成功")
     print(response.json())
     # 连接数据库,获取新增部门id
     with DbUtils("182.92.81.159", "readuser", "iHRM_user_2019",
                  "ihrm") as db:
         sql = "select id from co_department where name = '挖坑1部'"
         db.execute(sql)
         depart_id = db.fetchone()
     app.depart_id = depart_id[0]
 def test02_add_depart(self, name, code, status_code, success,
                       response_code, message):
     response = self.depart_api.add_depart(name, code, app.Header)
     # 断言
     assert_fn(self, response, status_code, success, response_code, message)
     print(response.json())
     # 连接数据库,获取新增部门id
     with DbUtils("182.92.81.159", "readuser", "iHRM_user_2019",
                  "ihrm") as db:
         sql = "select id from co_department where name = '{}'".format(name)
         db.execute(sql)
         depart_id = db.fetchone()
     app.depart_id = depart_id[0]
 def test05_delete_depart(self, status_code, success, response_code,
                          message):
     response = self.depart_api.delete_depart(app.depart_id, app.Header)
     assert_fn(self, response, status_code, success, response_code, message)
     print(response.json())
 def test01_login_success(self, mobile, password, status_code, success,
                          code, message):
     response = self.login_api.login(mobile, password)
     # 断言
     assert_fn(self, response, status_code, success, code, message)
     print(response.json())
示例#12
0
 def test07_login_lackMobile(self):
     response = requests.post("http://182.92.81.159/api/sys/login",
                              json={"password": "******"})
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#13
0
 def test08_login_lockPwd(self):
     response = requests.post("http://182.92.81.159/api/sys/login",
                              json={"mobile": "13800000002"})
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#14
0
 def test05_login_nullPwd(self):
     response = self.login_api.login("13800000002", "")
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#15
0
 def test06_login_noParams(self):
     response = requests.post("http://182.92.81.159/api/sys/login")
     assert_fn(self, response, 200, False, 99999, "抱歉,系统繁忙,请稍后重试!")
     print(response.json())
示例#16
0
 def test03_login_nullMobile(self):
     response = self.login_api.login("", "123456")
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#17
0
 def test04_login_errorPwd(self):
     response = self.login_api.login("13800000002", "12312")
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#18
0
 def test02_login_errorMobile(self):
     response = self.login_api.login("13900000002", "123456")
     assert_fn(self, response, 200, False, 20001, "用户名或密码错误")
     print(response.json())
示例#19
0
 def test01_login_success(self):
     response = self.login_api.login("13800000002", "123456")
     # 断言
     assert_fn(self, response, 200, True, 10000, "操作成功")
     print(response.json())
 def test04_modify_depart(self, name, status_code, success, response_code,
                          message):
     response = self.depart_api.modify_depart(name, app.depart_id,
                                              app.Header)
     assert_fn(self, response, status_code, success, response_code, message)
     print(response.json())
示例#21
0
 def test05_delete_depart(self):
     response = self.depart_api.delete_depart(app.depart_id, app.Header)
     assert_fn(self, response, 200, True, 10000, "操作成功")
     print(response.json())
示例#22
0
 def test04_modify_depart(self):
     response = self.depart_api.modify_depart("填坑1部", app.depart_id,
                                              app.Header)
     assert_fn(self, response, 200, True, 10000, "操作成功")
     print(response.json())