7.9 【作业】完成交易市场查询用例,从发布商品到交易市场查询
【作业】我们在7.7中提过,平时的工作中,用例最好减少互相的依赖。大家来完成一下7.7中所说的交易市场查询用例,需要先发布商品,再去交易市场中查询到对应的商品,并做断言。
【作业】我们在7.7中提过,平时的工作中,用例最好减少互相的依赖。大家来完成一下7.7中所说的交易市场查询用例,需要先发布商品,再去交易市场中查询到对应的商品,并做断言。
import allure
from common.common_request import Requests
class TestApi:
def test_search_product(self, token):
with allure.step("登录"):
headers = {"token": token("dada")}
with allure.step("新增二手商品"):
dada = {
"product_title": "test2",
"product_stock": 1,
"product_price": "100",
"product_status": 1,
"product_desc": "111",
"product_img": [
"http://122.51.42.138:9090/product/product_img/1733399773115bc0a02e9-a472-41f1-8643-f33187b30d79"
]
}
res = Requests(headers=headers).post("/api/product/publish_product", json=dada)
print(res.text)
with allure.step("新增二手商品-断言"):
assert res.json()["code"]==200
assert res.json()["msg"]=="成功"
with allure.step("查询新增的二手商品"):
data1 = {
"product_title":"test2"
}
res=Requests(headers=headers).post("/api/product/search_product",json=data1)
print(res.text)
with allure.step("查询新增的二手商品-断言"):
assert res.json()["code"]==200
assert res.json()["msg"]=="成功"
登录后即可查看更多作业,立即登录
数据加载中...