17.接口测试用例编写002:店铺shop接口测试用例的编写

店铺shop接口测试用例的编写

import ptest
import os
imoport allure
from common.baseAPI import BaseAPI
from libs.login import Login
from utils.handle_path import report_path
from utils.handle_excle import get_excle_data
# 创建测试类---业务模块
'''
店铺模块的测试:初始化操作(前置条件)
  1. 首先完成有效的登录操作----拿到token
  2.完成店铺实例的创建
'''
@allure.epic('XXXX系统') # 工程级别--项目级别
@allure.feature('店铺模块')  # 业务级别
class TestShop:
  
  # 创建测试方法---对应模块具体的接口
@pytest.mark.parametrize('tile,req_body,exp_resp',get_excle_data('店铺模块','queryshopping'))
@allure.story('店铺查询')  # 接口级别
@allure.title('{title}')  # 用例标题
  def test_shop_query(self,shop_init):
    shop_object = shop_init #  创建店铺实例,可以不写
    res = shop_init.query(res_body) # 调用店铺的查询方法
     assert res['code'] == exp_resp['code']
 
# 编辑的接口
@pytest.mark.parametrize('tile,req_body,exp_resp',get_excle_data('店铺模块','updateshopping'))
@allure.story('店铺查编辑')  # 接口级别
@allure.title('{title}')  # 用例标题
def test_shop_update(self,shhop_init):
    with allure.step('1、用户登录'):
      shop_object = shop_init 
    with allure.step('2、选中编辑店铺'):
      shop_id = shop_init.qurey({'page':1,'limit':20})['data']['records'][0]['id']
    with allure.step('3、替换店铺的图片'):
      image_info= shop_init.file_upload('../data/456.png')['data']['realFileName']
    with allure.step('4、提交店铺信息'):
      res= shop_init.update(req_body,shop_id,image_infi)
    with allure.step('5、判断是否操作成功'):
      assert res['code'] == exp_resp['code']

# 编辑的接口--方式2
@pytest.mark.parametrize('tile,req_body,exp_resp',get_excle_data('店铺模块','updateshopping'))
@allure.story('店铺查编辑)  # 接口级别
@allure.title('{title}')  # 用例标题
  def test_shop_update(self,shhop_init):
    with allure.step('1、提交店铺信息'):
      res= shop_update_init['shop_object'].update(req_body,shop_update_iinit['shop_id'])
    with allure.step('2、判断是否操作成功'):
      assert res['code'] == exp_resp['code']

if __name__ == '__main__':
  pytest.main([__file__,'-s'])
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容