Exemple #1
0
 def test001(self):
     logging.info("用例开始执行")
     # 调用api层登陆方法
     tt = self.login.login("13800000002", "123456")
     logging.info("打开格式")
     # 把相应数据以json格式显示出来
     data = tt.json()
     # 把相应结果data用户令牌取出存入变量
     token = data.get('data')
     # 重点:把data数据存入 api.Headers 请求头中 以下这种存入方式是在 api.Headers 字典变量中追加数据
     # 重点注意:Bearer 后面要加一个空格
     api.Headers["Authorization"] = "Bearer " + token
     # 导入断言
     asserts(self, tt, 200)
 def test005(self):
     r = self.emp.get_employee()
     asserts(self, r, 200)
     print("查询员工:", r.json())
 def test004(self):
     r = self.emp.delete_employee()
     print(r.text)
     print("删除员工:", r.json())
     asserts(self, r, 200)
 def test002(self):
     r = self.emp.put_employee("不会吐丝的蜘蛛侠")
     print("修改员工:", r.json())
     asserts(self, r, 200)
 def test001(self, a, b, c):
     f = self.emp.post_employee(a, b, c)
     asserts(self, f, 200)
     api.user_id = f.json().get('data').get('id')
     print("添加员工:", f.text)
     asserts(self, f, 200)