class TestLogin(unittest.TestCase): def setUp(self): self.t = DoExcel(DATA_PATH, "login") self.logger = MyLog("root") @data(*test_date) def test_login(self, item): self.logger.info("******************************") self.logger.info("正在执行的用例是 {}".format(item["title"])) self.logger.info("请求的数据是:{0}".format(item["data"])) res = HttpRequest().http_request(item["url"], eval(item["data"]), item["method"], item["type"]) try: self.assertEqual(item["ExpectResult"], res.json()["message"]) TestResult = "PASS" # 如果不报错,测试通过 except AssertionError as e: print("接口错误,错误是{}".format(e)) TestResult = "Fail" # 如果报错了,测试不通过 finally: # 不管测试结果是否正确,都把结果写入文件 self.logger.info("*********开始写入结果********") self.t.write_back(item["case_id"] + 1, 8, str(res.json()["message"])) # 写入实际结果 self.t.write_back(item["case_id"] + 1, 9, TestResult) # 写入测试结果 self.logger.info("*********结束写入数据********") # print(res.text) def tearDown(self): pass
def addDriver(self, user_id, a, b, c, d, m, e="", f="", g="", h="", i="", j=""): # 司机新增 url = url_service + "saas/res/driver/add" headers = {"user_id": str(user_id)} param = { "a": a, "b": b, "d": d, "e": e, "c": c, "f": f, "g": g, "h": h, "i": i, "j": j, "m": m } r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def guacarEdit(self, user_id, a, u, b, c, d, e, g, h, i, j, k, l, n, o, p, q): # 挂车信息修改 url = url_service + "saas/res/car/edit" headers = {"user_id": str(user_id)} param = { "a": a, "b": b, "d": d, "e": e, "c": c, "g": g, "h": h, "i": i, "j": j, "k": k, "l": l, "u": u, "n": n, "o": o, "p": p, "q": q } r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def post(*args, url, param): headers = {'token': args[0], 'user_id': args[1]} param = param r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def get_user_info(*args): url = fleet_url + 'saas/res/org/userInfo' headers = {'token': args[0], 'user_id': args[1]} r = requests.post(url=url, headers=headers) response = eval(r.text) MyLog().logger().info(response) company_id = response['d']['f'] return company_id
def setup_class(self): self.url = config.get_url() self.log = MyLog().logger() self.rand = random_param.Random_param() self.word = ParseWord.ParseWord(config.get_word()) self.web = web.Web() self.db = db_query.DBQuery() # 客服登录 self.service_login_result = self.web.user_login_web( 19900000001, '123456') # 车队登录 self.fleet_login_result = self.web.user_login_web( 19933334444, '123456') self.fleet_id = self.web.get_user_info(*self.fleet_login_result) # 管理员登录 self.admin_user_id = self.web.user_login_web(19999999999, '123456')
def goodsStatus(self, user_id): # 货单状态查询 url = url_service + "saas/cfg/dictionary/goods-status" headers = {"user_id": str(user_id)} r = requests.get(url=url, headers=headers) response = eval(r.text) MyLog().logger().info(response) return response
def goodsCanceledCarOrderList(self, user_id, b, x, y): # 小五货单已确认车单列表 url = url_service + "saas/transport/dispatch/list/canceled/carOrders" headers = {"user_id": str(user_id)} param = {"b": b, "x": x, "y": y} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def editOrgPeople(self, user_id, a, c, d, f): # 修改部门人员 url = url_service + "saas/res/org/people/edit" headers = {"user_id": str(user_id)} param = {"a": a, "c": c, "d": d, "f": f} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryGoodsOrderDetail(self, user_id, a): # 查询主货单详情 url = url_service + "saas/goods/goods/mainDetail" headers = {"user_id": str(user_id)} param = {"a": a} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def fleetGoodsReportPrice(self, user_id, a): # 车队货源报价列表 url = url_service + "saas/transport/report/list" headers = {"user_id": str(user_id)} param = {"a": a} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def delTransport(self, user_id, a): # 删除运力绑定关系 url = url_service + "saas/res/transport/del" headers = {"user_id": str(user_id)} param = {"a": a} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def addOrgPeople(self, cpy_id, a, c, d, e, f, h): # 新增部门人员 url = url_service + "saas/res/org/people/add" headers = {"cpy_id": str(cpy_id)} param = {"a": a, "c": c, "d": d, "e": e, "g": 2020, "f": f, "h": h} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryUserBasicInfo(self, user_id): # 查询用户基本信息 url = url_service + "saas/res/org/userInfo" headers = {"user_id": str(user_id)} param = {} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryCarList(self, user_id, a, d, x, y): # 查询车辆列表 url = url_service + "saas/res/car/list" headers = {"user_id": str(user_id)} param = {"a": a, "d": d, "x": x, "y": y} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def companyFind(self, user_id): # 货主公司查询 url = url_service + "saas/acc/company/find" headers = {"user_id": str(user_id)} param = {} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def x5List(self, user_id): # 查询小五列表 url = url_service + "saas/res/x5/list" headers = {"user_id": str(user_id)} param = {} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def addressDelete(self, user_id, a): # 常用装卸货地址删除 url = url_service + "saas/goods/address/delete" headers = {"user_id": str(user_id)} param = {"a": a} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryTransport(self, user_id, a, x): # 查询运力绑定关系 url = url_service + "saas/res/transport/list" headers = {"user_id": str(user_id)} param = {"a": a, "x": x} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryUserMenu(self, user_id): # 查询用户菜单 url = url_service + "saas/res/org/people/menu" headers = {"user_id": str(user_id)} param = {} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def inquiryReportPrice(self, user_id, a, b, c, d): # 询价查看-查看报价列表 url = url_service + "saas/inquiry/dispatch/inquiryReportPrice" headers = {"user_id": str(user_id)} param = {"a": a, "b": b, "c": c, "d": d} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def user_login_web(username, password): password_md5 = config.get_md5(password) url = fleet_url + 'paas/mm/userlogin?md=10&cmd=01' param = {"a": username, "b": password_md5} r = requests.post(url=url, json=param) response = eval(r.text) MyLog().logger().info(response) token, user_id = response['k'], response['b'] return token, str(user_id)
def queryConfirmedPrice(self, user_id, b): # 查询被确认的报价价格 url = url_service + "saas/inquiry/confirm/confirmedPrice" headers = {"user_id": str(user_id)} param = {"b": b} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def modifyEscort(self, user_id, a, b, d, k, l, m): # 押运员修改 url = url_service + "saas/res/escort/edit" headers = {"user_id": str(user_id)} param = {"a": a, "b": b, "d": d, "k": k, "l": l, "m": m} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryCarDetail(self, user_id, a, b, c): # 查询车辆详情 url = url_service + "saas/res/car/detail" headers = {"user_id": str(user_id)} param = {"a": a, "b": b, "c": c} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def editTransport(self, user_id, a, b, d, e, c, f, g): # 修改运力绑定关系 url = url_service + "saas/res/transport/edit" headers = {"user_id": str(user_id)} param = {"a": a, "b": b, "c": c, "d": d, "e": e, "f": f, "g": g} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def msDsFind(self, user_id): # 常用货品查询 url = url_service + "saas/goods/msds/find" headers = {"user_id": str(user_id)} param = {} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def addyaDriver(self, user_id, a, b, d, k="", l="", m=""): # 押运员新增 url = url_service + "saas/res/driver/add" headers = {"user_id": str(user_id)} param = {"a": a, "b": b, "d": d, "k": k, "l": l, "m": m} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def queryCompanyOrgAllListByCompanyId(self, user_id, a): # 查询车队的组织架构信息 url = url_service + "saas/res/company/org/all/list" headers = {"user_id": str(user_id)} param = {"a": a} r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response
def get_address(self, user_id, param): # 请求常用装卸货地址 url = self.url + 'saas/goods/address/find' headers = {'user_id': str(user_id)} param = param r = requests.post(url=url, headers=headers, json=param) response = eval(r.text) MyLog().logger().info(response) return response