Esempio n. 1
0
def env_projects_create():
    '''生成一项目,将项目信息写入conf.ini文件'''
    try:
        # -------------------登录普通账户获取token----------------------------------------------
        params = config.get("PRESET", "unadmin_params")
        respone = com_request(env_projects_create, "login", params=params)
        token = "JWT" + " " + respone.json()["token"]
        # -------------------创建项目----------------------------------------------
        params = {
            "name": "*name new 5 en*",
            "leader": "孙忘",
            "tester": "孙忘",
            "programmer": "孙忘",
            "publish_app": "自动化分析工具",
            "desc": "时序自动化"
        }
        respone = com_request(env_projects_create,
                              "projects",
                              params=params,
                              token=token)
        if respone.status_code == 201:
            config_write("PRESET", "projects", str(respone.json()))
        else:
            raise ValueError
    except Exception as e:
        raise ValueError
Esempio n. 2
0
def env_params_regist():
    '''生成一组非管理员/管理员账号,将账号信息写入conf.ini文件'''
    try:
        user_list = ["unadmin_params", "admin_params"]
        for user in user_list:
            params = {
                "username": username_get("username new 6".split(" ")),
                "email": email_get("email new".split(" ")),
                "password": "******",
                "password_confirm": "334498sun"
            }
            respone = com_request(env_params_regist, "register", params=params)
            if respone.status_code == 201:
                config_write("PRESET", user, str(params))
            else:
                raise ValueError
    except Exception as e:
        raise ValueError
def env_params_regist():
    '''生成一组借款人/投资人/管理员账号,将账号信息写入conf.ini文件'''
    try:
        type_dic = {"loan_params": 1, "admin_params": 0, "invest_params": 1}
        for type_key, type_value in type_dic.items():
            params = {
                "mobile_phone": int(phone_create("new")),
                "pwd": "334498sun",
                "type": type_value
            }
            respone = com_request(env_params_regist, "register", params=params)
            if respone["msg"] == "OK":
                params.pop("type")
                config_write("PRESET", type_key, str(params))
            else:
                raise ValueError
    except Exception as e:
        log.error("测试环境数据初始化失败", exc_info=True)
        raise ValueError("测试环境数据初始化失败")
def env_params_add_audit():
    '''预置投资项目100000000'''
    # ---------------------借款账户登录--------------------------------
    params = config.get("PRESET", "invest_params")
    respone = com_request(env_params_regist, "login", params=params)
    token = "Bearer" + " " + jsonpath(respone, "$..token")[0]
    # ---------------------普通账户添加项目--------------------------------
    params = {
        "member_id": jsonpath(respone, "$..id")[0],
        "title": "预置投资项目100000000",
        "amount": 100000000,
        "loan_rate": 1,
        "loan_term": 1,
        "loan_date_type": 1,
        "bidding_days": 1
    }
    respone = com_request(env_params_add_audit,
                          "add",
                          params=params,
                          token=token)
    loan_id = jsonpath(respone, "$..id")[0]

    # ---------------------管理账户登录--------------------------------
    params = config.get("PRESET", "admin_params")
    respone = com_request(env_params_add_audit, "login", params=params)
    token = "Bearer" + " " + jsonpath(respone, "$..token")[0]
    # ---------------------管理账户审核--------------------------------
    params = {"loan_id": loan_id, "approved_or_not": True}
    respone = com_request(env_params_add_audit,
                          "audit",
                          params=params,
                          token=token)
    assert respone["code"] == 0
    config_write("SETUPDATA", "audit_loan", {
        "loan_id": loan_id,
        "amount": 100000000
    })
Esempio n. 5
0
def env_testcases_create():
    '''生成一接口,将接口信息写入conf.ini文件'''
    try:
        # -------------------登录普通账户获取token----------------------------------------------
        params = config.get("PRESET", "unadmin_params")
        respone = com_request(env_projects_create, "login", params=params)
        token = "JWT" + " " + respone.json()["token"]
        # -------------------创建接口----------------------------------------------
        params = {
            "name": "*tcname new 200 ec*",
            "tester": "孙忘",
            "project_id": "*projects id exist*",
            "desc": "时序自动化"
        }
        respone = com_request(env_testcases_create,
                              "interfaces",
                              params=params,
                              token=token)
        if respone.status_code == 201:
            config_write("PRESET", "interfaces", str(respone.json()))
        else:
            raise ValueError
    except Exception as e:
        raise ValueError