【作业】完成交易市场查询用例,从发布商品到交易市场查询
809
等27人参与

7.9 【作业】完成交易市场查询用例,从发布商品到交易市场查询

【作业】我们在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"]=="成功"

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
代码块
复制 预览
复制成功!
代码块
复制 预览
复制成功!
0
评论
提交于  2025-02-14 10:27:07

登录后即可查看更多作业,立即

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号