Esempio n. 1
0
def test_4(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "用户模块"  # allure报告中一级分类
    story = '用户冻结'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/user/lock"  # 接口地址
    headers = {'token': '${token}'}
    status_code = 200  # 响应状态码
    expect = "冻结成功"  # 预期结果
    data = {'userName': '******'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 2
0
def test_getSkuByProdCode(pub_data):
    method = "GET"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '根据产品编码查商品'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/getSkuByProdCode"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    params = {'prodCode': '${code}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             params=params)
Esempio n. 3
0
def test_soldOut(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '下架'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/soldOut"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    data = {'productCode': '${code}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 4
0
def test_changePriceByProdCode(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '根据产品编码批量修改商品价格'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/changePriceByProdCode"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = "价格更新成功"  # 预期结果
    data = {'price': '588', 'prodCode': '${productCode}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 5
0
def test_accUnLock(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "账户模块"  # allure报告中一级分类
    story = '解冻账户'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/acc/accUnLock"  # 接口地址
    headers = {}
    status_code = 200  # 响应状态码
    expect = "已被解冻"  # 预期结果
    data = {'accountName': '${username}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 6
0
def test_getBillss(pub_data):
    method = "GET"  #请求方法,全部大写
    feature = "账户模块"  # allure报告中一级分类
    story = '查询余额'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/acc/getBills"  # 接口地址
    headers = {}
    status_code = 200  # 响应状态码
    expect = "查询成功"  # 预期结果
    params = {'accountName': '${userName}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             params=params)
Esempio n. 7
0
def test_changePrice(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "用户模块"  # allure报告中一级分类
    story = '修改价格'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/changePrice"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    data = {'SKU': '${sku}', 'price': '1000'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
def test_the_case_file(pub_data):
    method = "PUT"  # 请求方法,全部大写
    feature = "案件立案"  # allure报告中一级分类
    story = '待立案'  # allure报告中二级分类
    title = "立案"  # allure报告中用例名字
    uri = f"/api/web/events/{d['eventId']}?token={pub_data['token']}&id={d['eventId']}"  # 接口地址
    headers = {'Content-Type': 'application/json;charset=utf-8'}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    json_data = '''{"data":{"eventName":"住宅小区里废弃非机动车辆","address":"详细地址1","eventDescription":"案件描述","eventType":{"level_1":"事件","level_2":"市容环卫","level_3":"废弃车辆"},"community":"","source":1,"images":[],"status":13,"confirm_info":{"description":"案件情况属实,予以立案,请派遣处置!"}}}'''
    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             json_data=json_data)
    assert r.json()["code"] == 200 and r.json()["data"] != None
Esempio n. 9
0
def test_incrementSku(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '增量调整单个商品库存'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/incrementSku"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = "更新成功"  # 预期结果
    data = {'qty': '444444444', 'skuCode': '${productCode}_白色_37'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 10
0
def test_get_file(pub_data,db):
    file_name = "e:\\sku2.xlsx" # 下载文件地址
    method = "GET"  #请求方法,全部大写
    feature = "库存模块"  # allure报告中一级分类
    story = '下载库存信息'  # allure报告中二级分类
    title = "下载库存信息_全字段正常流_1"  # allure报告中用例名字
    uri = "/product/downProdRepertory"  # 接口地址
    # post请求json数据,注意数据格式为字典或者为json串 为空写None
    tempCodeTupel = db.select_execute("SELECT product_code FROM `t_prod_product`")
    print(tempCodeTupel[0])
    hhh = random.choice(tempCodeTupel)[0]
    print(hhh)
    print(hhh[0])
    print(hhh[1])
    params = {"pridCode":random.choice(tempCodeTupel)[0]}
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,url=uri,pub_data=pub_data,params=params,status_code=status_code,expect=expect,feature=feature,story=story,title=title,headers=headers)
    with open(file_name,"wb") as f :
        f.write(r.content)
Esempio n. 11
0
def test_5(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '商品预售'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/toPreSale"  # 接口地址
    headers = {'token': '${token}'}
    status_code = 200  # 响应状态码
    expect = "产品更新成功1条"  # 预期结果
    data = {'productCode': '${productCode}'}

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             data=data)
Esempio n. 12
0
def test_2(pub_data):
    pub_data['productCode'] = '自动生成 字符串 5 数字字母'
    pub_data['productName'] = '自动生成 字符串 5 中文数字字母'
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '创建商品'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/addProd"  # 接口地址
    headers = {'token': '${token}'}
    status_code = 200  # 响应状态码
    expect = "创建产品成功"  # 预期结果
    json_data = '''{
  "brand": "自动生成 字符串 5 中文数字字母",
  "colors": [
    "red"
  ],
  "price": 10000,
  "productCode": "${productCode}",
  "productName": "${productName}",
  "sizes": [
    "13"
  ],
  "type": "包"
}'''

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             json_data=json_data)
Esempio n. 13
0
def test_sold_out(pub_data):
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '成为下架'  # allure报告中二级分类
    title = "商品_全字段正常流_1"  # allure报告中用例名字
    uri = "/product/soldOut"  # 接口地址
    # post请求json数据,注意数据格式为字典或者为json串 为空写None
    data = {"productCode": "futa2"}
    headers = {"token": pub_data["token"]}
    status_code = 200  # 响应状态码
    expect = "2000"  # 预期结果
    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             data=data,
                             status_code=status_code,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             headers=headers)
    print(r.text)
def test_addProd(pub_data):
    pub_data["productCode"] = "自动生成 字符串 5 数字字母"
    method = "POST"  #请求方法,全部大写
    feature = "用户模块"  # allure报告中一级分类
    story = '创建产品'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/addProd"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = ""  # 预期结果
    json_data = '''{
  "brand": "陈",
  "colors": [
    "黑色"
  ],
  "price": 888,
  "productCode": "${productCode}",
  "productName": "超",
  "sizes": [
    "42"
  ],
  "type": "珠宝"
}'''

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             json_data=json_data)
Esempio n. 15
0
def login():
    method = "POST"  # 请求方法,全部大写
    feature = "用户模块"  # allure报告中一级分类
    story = '用户登录'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/login"  # 接口地址
    # post请求json数据,注意数据格式为字典或者为json串 为空写None
    json_data = '''
            {
          "pwd": "HF123456",
          "userName": "******"
        }
            '''
    status_code = 200  # 响应状态码
    expect = "登录成功"  # 预期结果
    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             json_data=json_data,
                             status_code=status_code,
                             expect=expect)
    return r.json()["data"]["token"]
Esempio n. 16
0
def test_addProd(pub_data):
    pub_data["code"] = "自动生成 字符串 3,10 数字"
    method = "POST"  #请求方法,全部大写
    feature = "商品模块"  # allure报告中一级分类
    story = '增加产品'  # allure报告中二级分类
    title = "全字段正常流_1"  # allure报告中用例名字
    uri = "/product/addProd"  # 接口地址
    headers = {"token": "${token}"}
    status_code = 200  # 响应状态码
    expect = "创建产品成功"  # 预期结果
    json_data = '''{
  "brand": "小米",
  "colors": [
    "string"
  ],
  "price": "自动生成 数字 99,8888",
  "productCode": "${code}",
  "productName": "小米",
  "sizes": [
    "32G512G"
  ],
  "type": "手机"
}'''

    # --------------------分界线,下边的不要修改-----------------------------------------
    # method,pub_data和url为必传字段
    r = request_tool.request(method=method,
                             url=uri,
                             pub_data=pub_data,
                             status_code=status_code,
                             headers=headers,
                             expect=expect,
                             feature=feature,
                             story=story,
                             title=title,
                             json_data=json_data)