Ejemplo n.º 1
0
def goods_list():
    url = "http://211.103.136.242:8064/categories/115/skus/"
    data = {"page": "1", "page_size": "10", "ordering": "create_time"}
    requset = Request()
    r = requset.get(url, json=data)
    print(r)
    return r
Ejemplo n.º 2
0
def login():
    Con = ConfigYaml()
    con_url = Con.get_url_yaml()
    url = con_url + "/authorizations/"

    data = {"username": "******", "password": "******"}

    requset = Request()
    r = requset.post(url, json=data)
    code = r["code"]
    print(code)
    # print(r)
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # print(body,"-------------------")
    # AssertUtil().assert_in_body(body, '"user_id": 1, "username": "******"')

    #初始化数据库对象
    mysql = MySql()

    #调用查询方法
    res_db = mysql.fetchone(
        "select id,username from tb_users where username='******'")
    # print("数据库查询的结果:{}".format(res_db))

    #验证
    user_id = body["user_id"]
    assert user_id == res_db["id"]
    return r
Ejemplo n.º 3
0
def cart():
    url = "http://211.103.136.242:8064/cart/"
    data = {"sku_id": "3", "count": "1", "selected": "true"}
    requset = Request()
    r = requset.post(url, json=data)
    print(r)
    return r
Ejemplo n.º 4
0
def info():
    url = "http://211.103.136.242:8064/user/"
    token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Ijk1MjY3MzYzOEBxcS5jb20iLCJleHAiOjE1ODMyMTg3MzksInVzZXJuYW1lIjoicHl0aG9uIiwidXNlcl9pZCI6MX0.7Mh9eeMIhstMNrQQH6qLmwwL0gM_HY5GcsZkvWRsGas"
    header = {'Authorization': 'JWT ' + token}
    requset = Request()
    r = requset.get(url, headers=header)
    print(r)
    return r
Ejemplo n.º 5
0
def orders():
    url = "http://211.103.136.242:8064/orders/"
    # data = {"address" : "1", "pay_method" : "1"}
    data = {"address": "1", "pay_method": "1"}
    token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJlbWFpbCI6Ijk1MjY3MzYzOEBxcS5jb20iLCJleHAiOjE1ODMyMTg3MzksInVzZXJuYW1lIjoicHl0aG9uIiwidXNlcl9pZCI6MX0.7Mh9eeMIhstMNrQQH6qLmwwL0gM_HY5GcsZkvWRsGas"
    header = {'Authorization': 'JWT ' + token}
    requset = Request()
    r = requset.post(url, json=data, headers=header)
    print(r)
    return r
Ejemplo n.º 6
0
 def  run_api(self,url,method,params=None,header=None,cookie=None):
    reqest = Request()
    params = json_data(params)
    if str(method).lower() == "get":
        res = reqest.get(url, json=params, headers=header, cookies=cookie)
    elif str(method).lower() == "post":
        res = reqest.post(url, json=params, headers=header, cookies=cookie)
    else:
        log.error("I like you")
        # print(res)
    return res
Ejemplo n.º 7
0
def test_01():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetSampleDeviceAndPoint"
    data = {"Inputs": "{CName:\"\",MCode:0,pageCurrent:1,PageSize:10}"}
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(body, "'Page': {'Current': 1, 'Total': 150}")
    print(body)
Ejemplo n.º 8
0
def test_06():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetDevStateBySysAndName"
    data = {"Inputs": ""}
    # headers = {"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"}
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # AssertUtil().assert_in_body(body, "'Page': {'Current': 1, 'Total': 0}, 'SysId': 0, 'SysName': '全系统'")
    print(body)
Ejemplo n.º 9
0
def run_api(url,method,params=None,header=None,cookie=None):
    # 接口请求
    reqest = Request()
    #验证parrams 是否有内容
    params = json_parse(params)

    if str(method).lower() == "get":
        res = reqest.get(url, json=params, headers=header, cookies=cookie)
    elif str(method).lower() == "post":
        res = reqest.post(url, json=params, headers=header, cookies=cookie)
    else:
        log.error("I like you")
        # print(res)
    return res
Ejemplo n.º 10
0
def test_01():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=DeleteReportInfo"
    data = {"Inputs": "{ID:1}"}
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body, "'ErrorCode': 0, 'Success': True, 'ExceptionMsg': '删除成功!'")
    print(body)

    conn = init_db("db_1")
    conn.execute("truncate table TB_IMS_REPORTFORMS")
Ejemplo n.º 11
0
def test_08():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetDeviceBySysAndName"
    # data = {"Inputs":"{DateType:0,List:[{TableNum:18,Num:1,RecordNo:null,DeviceId:1}]}"}
    # data = {"Inputs": "{strMcode:\"M009\",strName:\"\",PageCurrent:1,PageSize:10}"}
    data = {
        "Inputs": "{strMcode:0,strName:\"@@@@\",PageCurrent:1,PageSize:10}"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body, "'Page': {'Current': 1, 'Total': 0}, 'list': []")
    print(body)
Ejemplo n.º 12
0
def test_03():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetSampleDeviceAndPoint"
    data = {
        "Inputs": "{CName:\"1设备11\",MCode:\"M014\",pageCurrent:1,PageSize:10}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(body, "'Page': {'Current': 1, 'Total': 1}")
    print(body)
Ejemplo n.º 13
0
def test_13():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetDevicePDRData"
    data = {"Inputs": "{alarmId:\"e815175d-3051-4d8e-a52e-c97d498bed7e\"}"}
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    Cookie = {"userid": "admin"}
    requests = Request()
    r = requests.post(url, data=data, headers=None, cookies=Cookie)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'Success': False, 'ExceptionMsg': '没有数据', 'ActionName': '获取告警曲线数据'")
    print(body)
Ejemplo n.º 14
0
def test_09():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetHistoryMonitor"
    data = {
        "Inputs":
        "{particle:1,Unit:1,QueryType:\"avg\",StartTime:\"2020-09-09 00:00:00\",EndTime:\"2020-09-09 10:51:59\","
        "DeviceId:1,SampleType:1,NumList:[\"20002000\"]}"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'Items': [{'ItemName': '模拟量点1', 'ItemValue': 10.0, 'Unit': 'V'}]")
    print(body)
Ejemplo n.º 15
0
def test_04():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=ExportDeviceHistoryData"
    data = {
        "Inputs":
        "{Unit:1,StartTime:\"2020-09-08 00:00\",EndTime:\"2020-09-08 11:09\",MinutesNum:10,"
        "DeviceList:[{DeviceId:1,DeviceName:\"1设备1:\",NumList:[{SampleType:18,RecordNo:20002000}]}]}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(body, "'status': 'success'")
    print(body)
Ejemplo n.º 16
0
def test_10():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=ExportSelectedAlarms"
    data = {
        "Inputs":
        "{AlarmIds:['e815175d-3051-4d8e-a52e-c97d498bed7e'],PageSize:10,PageIndex:1,AllAlarm:true,CampusIds:1001}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body, "'Success': False, 'ExceptionMsg': '登录超时,请重新登录'")
    print(body)
Ejemplo n.º 17
0
def test_07():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?prefix=admin&action=GetDeviceLimit"
    # data = {"Inputs":"{DateType:0,List:[{TableNum:18,Num:0,RecordNo:null,DeviceId:1}]}"}
    # data = {"Inputs":"{DateType:0,List:[{TableNum:18,Num:1,RecordNo:null,DeviceId:1}]}"}
    data = {
        "Inputs":
        "{DateType:1,List:[{TableNum:18,Num:null,RecordNo:20002000,DeviceId:1}]}"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body, "'ResLimitList': {'18_20002000': {'UpperLimit': '2', "
        "'LowerLimit': '1', 'DeadZoneValue': '0'}}")
    print(body)
Ejemplo n.º 18
0
def test_03():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/admin/action.ashx?prefix=admin&action=AddMonitorIndexFormula"
    data = {
        "Inputs":
        "{IndexFormulaList:[{OprationType:0,ID:null,SystemId:1,FormulaName:'配电自动化系统联动',AnalyzeType:6,SourceName:'',SourceID:1,IndexType:301,IndexFormula:'YC_20002000=30',FormulaParm:0,IsExeute:1,isPushEAM:null,BounceTime:null,ClassType:null,Ext:'',Description:'',UpdateTime:'2020-12-17 18:47:17'}]}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
        "Accept-Language": "zh-CN,zh;q=0.9"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # AssertUtil().assert_in_body(body, "'IndexName': '告警联动', 'IndexFormula': '(YC_20004000+1)'")
    print(body)
Ejemplo n.º 19
0
def test_01():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/admin/action.ashx?prefix=admin&action=AddMonitorIndexFormula"
    data = {
        "inputs":
        "{IndexFormulaList:[{OprationType:0,ID:null,'SystemId':1,FormulaName:'配电自动化(1)1设备1:越下限',AnalyzeType:5,SourceName:'',SourceID:1,IndexType:'405',IndexFormula:'YC_20002000=10',FormulaParm:0,IsExeute:1,isPushEAM:0,BounceTime:15,ClassType:0,Ext:'{\"StartTime\":\"00:00:00\",\"EndTime\":\"23:59:59\",\"EndDate\":\"same\"}',Description:'测试告警',UpdateTime:'2020-12-31 10:24:51'}]}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
        "Accept-Language": "zh-CN,zh;q=0.9"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # AssertUtil().assert_in_body(body, "'list': [{'DeviceId': 1, 'TableNum': 18, 'SampleId': 20002000}]")
    print(body)
Ejemplo n.º 20
0
def test_14():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetAlarmsByAlarmCount"
    data = {
        "Inputs":
        "{StartTime:\"2020-08-15\",EndTime:\"2020-09-14\",CampusInfo:1001,AlarmClass:0,PageIndex:1,"
        "PageSize:10,AlarmLevel:3,SysId:1}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    Cookie = {"userid": "admin"}
    requests = Request()
    r = requests.post(url, data=data, headers=None, cookies=Cookie)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # AssertUtil().assert_in_body(body, "'Success': True, 'ExceptionMsg': None, 'ActionName': '获取告警统计弹窗数据'")
    print(body)
Ejemplo n.º 21
0
def test_12():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=ExportSelectedAlarms"
    data = {
        "Inputs":
        "{AlarmIds:[\"e815175d-3051-4d8e-a52e-c97d498bed7e\"],PageSize:10,PageIndex:1,"
        "AllAlarm:true,CampusIds:1001}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    Cookie = {"userid": "admin"}
    requests = Request()
    r = requests.post(url, data=data, headers=None, cookies=None)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    # AssertUtil().assert_in_body(body, "'ErrorCode': 0, 'Success': True")
    print(body)
Ejemplo n.º 22
0
def test_11():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetAlarms"
    data = {
        "Inputs":
        "{ObjName:\"模拟量1\",IsAlarmPage:\"alarm\",StartTime:\"2020-09-14 00:00\","
        "EndTime:\"2020-09-14 17:21\",PageSize:10,CampusIds:1001,PageIndex:1,SrcType:0,Flag:-1}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    Cookie = {"userid": "admin"}
    requests = Request()
    r = requests.post(url, data=data, headers=headers, cookies=Cookie)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(body, "'total': 1, 'current': 1, 'Count': 2")
    print(body)
Ejemplo n.º 23
0
def test_02():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetSampleDeviceAndPoint"
    data = {
        "Inputs": "{CName:\"1设备1\",MCode:\"M009\",pageCurrent:1,PageSize:10}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'ActionInfo': {'ErrorCode': 0, 'Success': True, 'ExceptionMsg': '', "
        "'ExtendContent': None}, 'Page': {'Current': 1, 'Total': 2}")
    print(body)
Ejemplo n.º 24
0
def login():
    log.info("登录请求")
    con = Config().yaml_url()
    url = con + "/authorizations/"
    data = {"username": "******", "password": "******"}
    req = Request()
    r = req.post(url, json=data)
    #数据验证
    # mysql = Mysql()
    # my = mysql.execute("select id,username from tb_users where username='******'")
    # body =r["body"]["user_id"]
    # assert  my["id"] ==body
    # print(my)
    print(r)
    #断言验证状态码是否相等
    ass = AssertUtil()
    # ass.assert_code(r["code"],200)
    # ass.assert_body(r["body"],"")
    #验证是否包含
    body = r["body"]
    ass.assert_in_body(body, "'username': '******', 'user_id': 1")
Ejemplo n.º 25
0
def test_05():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetIndexPageConfChart"
    data = {
        "Inputs":
        "{SystemId:1,SystemName:'配电自动化',AnalyzeType:2,AnalyzeTypeName:'设备指标类',IndexType:1,IndexTypeName:'总供冷量(kW)',SourceList:[{devType:'CODE1-13',devTypeName:'智能照明3'}],StartTime:'2021-01-12',EndTime:'2021-01-12',TimeGranule:0,DataType:0,RatioType:0}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'RowUnit': {'RowUnitList': {'对象CODE1-13': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]}}"
    )
    print(body)
Ejemplo n.º 26
0
def test_05():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetDeviceRunInfo"
    data = {
        "Inputs":
        "{Start_StopState:0,DeviceType:1,DevName:\"@@@@\",strMcode:0,On_Offline:0,"
        "RunState:0,pageCurrent:1,PageSize:10,CampusInfo:1001}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    requests = Request()
    r = requests.post(url, data=data, headers=headers)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'Page': {'Current': 1, 'Total': 0}, 'SysId': 0, 'SysName': '全系统'")
    print(body)
Ejemplo n.º 27
0
def test_15():
    conf_y = ConfigYaml()
    url_path = conf_y.get_conf_url()
    url = url_path + "/action.ashx?action=GetAlarmsByAlarmCount"
    data = {
        "Inputs":
        "{StartTime:'2020-08-15',EndTime:'2020-09-14',CampusInfo:1001,AlarmClass:0,PageIndex:1,PageSize:10,AlarmLevel:3,SysId:1}"
    }
    headers = {
        "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8"
    }
    Cookie = {"userid": "admin"}
    requests = Request()
    r = requests.post(url, data=data, headers=None, cookies=Cookie)
    code = r["code"]
    AssertUtil().assert_code(code, 200)
    body = r["body"]
    AssertUtil().assert_in_body(
        body,
        "'DeviceName': '设备2', 'AlarmObjName': '模拟量点1', 'AlarmContent': '模拟量1 置数5成功'"
    )
    print(body)
Ejemplo n.º 28
0
    def test_run(self,case):
        # 3、重构函数内容
        data_key = ExcelConfig.DataConfig
        # run_list第1个用例,用例key获取values
        url = ConfigYaml().get_conf_url() + case[data_key.url]
        print(url)
        case_id = case[data_key.case_id]
        case_model = case[data_key.case_model]
        case_name = case[data_key.case_name]
        pre_exec = case[data_key.pre_exec]
        method = case[data_key.method]
        params_type = case[data_key.params_type]
        params = case[data_key.params]
        expect_result = case[data_key.expect_result]
        headers = case[data_key.headers]
        cookies = case[data_key.cookies]
        status_code = case[data_key.status_code]
        db_verify = case[data_key.db_verify]

        # 2).接口请求
        request = Request()
        # params 转义json
        # 验证params有没有内容
        if len(str(params).strip()) is not 0:
            params = json.loads(params)
        # headers 转义json
        # 验证headers有没有内容
        if len(str(headers).strip()) is not 0:
            headers = json.loads(headers)
        # cookies 转义json
        # 验证cookies有没有内容
        if len(str(cookies).strip()) is not 0:
            cookies = json.loads(cookies)

        # method post/get
        if str(method).lower() == "get":
            res = request.get(url, data=params, headers=headers, cookies=cookies)

        elif str(method).lower() == "post":
            res = request.post(url, data=params, headers=headers, cookies=cookies)

        else:
            res = log.error("错误请求method: %s" % method)
        print(res)

        # allure
        # sheet名称  feature 一级标签
        allure.dynamic.feature(sheet_name)
        # 模块   story 二级标签
        allure.dynamic.story(case_model)
        # 用例ID+接口名称  title
        allure.dynamic.title(case_id + case_name)
        # 请求URL  请求类型 期望结果 实际结果描述
        desc = "<font color='red'>请求URL: </font> {}<Br/>" \
               "<font color='red'>请求类型: </font>{}<Br/>" \
               "<font color='red'>期望结果: </font>{}<Br/>" \
               "<font color='red'>实际结果: </font>{}".format(url, method, expect_result, res)
        allure.dynamic.description(desc)

        # 断言验证
        # 状态码,返回结果内容,数据库相关的结果的验证
        # 状态码
        assert_util = AssertUtil()
        assert_util.assert_code(int(res["code"]), int(status_code))

        # 返回结果内容
        assert_util.assert_in_body(str(res["body"]), str(expect_result))
def test_zxx():
    # url = "http://mp-meiduo-python.itheima.net/login/"
    conf_yaml = ConfigYalm()
    url_path = conf_yaml.get_conf_url()
    url = url_path + "login/"
    print(url)
    # r_get = requests.get(url)
    # 使用封装的方法
    request = Request()
    r_get = request.get(url)
    res = r_get.get("body")
    # 登陆时要传入token 使用正则表达式获取token
    token = re.findall('csrfmiddlewaretoken\" value=\"(.+?)\"', res)
    data = {"csrfmiddlewaretoken": token[0],
            "username": "******",
            "pwd": "admin",
            "remembered": "on"
            }
    # 登陆成功后禁止重定向 allow_redirects=False
    # r = requests.post(url, data=data, allow_redirects=False)
    # allow_redirects = False
    r = request.post(url, data=data, allow_redirects=False)
    # 获取登陆成功之后响应头中的cookie信息中的username和sessionid
    header = r.get("headers").get("Set-Cookie")
    username = re.findall('username=(.+?);', header)
    sessionid = re.findall('sessionid=(.+?);', header)
    cookie = "username="******"; sessionid="+sessionid[0]
    print("----------")
    print("登陆:cookie"+cookie)
    # 个人中心
    # url_info = "http://mp-meiduo-python.itheima.net/info/"
    url_info = url_path + "info/"
    print(url_info)
    headers = {
        "Content-Type": "application/x-www-form-urlencoded",
        "Cookie": cookie
    }
    # r_info = requests.get(url_info, headers=headers)
    r_info = request.get(url_info, headers=headers)
    print("个人中心")
    print(r_info)

    # 添加购物车
    # url_carts = "http://mp-meiduo-python.itheima.net/carts/"
    url_carts = url_path + "carts/"
    headers_carts = {
        "Content-Type": "application/json;charset=UTF-8",
        "Cookie": cookie
    }
    data_carts = {'sku_id': '18', 'count': '1'}
    # request payload形式传参使用json.dumps(data_carts)
    # res_carts = requests.post(url_carts, data=json.dumps(data_carts), headers=headers_carts)
    # print(res_carts.text)
    res_carts = request.post(url_carts, data=json.dumps(data_carts), headers=headers_carts)
    print("添加购物车")
    print(res_carts)
    # 购物车选择商品
    # url_carts_sel = "http://mp-meiduo-python.itheima.net/carts/"
    url_carts_sel = url_path + "carts/"
    data_carts_sel = {'count': '10', 'selected': 'ture', 'sku_id': '18'}
    headers_carts_sel = {
        "Content-Type": "application/json;charset=utf-8",
        "Cookie": cookie
    }
    # res_carts_sel = requests.put(url_carts_sel, json=data_carts_sel, headers=headers_carts_sel)
    # print(res_carts_sel.json())
    res_carts_sel = request.put(url_carts_sel, json=data_carts_sel, headers=headers_carts_sel)
    print("购物车选择商品")
    print(res_carts_sel)
    # 下订单
    # url_orders = "http://mp-meiduo-python.itheima.net/orders/commit/"
    url_orders = url_path + "orders/commit/"
    headers_orders = {
        "Content-Type": "application/json;charset=utf-8",
        "Cookie": cookie
    }
    data_orders = {'address_id': '5', 'pay_method': 2}
    # res_orders =
    # requests.post(url_orders, data=json.dumps(data_orders), headers=headers_orders, allow_redirects=False)
    # print(res_orders.json())
    res_orders = request.post(url_orders, data=json.dumps(data_orders), headers=headers_orders, allow_redirects=False)
    print("下订单")
    print(res_orders)