auto_test_dev/YiMao/ZeroLib/test_CVip007_AddWeightToTheProduct.py

78 lines
3.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# !/usr/bin/python
# -*- coding: utf-8 -*-
# @Author:: Arthur Wu
# @Description:: 游客转会员登录,加购重量放通商品,并结算
# @Date:: 2024/11/21
import unittest,allure,time,pytest
from configs.globalObj import LOGGER
from YiMao.businessFunc.ClientApiLib import YMClientApi
from YiMao.businessFunc.ServiceApiLib import YMServiceApi
from YiMao.data.WuShangSceneTestData import *
DescName = "Vip007-游客转会员登录,加购重量放通商品,并结算"
@allure.story(f'[场景测试] {DescName}验证')
class Test_CVip007(unittest.TestCase):
f'''@Date:: 2024/11/15
@Author:: Arthur Wu
@Desc::
[购物车客户端] {DescName}
1、武商测试环境重量放通商品inputcode为
6924743915848
'''
def setUp(self) -> None:
self.timestamp = int(time.time())
self.ymc = YMClientApi(ShoppingCartMac)
self.yms = YMServiceApi()
self.vip_phone_num = VIPPhoneNumber
self.weight_to_whitelist_goods = WeightToWhitelistGoods
self.market_and_store_info = {
"MarketId": MarketAndStoreDetails["putMarketId"],
"StoreId": MarketAndStoreDetails["putStoreId"][0]
}
def test_CVip007_AddWeightToTheProduct(self):
allure.dynamic.description(f"描述:{DescName}")
allure.step("[前置条件]:先调用管理平台接口,将指定商品添加到重量放通白名单中")
pre_respomse = self.yms.add_weight_to_whitelist(
self.weight_to_whitelist_goods, self.market_and_store_info
)
if pre_respomse['data'] is not None:
LOGGER.info(f"---商品 {self.weight_to_whitelist_goods['GoodsInputcode']} "
f"已添加到重量放通白名单中")
''' 2-再调用客户端接口,执行加购操作 '''
allure.step("[业务步骤]:再调用客户端接口,执行加购操作")
allure.step("步骤1session开始")
self.ymc.session_start()
allure.step("步骤2匿名登录")
Payload01 = {"action": 0, "isAnon": True}
LoginData = self.ymc.login_app_v2(Payload01)
allure.step("步骤3切换会员登录")
Payload02 = {"action": 1, "code": self.vip_phone_num, "isAnon": False}
self.ymc.login_app_v2(Payload02)
allure.step("步骤3获取白名单商品信息")
GoodsInfoData1 = self.ymc.get_goods_info(self.weight_to_whitelist_goods["GoodsInputcode"])
if GoodsInfoData1['msg'] != '加购商品不存在':
allure.step("步骤4加购白名单商品")
self.ymc.add_cart_goods(GoodsInfoData1, 1, LoginData)
allure.step("步骤5获取购物车商品信息")
self.ymc.get_cart_goods_info([GoodsInfoData1])
allure.step("步骤6请求订单结算")
self.ymc.request_order_settlement(LoginData)
else:
LOGGER.info(f"---商品 {self.weight_to_whitelist_goods["GoodsInputcode"]} 不存在")
pytest.fail(f"---商品 {self.weight_to_whitelist_goods["GoodsInputcode"]} 不存在")
allure.step("[后置处理]:删除添加的重量放通白名单商品")
self.yms.delete_weight_whitelist_goods()
else:
LOGGER.info(f"---添加商品 {self.weight_to_whitelist_goods['GoodsInputcode']} "
f"到重量放通白名单失败")
pytest.fail(f"---添加商品 {self.weight_to_whitelist_goods['GoodsInputcode']} "
f"到重量放通白名单失败")
if __name__ == '__main__':
unittest.main(verbosity=2)