def ordernew_type0(): """ 指定用户&&托管养车&&待支付&&待存钥匙 """ sql = ''' select id from db_xcb.t_order where uid=27 and service_type=0 and status=0 and pay_status =0 ''' order_id = SQLclient().sql_client(sql) if order_id == None: api = '/api/v1.0/order' xcb_request = XCBRequest('app') headers = {} headers["token"] = check_level.TOKEN_APP body = { "amount": 1, "c_name": "深云智能", "cid": 63, "name": "测试-1", # "parking_type": 0, "phone": "18408251193", "plate_no": "川A1123B", "services": [{ "num": 1, "price_id": 140 }], "shop": "深云智能·银泰城店", "sid": 69, "type": 0 } resp = xcb_request.post(api, data=body, headers=headers) return resp.data['order_id'] else: return order_id[0]
def get_cabinet_token(): xcb_request = XCBRequest('cabinet') body = {'sid': 69, 'sa_no': 'test123'} api = '/api/v1/token' resp = xcb_request.get(api, data=body) return resp.data["token"]
def get_app_token(): xcb_request = XCBRequest('app') headers = { 'token': 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE1OTA0ODQwNTAsImp0aSI6IjI3Iiwic3ViIjoie1wiYWxpX3VpZFwiOlwiXCIsXCJvcGVuaWRcIjpcIm85WG1nNGdRVm9mMmZ0ZzFFZWdacDdNU256RFlcIixcInBob25lXCI6XCIxODQwODI1MTE5M1wifSJ9.FfluM7SrEA-seQ1GPqNIvPSTUd1q1nIf6mvBKrPbEdE', } api = '/api/v1.0/token' resp = xcb_request.put(api, headers=headers) return resp.data["token"]
import allure from utils.xcb_req import XCBRequest from const import check_level api = '/api/v1.0/order/open_cabinet' api_name = '012-选择订单开箱' xcb_request = XCBRequest('app') @allure.feature('订单') @allure.story(api_name) @allure.title('托管待支付订单存钥匙开箱') def test_case_1(ordernew_type0): """ 用例描述:托管待支付订单存钥匙开箱 """ headers={} headers["token"] = check_level.TOKEN_APP body={ "order_id": ordernew_type0, "sid": 69, "sn": "test123", "type": 1 } resp = xcb_request.post(api,headers=headers,data=body)
import allure from utils.xcb_req import XCBRequest api = '/api/v1/cabinet/save_vcode' api_name = '001-存钥匙' xcb_request = XCBRequest('cabinet') def test_case_general_1(get_cabinet_token, ordercomment_type1): """ 用例描述:托管订单 """ headers = {'sid': 69, 'sa_no': 'test123', 'token': get_cabinet_token} body = {"vcode": "string"} resp = xcb_request.post(api, data=body, headers=headers) assert resp.code == 0
def test_add_goods_and_buy(get_app_token, get_cabinet_token): ''' 托管养车流程性用例: 1、下单 2、存钥匙 3、门店接单 4、店员取钥匙 5、店员存钥匙 6、支付 7、取钥匙 8、评价 ''' with allure.step("step1:下单"): api_1 = '/api/v1.0/order' headers = {'token': get_app_token} body = { "amount": 1, "c_name": "深云智能", "cid": 63, "name": "测试-1", # "parking_type": 0, "phone": "18408251193", "plate_no": "川A1123B", "services": [{ "num": 1, "price_id": 140 }], "shop": "深云智能·银泰城店", "sid": 69, "type": 0 } resp_1 = XCBRequest('app').post(api_1, data=body, headers=headers) print("用户下单") with allure.step("step2:存钥匙"): api_2 = '/api/v1/cabinet/save_vcode' headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"vcode": resp_1.data['vcode']} resp_2 = XCBRequest('cabinet').put(api_2, data=body, headers=headers) #调用接口关门 api_2_2 = '/api/v1/cabinet/close' headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"key_no": resp_2.data['key_no']} resp_2_2 = XCBRequest('cabinet').put(api_2_2, data=body, headers=headers) print("用户存钥匙") with allure.step("step3:门店接单"): api_3 = '/api/v1/order/receiving' body = { "brand_id": 0, "clerk": "string", "clerk_id": 0, "order_id": resp_1.data['order_id'], "phone": "18408251193", "vehicle_id": "string", "vehicle_source": 0 } resp3 = XCBRequest('middle').put(api_3, data=body) print("门店接单") with allure.step("step4:店员取钥匙"): sql = ''' select message from db_xcb.t_order_item where order_id=%s and status=20 ''' % resp_1.data['order_id'] message = SQLclient().sql_client(sql) api_4 = '/api/v1/cabinet/fetch_vcode' headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} f_key = (eval(message[0]))['f_key'] body = {'vcode': f_key} resp_4 = XCBRequest('cabinet').put(api_4, data=body, headers=headers) # 调用接口关门 headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"key_no": resp_4.data['key_no']} resp_4_2 = XCBRequest('cabinet').put(api_2_2, data=body, headers=headers) print("店员取钥匙") with allure.step("step5:店员存钥匙"): headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} s_key = (eval(message[0]))['s_key'] body = {"vcode": s_key} resp_5 = XCBRequest('cabinet').put(api_2, data=body, headers=headers) # 调用接口关门 headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"key_no": resp_5.data['key_no']} resp_5_2 = XCBRequest('cabinet').put(api_2_2, data=body, headers=headers) with allure.step("step6:支付"): """ 修改mysql和ES """ sql = "update db_xcb.t_order id set pay_status=1 where id=%s" % resp_1.data[ 'order_id'] sql_result = SQLclient().sql_client(sql) index = 'xcb-order.test.order' body = { "script": { "source": "ctx._source['pay_status']=1" }, "query": { "bool": { "must": [{ "match": { "id": { "query": resp_1.data['order_id'] } } }] } } } es_result = ESclient().update(index=index, body=body) with allure.step("step7:用户取回钥匙"): sql = "select message from db_xcb.t_order_item where order_id=%s and status=40" % resp_1.data[ 'order_id'] message_7 = SQLclient().sql_client(sql) headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"vcode": (eval(message_7[0]))['key']} resp_7 = XCBRequest('cabinet').put(api_4, data=body, headers=headers) # 调用接口关门 headers = {'sid': '69', 'sa_no': 'test123', 'token': get_cabinet_token} body = {"key_no": (eval(message_7[0]))['key_no']} print(body) resp_7_2 = XCBRequest('cabinet').put(api_2_2, data=body, headers=headers) with allure.step("断言"): sql = "select status from db_xcb.t_order where id=%s " % resp_1.data[ 'order_id'] message_s = SQLclient().sql_client(sql) print(message_s[0]) assert message_s[0] == 50