class TestCaseAppDeviceReport(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "uuid": "${parameterize(test_data/normal_device_bind_data.csv)}", "status_code-ok-status-code-ids": [[200, 1, "ok", 200, 0]], }), ) def test_start(self, param): super().test_start(param) config = Config("设备上报日志").base_url("${ENV(api_url)}") teststeps = [ Step( RunRequest("设备上报日志").post("app/device/report").with_headers( **{ "Content-Type": "application/json" }).with_json({ "uuid": "$uuid" }).validate().assert_equal("status_code", "$status_code").assert_equal( "body.ok", "$ok").assert_equal( "body.status", "$status").assert_equal( "body.code", "$code")), ]
class TestCaseItemGetItemList(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", "byClassIds-currentPage-frontCategoryId-mustNot-pageSize-qp_status_eq-qp_storeCode_eq-sorter_complex-sorter_salePrice-sorter_sales": "${parameterize(testcases/api/mall/item/item_getItemList.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("查询商品列表").base_url("${get_base_url()}") # .variables(**{ # "byClassIds": "$byClassIds", # string (query) 查推荐区分参数 # "currentPage": "$currentPage", # integer($int64) (query) 当前页数 # "frontCategoryId": "$frontCategoryId", # integer($int64) (query) 前端类目Id # "mustNot": "$mustNot", # string (query) 需要过滤的商品编码 # "pageSize": "$pageSize", # integer($int64) (query) 每页记录数 # # "qp_classIds_in": "$qp_classIds_in", #string (query) 品类名称 # "qp_status_eq": "$qp_status_eq", # string (query) 上下架。0下架 1上架 # "qp_storeCode_eq": "$qp_storeCode_eq", # string (query) 店铺Code # "sorter_complex": "$sorter_complex", # string (query) 综合排序 # "sorter_salePrice": "$sorter_salePrice", # string (query) 价格排序 # "sorter_sales": "$sorter_sales", # string (query) 销量排序 asc 或者 desc # # "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 # }) .verify(False)) teststeps = [ Step( RunTestCase("登录").call(Login).export(*[ 'sessionId', 'token', 'accountCode', 'personId', "name", "nickname", "username", "phone", "memberCode", "userCode", "account_id", "storeCode", "member_id" ])), Step( RunRequest("查询商品列表").get("/mall/item/getItemList").with_params( **{ "qp-status-eq": "$qp_status_eq", "qp-storeCode-eq": "$qp_storeCode_eq", "frontCategoryId": "$frontCategoryId", "totalCount": "0", "currentPage": "1", "pageSize": "16", "sorter-complex": "$sorter_complex", }).with_headers(**{ "x-tenant-id": "2", "sso_sessionid": "$sessionId", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).validate().assert_equal("status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success")), ]
class TestCaseDeviceAuthActive(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "uuid-actived": "${parameterize(test_data/normal_device_data.csv)}", "status_code-ok-status-code-data": [[200, 1, "ok", 200, "active success"]], }), ) def test_start(self, param): super().test_start(param) config = Config("tange-iiCam365 激活设备").base_url("${ENV(DV_test_url)}") teststeps = [ Step( RunRequest("激活设备").post("device/auth/active").with_headers( **{ "Content-Type": "application/json" }).with_json({ "uuid": "$uuid", "actived": "$actived" }).validate().assert_equal( "status_code", "$status_code").assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.ok", "$ok").assert_equal( "body.status", "$status").assert_equal("body.code", "$code").assert_equal( "body.data", "$data")), ]
class TestCaseAppDeviceNamelist(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "username-pwd-platform-uuid-add_type-pkgname-push_id-push_channel-version-language": "${parameterize(test_data/normal_device_bind_data.csv)}", "status_code-ok-status-code-ids": [[200, 1, "ok", 200, 0]], }), ) def test_start(self, param): super().test_start(param) config = Config("预定义的设备名称").base_url("${ENV(api_url)}") teststeps = [ Step( RunTestCase("获取登录token").call(AppUserLogin).export( *["id", "token"])), Step( RunRequest("预定义的设备名称").post("app/device/namelist").with_headers( **{ "Content-Type": "application/json" }).with_json({ "token": "$token", "language": "$language", "uuid": "$uuid", "device_type": "$add_type", }).validate().assert_equal( "status_code", "$status_code").assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.ok", "$ok").assert_equal( "body.status", "$status").assert_equal("body.code", "$code")), ]
class TestCasesLogin(HttpRunner): @pytest.mark.parametrize("param", Parameters({ "username-password": "******" })) def test_start(self, param): super().test_start(param) config = (Config("login").export(*["token"]).base_url("")) teststeps = [ Step( RunRequest("login").get("${ENV(url)}").with_params( **{ "password": "******", "pid": "${ENV(pid)}", "type": "${ENV(type)}", "version": "${ENV(version)}", "username": "******", "deviceid": "${ENV(deviceid)}", "language": "${ENV(language)}", "lz": "${ENV(lz)}", "hwdeviceid": "${ENV(hwdeviceid)}", "m": "User", "a": "login", }).extract().with_jmespath( "body.user_info.device_info.login_token", "token").validate().assert_equal( "status_code", 200).assert_equal("body.ret", 0).assert_not_equal( "body.user_info.device_info.login_token", "")), ]
class TestCaseToolsSim(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "username-pwd-platform-pkgname-push_id-push_channel-version-language": "${parameterize(test_data/normal_device_bind_data.csv)}", "status_code-ok-status-code-ids": [[200, 1, "ok", 200, 0]], }), ) def test_start(self, param): super().test_start(param) config = Config("物联网卡工具页").base_url("${ENV(api_url)}") teststeps = [ Step( RunTestCase("获取登录token").call(AppUserLogin).export( *["id", "token"])), Step( RunRequest("物联网卡工具页").get( "//tools/sim?user_id=$id&version=$version&platform=$platform&pkgname=$pkgname&language=$language&token=$token" ).with_headers(**{ "Content-Type": "application/json" }).with_json(None).validate().assert_equal("status_code", "$status_code")), ]
class TestCaseAppDeviceBindUser(HttpRunner): @pytest.mark.parametrize( "param", Parameters( { "username-pwd-platform-uuid-bind_token": "${parameterize(test_data/normal_device_data.csv)}", "pkgname-push_id-push_channel-version-language": "${parameterize(test_data/common_app_param.csv)}", "status_code-ok-status-code-ids-ai_uuid": [ [200, 1, "ok", 200, 0, "AI"] ], } ), ) def test_start(self, param): super().test_start(param) config = Config("设备发起绑定").base_url("${ENV(api_url)}") teststeps = [ Step(RunTestCase("获取登录token").call(AppUserLogin).export(*["id", "token"])), Step( RunRequest("设备发起绑定") .post("http://device-cn01.tange365.com/app/device/bind/user") .with_headers(**{"Content-Type": "application/json"}) .with_json({"uuid": "$uuid", "user_id": "$id", "bind_token": "$bind_token"}) .validate() .assert_equal("status_code", "$status_code") .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8") .assert_equal("body.ok", "$ok") .assert_equal("body.status", "$status") .assert_equal("body.code", "$code") .assert_startswith("body.data.ai_uuid", "$ai_uuid") ), ]
class Test_hrun_stu(HttpRunner): @pytest.mark.parametrize("param", Parameters({ "httprunner_version": "$get_httprunner_version()" })) def test_start(self, param): super().test_start(param) config = Config('用来练习的case').base_url('http://127.0.0.1:5000/') # @pytest.mark.parametrize("param", Parameters({"username": [111, 222, 333]})) teststeps = [ Step( RunRequest('测试getUserName接口').get( '/getUserName').extract().with_jmespath( 'body.username', 'var_username') # 新写一份接口case # RunTestCase # 引入一份接口case ), Step( RunRequest('测试joinStr接口').get('/joinStr').with_params( **{ 'str1': 'hello', 'str2': '$httprunner_version' }) # .validate() # .assert_equal('body.result', 'hello $var_username') ), Step(RunRequest('测试string_data接口').get('/string_data').extract()) ]
class TestCaseSubmitd(HttpRunner): """使用如下功能需要修改testcase中标记为2020.08.17新增""" @pytest.mark.parametrize("param", Parameters({ "phone-password-code-msg": [ ["13544871706", '100100', 0, None], ["1", "100100", 5, "数据验证失败,请重新提交"], ], })) def test_start(self, param): super().test_start(param) _config = Config("submit") _conf = _config.conf() _headers_get = _config.headers_get() _headers_post = _config.headers_post() _cookies = _config.cookies() config = _config.verify(False).variables(**_conf).variables(**{ "phone": "1", "password": "******", "code": 1, "msg": "1" }) teststeps = [ RunTestCase('submit').call(submit), ]
class TestCaseDeviceRecordTime(HttpRunner): @pytest.mark.parametrize( "param", Parameters( {"status_code-ok-status-code-data": [[200, 1, "ok", 200, 0]]}), ) def test_start(self, param): super().test_start(param) config = Config("获取当前服务器时间").base_url("${ENV(DV_test_url)}") teststeps = [ Step( RunRequest("获取当前服务器时间").post("device/record/time").with_headers( **{ "Content-Type": "application/json" }).with_json(None).validate().assert_equal( "status_code", "$status_code").assert_equal( "body.ok", "$ok").assert_equal("body.status", "$status").assert_equal( "body.code", "$code").assert_greater_than( "body.data", "$data")), ]
class TestCaseWebPCLogin(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "phoneNumber-verifyCode": "${parameterize(testcases/api/mall/web_pcLogin.csv)}" })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("登录").base_url("${get_base_url()}").variables(**{ "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 }).verify(False).export(*["sessionId", "token"])) teststeps = [ Step( RunRequest("登录").get("/mall/web/pcLogin").with_params( **{ "phoneNumber": "$phoneNumber", "verifyCode": "$verifyCode" }).with_headers(**{ "sso_sessionid": "undefined", "x-tenant-id": "$x_tenant_id", }).extract().with_jmespath( 'body.data.sessionId', 'sessionId').with_jmespath( 'body.data.token', 'token').validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal( "body.msg", "Success")), ]
class TestCaseCreateCancelObligationOrder(HttpRunner): @pytest.mark.parametrize("param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", "good_name": "${get_good_name()}" })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = (Config("登录操作 ").base_url("${get_base_url()}").verify(False)) teststeps = [ Step( RunTestCase("检索商品下单").with_variables(**{ "good_name": "$good_name" }).call(BuyGood).export(*['sessionId', 'token', 'orderNo'])), Step( RunRequest("取消待付款订单").put("/mall/order/cancelOrder").with_params( **{ "cause": "", "orderNo": "$orderNo" }).with_headers(**{ "x-tenant-id": "2", "sso_sessionid": "$sessionId" }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).teardown_hook("${teardown_hook_sleep_N_secs($response, 7)}") .validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success")) ]
class Test_hrun_home(HttpRunner): @pytest.mark.parametrize( "param", Parameters({"username-password": "******"})) def test_start(self, param): super().test_start(param) config = Config('HttpRunner的接口case测试').base_url( 'http://127.0.0.1:6666/api/v1/admin') teststeps = [ Step( RunRequest('注册接口测试').post('/register').with_headers( **{ "Content-Type": "application/json" }).with_json({ 'userName': '******', 'passWord': '******' }).validate().assert_equal("status_code", 200).assert_equal( 'headers."Content-Type"', "application/json") # .with_jmespath('body.username', 'var_username')# 新写一份接口case # # RunTestCase # 引入一份接口case ), Step( RunRequest('登录接口测试').post('/login').with_headers( **{ "Content-Type": "application/json" }).with_json({ 'userName': '******', 'passWord': '******' }).validate().assert_equal("status_code", 200).assert_equal( 'headers."Content-Type"', "application/json")), Step(RunRequest('获取时间接口测试').get('/time').extract()) ]
class TestCaseUserLogin(HttpRunner): @pytest.mark.parametrize("param", Parameters( { "title": ["demo1"], "user": ["user1", "user2"], "title-user": [("demo4", "4"), ("demo5", "5"), ("dmeo6", "6")], } ), ) config = ( Config("OBE目标达成度分析-新建OBE设置信息") .variables(loginNameadmin="${ENV(LoginNameCourseAdmin)}",loginNametea="${ENV(LoginNametea)}",password="******",HOST="${ENV(TestHOST)}") .base_url("https://${HOST}") .verify(False) .export(*[]) ) teststeps = [ Step( RunRequest("用户登录成功!") .post("/users/login") .with_headers(**{"Content-Type": "application/json"}) .with_json({"loginName": "${loginNameadmin}","password": "******"}) .extract() .with_jmespath("body.authorization", "authorization") .validate() .assert_equal("status_code", 200) ) ]
class TestCaseGloud(HttpRunner): @pytest.mark.parametrize( "param", Parameters({"username": "******"})) def test_start(self, param): super().test_start(param) config = Config("game_info") teststeps = [ Step( RunRequest("game_info").with_variables( **{ "token": "${return_token($username)}" }).get("${ENV(url)}").with_params( **{ "deviceid": "${ENV(deviceid)}", "ver": "${ENV(ver)}", "pid": "${ENV(pid)}", "logintoken": "$token", "account_id": "$username", "mode": "${ENV(mode)}", "language": "${ENV(language)}", "lz": "${ENV(lz)}", "hwdeviceid": "${ENV(hwdeviceid)}", "TimeZoneName": "${ENV(TimeZoneName)}", "TimeZoneId": "${ENV(TimeZoneId)}", "version": "${ENV(version)}", "m": "GameList", "a": "game_info", "gameid": "10841", }).validate().assert_equal("status_code", 200).assert_equal( "body.ret", 0)), ]
class TestCaseVideoLookAVideo(HttpRunner): #更改为与接口相关的名字,方便以后引用(例如引用login接口需要先导入类名) @pytest.mark.parametrize( "param", Parameters( { "username-password": "******" #取excel表格中的数据做数据驱动 } ) ) def test_start(self, param): super().test_start(param) config = ( Config("look_a_video") .variables( **{ "username": "******", #在此文件中引用其他测试用例,需要定义本次用例中引用的参数 "password": "******" } ) ) teststeps = [ Step( RunTestCase("login function") .call(TestCasesLogin) #调用login接口 .export(*["token"]) ), Step( RunRequest("look_a_video") .with_variables( **{ } ) .get("${ENV(url)}") .with_params( **{ "deviceid": "${ENV(deviceid)}", "ver": "${ENV(ver)}", "pid": "${ENV(pid)}", "logintoken": "$token", "account_id": "$username", "mode": "${ENV(mode)}", "language": "${ENV(language)}", "lz": "${ENV(lz)}", "hwdeviceid": "${ENV(hwdeviceid)}", "TimeZoneName": "${ENV(TimeZoneName)}", "TimeZoneId": "${ENV(TimeZoneId)}", "version": "${ENV(version)}", "brand": "${ENV(brand)}", "video_id": "${ENV(video_id)}", "Sint": "29", "m": "video", "a": "look_a_video" } ) .validate() .assert_equal("status_code", 200) .assert_equal("${judgment_ret($response)}",0) ) ]
class TestCaseGetCandlestick(HttpRunner): @pytest.mark.parametrize("param", Parameters({"desc-params": "${read_yaml()}"})) def test_start(self, param): super().test_start(param) config = (Config("$desc").verify(False).base_url("${ENV(UAT_BASE_URL)")) teststeps = [ Step( RunRequest("/v2/public/get-candlestick").get( "v2/public/get-candlestick").with_params(**"$params"). with_headers( **{ "cache-control": "max-age=0", "sec-ch-ua": '"Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"', "sec-ch-ua-mobile": "?0", "upgrade-insecure-requests": "1", "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36", "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "sec-fetch-site": "none", "sec-fetch-mode": "navigate", "sec-fetch-user": "******", "sec-fetch-dest": "document", "accept-encoding": "gzip, deflate, br", "accept-language": "zh-CN,zh;q=0.9", }).with_cookies(**{ "__cfduid": "dcb695eb677c5a40e841705ef79415c651617014441" }).validate().assert_equal("status_code", 200)), ]
class TestCaseCategoryQueryCategoryTree(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", "status": "${parameterize(testcases/api/mall/category/category_queryCategoryTree.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("根据模板id查询类目录树").base_url("${get_base_url()}").variables(**{ "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 }).verify(False)) teststeps = [ Step(RunTestCase("登录").call(Login).export(*['sessionId', 'token'])), Step( RunRequest("根据模板id查询类目录树").get("/mall/category/queryCategoryTree"). with_params(**{ "status": "$status", }).with_headers(**{ "x-tenant-id": "2", "sso_sessionid": "$sessionId", }).validate().assert_equal("status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success")), ]
class TestCaseMubuCreatDoc(HttpRunner): @pytest.mark.parametrize("param", Parameters({"mapname": "${get_chengdu20_mapname()}"})) def test_start(self, param): super().test_start(param) config = ( Config("login mubu") .variables(phone="${ENV(username)}", password="******", host="${ENV(host)}") .verify(False) .base_url("https://${host}") .export(*["unreadCount"]) ) teststeps = [ Step( RunTestCase("这里调用登录的用例,传递出三个会话的变量。") .call(MubuLogin) .export(*["tgc_login", "genex_session", "jessionid_fusiongissaccess"]) ), Step( RunRequest("这里是上传文件的接口") .post("https://{host}:8888/xxx/upload.do") .with_headers("xxx") .with_cookies("xxx") .upload(file = "//ip//目录//目录//$mapname.zip", mapname = "", usage = "xx", description = "") .validate() .assert_equal("status_code", 200) )]
class TestCaseshttprunner(HttpRunner): @pytest.mark.parametrize("param", Parameters({ "username-password": "******" })) def test_start(self, param): super().test_start(param) config = (Config("login").base_url("https://b2.51ias.com")) teststeps = [ Step( RunRequest("login").get("/api.php").with_params( **{ "password": "******", "pid": "${ENV(pid)}", "type": "${ENV(type)}", "version": "${ENV(version)}", "username": "******", "deviceid": "${ENV(deviceid)}", "language": "${ENV(language)}", "lz": "${ENV(lz)}", "hwdeviceid": "${ENV(hwdeviceid)}", "m": "User", "a": "login", }).extract().validate().assert_equal("status_code", 200).assert_equal( "body.ret", 0)), ]
class TestCaseUserGetUserInfo(HttpRunner): @pytest.mark.parametrize("param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("获取个人信息").base_url("${get_base_url()}").variables(**{ "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 }).verify(False)) teststeps = [ Step(RunTestCase("登录").call(Login).export(*[ 'sessionId', 'token', ])), Step( RunRequest("获取用户的个人信息").get("/mall/user/getUserInfo").with_params( **{ "sessionId": "$sessionId" }).with_headers(**{ "x-tenant-id": "2", "sso_sessionid": "$sessionId", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).extract().with_jmespath( 'body.data.accountResDto.accountCode', "accountCode").with_jmespath( 'body.data.accountResDto.personId', "personId").with_jmespath( 'body.data.accountResDto.name', "name").with_jmespath( 'body.data.accountResDto.nickname', "nickname").with_jmespath( 'body.data.accountResDto.username', "username").with_jmespath( 'body.data.accountResDto.phone', "phone"). with_jmespath('body.data.memberCardResDto.memberCode', "memberCode").with_jmespath( 'body.data.memberCardResDto.userId', "userId").with_jmespath( 'body.data.personResDto.userCode', "userCode").with_jmespath( 'body.data.accountResDto.id', "account_id").with_jmespath( 'body.data.memberCardResDto.id', "member_id").validate().assert_equal( "status_code", 200). assert_equal('headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success")), ]
class TestCaseSearchAllOrder(HttpRunner): @pytest.mark.parametrize( 'param', Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", }), ) def test_start(self, param): super().test_start(param) config = (Config("登录操作 ").base_url("${get_base_url()}").export(*[ 'sessionId', 'token', 'accountCode', 'personId', "name", "nickname", "username", "phone", "memberCode", "userCode", "account_id", "storeCode", "platformPricing", "salePrice", "itemCode", "skuCode", "orderIdOut", "orderNo" ]).verify(False)) teststeps = [ Step( RunTestCase("登录").call(Login).export(*[ 'sessionId', 'token', 'accountCode', 'personId', "name", "nickname", "username", "phone", "memberCode", "userCode", "account_id", "storeCode", ])), Step( RunRequest("查看全部订单").get("/mall/order/getOrderPage").with_params( **{ "currentPage": "1", "pageSize": "10", "qp-memberCardCode-eq": "$memberCode", "qp-storeCode-eq": "$storeCode", }).with_headers(**{ "x-tenant-id": "2", "sso_sessionid": "$sessionId", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).extract().with_jmespath('body.data.totalCount', "totalCount"). with_jmespath('body.data.totalPage', "totalPage").with_jmespath( 'body.data.pageSize', "pageSize").validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success") # .assert_less_than("$totalCount", "$totalPage * $pageSize") ), ]
class TestCaseITemGetCommentList(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", "qp_customerId_eq-qp_skuCode_eq-sorter": "${parameterize(testcases/api/mall/item/item_getCommentList.csv)}", }) ) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("商品评价列表") .base_url("${get_base_url()}") .variables(**{ "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 }) .verify(False) ) teststeps = [ Step( RunTestCase("登录") .call(Login) .export(*['sessionId', 'token',]) ), Step( RunRequest("获取商品评价") .get("/mall/item/getCommentList") .with_params( **{ "qp-customerId-eq": "$qp_customerId_eq", "qp-skuCode-eq": "$qp_skuCode_eq", "pageSize": "10", "currentPage": "1" } ) .with_headers( **{ "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", } ) .with_cookies( **{ "sessionId": "$sessionId", "token": "$token", } ) .validate() .assert_equal("status_code", 200) .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8") .assert_equal("body.code", "000000") .assert_equal("body.msg", "Success") ), ]
class TestCaseCmstemplateQuerytemplate(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "business_userName-business_password-business_verifyCode-business_regType": "${parameterize(common.csv)}", "store_code-currentPage-pageSize-qp_bg_eq-qp_platform_eq-qp_storeCode_eq-qp_templateName_like-qp_templateType_eq-sorter": "${parameterize(testcases/api/business/cmsTemplate/cmsTemplate_queryTemplate.csv)}" })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("计算购物车中选中商品的价格").base_url("${get_base_url()}").variables( **{ "x_app_id": "201", "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 }).export(*[ "sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode" ]).verify(False)) teststeps = [ Step( RunTestCase("商家后台登录").call(Login).export(*[ "sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode" ])), Step( RunRequest("查询装修模板,也就是列表").get( "/business/api/cmsTemplate/queryTemplate").with_params( **{ "qp-bg-eq": "$qp_bg_eq", "qp-platform-eq": "$qp_platform_eq", "qp-templateName-like": "$qp_templateName_like", "pageSize": "$pageSize", "currentPage": "$currentPage", "qp-templateType-eq": "$qp_templateType_eq", "sorter": "$sorter", "qp-storeCode-eq": "$qp_storeCode_eq" }).with_headers( **{ "x-app-id": "$x_app_id", "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", "store-code": "$store_code", "business-code": "$accountCode", "token": "$token", }).validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal( "body.msg", "Success").assert_equal( "body.traceId", "")), ]
class TestCaseQuery(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "userName-password-verifyCode1-regType": "${parameterize(common.csv)}", "qp_orderNo_eq-qp_storeCode_eq-qp_phoneNumber_eq": "${parameterize(testcases/api/ops/order/query.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("登录ops环境").base_url("${get_base_url()}").variables( **{ "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 "x_app_id": "200", }).export(*["token", "sessionId"]).verify(False)) teststeps = [ Step(RunTestCase("登录ops").call(Login).export(*["token", "sessionId"])), Step( RunRequest("/ops/api/order/query").get( "/ops/api/order/query").with_params( **{ "qp-orderNo-eq": "$qp_orderNo_eq", "qp-storeCode-eq": "$qp_storeCode_eq", "qp-phoneNumber-eq": "$qp_phoneNumber_eq", # "qp-createTime-ge": "{}".format((datetime.datetime.now() + datetime.timedelta(-10) ).strftime("%Y-%m-%d %H:%M:%S")), "qp-createTime-le": "{}".format(datetime.datetime.now().strftime( "%Y-%m-%d %H:%M:%S")), }).with_headers( **{ "x-app-id": "200", "x-tenant-id": "2", "sso_sessionid": "$sessionId", "Token": "$token", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal( "body.msg", "Success")), ]
class TestCaseItemGetitemlist(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "userName-password-verifyCode1-regType": "${parameterize(common.csv)}", "currentPage-pageSize-qp_brandId_in-qp_businessCode_eq-qp_categoryId_in-qp_channelId_in-qp_classId_in-qp_combination_eq-qp_createTime_eq-qp_itemCode_eq-qp_name_like-qp_ownerId_eq-qp_storeCode_eq-sorter": "${parameterize(testcases/api/ops/item/item_getItemList.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("登录ops环境").base_url("${get_base_url()}").variables( **{ "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 "x_app_id": "200", }).export(*["token", "sessionId"]).verify(False)) teststeps = [ Step(RunTestCase("登录").call(Login).export(*["sessionId", "token"])), Step( RunRequest("获取商品列表").get("/ops/api/item/getItemList").with_params( **{ "currentPage": "$currentPage", "pageSize": "$pageSize", "qp-combination-eq": "$qp_combination_eq", "qp-ownerId-eq": "$qp_ownerId_eq", "qp-brandId-in": "$qp_brandId_in", "qp-businessCode-eq": "$qp_businessCode_eq", "qp-categoryId-in": "$qp_categoryId_in", "qp-channelId-in": "$qp_channelId_in", "qp-classId-in": "$qp_classId_in", "qp-createTime-eq": "$qp_createTime_eq", "qp-itemCode-eq": "$qp_itemCode_eq", "qp-name-like": "$qp_name_like", "qp-storeCode-eq": "$qp_storeCode_eq", "sorter": "$sorter" }).with_headers( **{ "x-app-id": "$x_app_id", "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", "Token": "$token", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success")), ]
class TestCaseMemberGetmembercardlist(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "userName-password-verifyCode1-regType": "${parameterize(common.csv)}", "currentPage-pageSize-qp_barCode_eq-qp_brandId_in-qp_categoryId_in-qp_classId_in-qp_combination_eq-qp_labelIds_like-qp_name_like-qp_ownerId_eq-qp_skuCode_eq-qp_storeCode_eq-skuNameOrCode-sorter": "${parameterize(testcases/api/ops/item/getSkuList.csv)}", }) ) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("登录ops环境") .base_url("${get_base_url()}") .variables(**{ "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 "x_app_id": "200", }) .export(*["token", "sessionId"]) .verify(False) ) teststeps = [ Step( RunTestCase("登录") .call(Login) .export(*["sessionId", "token"]) ), Step( RunRequest("查询一系列对象,也就是列表") .get("/ops/api/member/getMemberCardList") .with_params(**{"currentPage": "1", "pageSize": "10"}) .with_headers( **{ "x-app-id": "$x_app_id", "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", "Token": "$token", } ) .with_cookies( **{ "sessionId": "$sessionId", "token": "$token", } ) .validate() .assert_equal("status_code", 200) .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8") .assert_equal("body.code", "000000") .assert_equal("body.msg", "Success") ), ]
class TestCaseReverseorderQuery(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "business_userName-business_password-business_verifyCode-business_regType": "${parameterize(common.csv)}", "store_code-currentPage-pageSize-qp_createTime_ge-qp_createTime_le-qp_orderIdOut_eq-qp_phoneNumber_eq-qp_storeCode_in-sorter": "${parameterize(testcases/api/business/order/reverseOrder_query.csv)}" })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("计算购物车中选中商品的价格").base_url("${get_base_url()}").variables(**{ "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 }).export(*[ "sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode" ]).verify(False)) teststeps = [ Step( RunTestCase("商家后台登录").call(Login).export(*[ "sessionId", "token", "employeeName", "employeeId", "accountName", "accountId", "accountCode" ])), Step( RunRequest("售后订单查询").get( "/business/api/reverseOrder/query").with_params( **{ "currentPage": "$currentPage", "pageSize": "$pageSize", "qp-storeCode-in": "$qp_storeCode_in", "qp-createTime-ge": "$qp_createTime_ge", "qp-createTime-le": "$qp_createTime_le", "qp-orderIdOut-eq": "$qp_orderIdOut_eq", "qp-phoneNumber-eq": "$qp_phoneNumber_eq", "sorter": "$sorter" }).with_headers( **{ "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", "store-code": "$store_code", "business-code": "$accountCode", "token": "$token", }).validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal( "body.msg", "Success")), ]
class TestCaseStoreQuery(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "userName-password-verifyCode1-regType": "${parameterize(common.csv)}", "currentPage-pageSize-qp_customerName_like-qp_storeName_like-qp_storeCode_like-sorter-customerCode": "${parameterize(testcases/api/ops/store/store_query.csv)}", })) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("登录ops环境").base_url("${get_base_url()}").variables( **{ "x_tenant_id": "2", # tenant Default value : 2 必填选项 header部分 "x_app_id": "200", }).export(*["token", "sessionId"]).verify(False)) teststeps = [ Step(RunTestCase("登录").call(Login).export(*["token", "sessionId"])), Step( RunRequest("店铺查询").get("/ops/api/store/query").with_params( **{ "currentPage": "$currentPage" if "$currentPage" else None, "pageSize": "$pageSize", "qp-customerName-like": "$qp_customerName_like", "qp-storeName-like": "$qp_storeName_like", # "customerCode" if "$customerCode" else "": "$customerCode" if "$customerCode" else "", # string (query) 渠道商code "qp-storeCode-like": "$qp_storeCode_like", # string (query) 店铺编码 "sorter": "$sorter", # string (query) 排序条件 desc-字段名或者asc-字段名 }).with_headers( **{ "x-app-id": "$x_app_id", "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", "Token": "$token", }).with_cookies(**{ "sessionId": "$sessionId", "token": "$token", }).validate().assert_equal( "status_code", 200).assert_equal( 'headers."Content-Type"', "application/json;charset=UTF-8").assert_equal( "body.code", "000000").assert_equal("body.msg", "Success").assert_equal( "body.traceId", "")), ]
class TestCaseHomeTGetPageByYourLike(HttpRunner): @pytest.mark.parametrize( "param", Parameters({ "phoneNumber-verifyCode": "${parameterize(common.csv)}", "currentPage-pageSize-qp_storeCode_eq-userCode": "${parameterize(testcases/api/mall/homeTemplate/homeT_getPageByYourLike.csv)}" }) ) def test_start(self, param) -> "HttpRunner": super().test_start(param) config = ( Config("查询获取一个商品的详情") .base_url("${get_base_url()}") .variables(**{ "x_tenant_id": "2", #tenant Default value : 2 必填选项 header部分 }) .verify(False) ) teststeps = [ Step( RunTestCase("登录") .with_variables(**{"x_tenant_id": "2",}) .call(Login) .export(*['sessionId', 'token', 'accountCode', 'personId', "name", "nickname", "username", "phone", "memberCode", "userCode", "account_id", "storeCode", "member_id"]) ), Step( RunRequest("猜你喜欢") .get("/mall/homeTemplate/getItemPagerByYourLike") .with_params(**{"qp-storeCode-eq": "$qp_storeCode_eq", "pageSize": "12", "userCode": "$userCode"}) .with_headers( **{ "x-tenant-id": "$x_tenant_id", "sso_sessionid": "$sessionId", } ) .with_cookies( **{ "sessionId": "$sessionId", "token": "$token", } ) .validate() .assert_equal("status_code", 200) .assert_equal('headers."Content-Type"', "application/json;charset=UTF-8") .assert_equal("body.code", "000000") .assert_equal("body.msg", "Success") ), ]