Esempio n. 1
0
def Conftest():
    uri = "/api/user/login"
    allure.attach(SX_API_URl + uri, '地址', allure.attachment_type.TEXT)
    data = {"account": User_account, "password": User_password}
    headers = {'content-type': 'application/json'}
    allure.attach(json.dumps(data, ensure_ascii=False, indent=4), '请求',
                  allure.attachment_type.TEXT)
    allure.attach(json.dumps(headers, ensure_ascii=False, indent=4), '请求头',
                  allure.attachment_type.TEXT)
    comm = Common()
    response = comm.post(uri, params=data, headers=headers)
    allure.attach(json.dumps(response.json(), ensure_ascii=False, indent=4),
                  '响应', allure.attachment_type.TEXT)
    print("__________________________")
    print(response.text)
    code = int(response.status_code)
    print(code)
    code1 = json.loads(response.text)['code']
    if code == 200 and code1 == 0:
        msg = response.json().get('msg')
        # with open('./Config/config_token', 'w', encoding='utf-8') as f:
        #     f.write(msg)
        login_headers["token"] = msg
        print("Conftest——成功")
    else:
        print("Conftest——失败")
 def test_update_mer_addorupdate(self, Conftest, merchantName_name):
     uri = "/api/merchant/addOrUpdate"
     data1 = {
         "merchantName":
         merchantName_name,
         "address":
         "刘程旭",
         "amountReceived":
         "string",
         "brandName":
         "string",
         "commissionRatio":
         "string",
         "contact":
         "test2",
         "contactAmount":
         "string",
         "contactDeadline":
         "string",
         "contactLink":
         "string",
         "contactPhone":
         "13671618736",
         "contactUuid":
         "string",
         "cooperationStatus":
         0,
         "cityAddress": [{
             "areaCode": "310000",
             "areaName": "上海市",
             "level": 1
         }, {
             "areaCode": "310100",
             "areaName": "上海市",
             "level": 2
         }, {
             "areaCode": "310110",
             "areaName": "虹口区",
             "level": 3
         }],
         "isElmOnline":
         0,  # 饿了么是否上线(0.未上线 1.已上线)
         "elmMonthlySales":
         "",  # 饿了么月销量
         "isMtOnline":
         0,  # 美团是否上线(0.未上线 1.已上线)
         "mtMonthlySales":
         "",
         "intentionality":
         2  # 意向度 0不满意 1一般 2满意 3非常满意
     }
     headers1 = login_headers
     common = Common()
     status = common.post(uri, data1, headers1)
     allure.attach(json.dumps(status.json(), ensure_ascii=False, indent=4),
                   '新增商户接口新增的名字{},返回的数据'.format(merchantName_name),
                   allure.attachment_type.TEXT)
     if status:
         return merchantName_name
     else:
         return None
Esempio n. 3
0
    def test_addorupdate(self, Conftest, test1, test2):
        """
        /api/merchant/addOrUpdate 接口的公共配置
        """
        # with open('./Config/config_token', 'r', encoding='utf-8') as f:
        #     token = f.read()

        uri1 = "/api/merchant/addOrUpdate"
        allure.attach(SX_API_URl + uri1, '地址', allure.attachment_type.TEXT)
        data1 = {
            "merchantName":
            test1,
            "address":
            "刘程旭",
            "amountReceived":
            "string",
            "brandName":
            "string",
            "commissionRatio":
            "string",
            "contact":
            test2,
            "contactAmount":
            "string",
            "contactDeadline":
            "string",
            "contactLink":
            "string",
            "contactPhone":
            "13671618736",
            "contactUuid":
            "string",
            "cooperationStatus":
            0,
            "cityAddress": [{
                "areaCode": "310000",
                "areaName": "上海市",
                "level": 1
            }, {
                "areaCode": "310100",
                "areaName": "上海市",
                "level": 2
            }, {
                "areaCode": "310110",
                "areaName": "虹口区",
                "level": 3
            }],
            "isElmOnline":
            0,  # 饿了么是否上线(0.未上线 1.已上线)
            "elmMonthlySales":
            "",  # 饿了么月销量
            "isMtOnline":
            0,  # 美团是否上线(0.未上线 1.已上线)
            "mtMonthlySales":
            "",
            "intentionality":
            2  # 意向度 0不满意 1一般 2满意 3非常满意
        }
        # headers1 = {
        #     'content-type': 'application/json',
        #     'token': token
        # }
        headers1 = login_headers
        allure.attach(json.dumps(data1, ensure_ascii=False, indent=4), '请求',
                      allure.attachment_type.TEXT)
        allure.attach(json.dumps(headers1, ensure_ascii=False, indent=4),
                      '请求头', allure.attachment_type.TEXT)
        comm1 = Common()
        response1 = comm1.post(uri1, params=data1, headers=headers1)
        allure.attach(
            json.dumps(response1.json(), ensure_ascii=False, indent=4), '响应',
            allure.attachment_type.TEXT)
        print(response1.text)
        code = int(response1.status_code)
        code1 = json.loads(response1.text)['code']
        msg = json.loads(response1.text)['msg']
        print(code)
        if code == 200 and code1 == 0:
            print("------------------------")
            print("/api/merchant/addOrUpdate_________接口调用成功")
        elif code == 200 and code1 == 500 and msg == "联系人参数缺失":
            print("------------------------")
            print("/api/merchant/addOrUpdate_________接口调用500_联系人参数缺失")
        elif code == 200 and code1 == 500 and msg == "该商户名称已存在":
            print("------------------------")
            print("/api/merchant/addOrUpdate_________接口调用500_该商户名称已存在")
        else:
            print("------------------------")
            print("/api/merchant/addOrUpdate_________接口调用失败建议查看")