Commit 94c1181e authored by 刘婷婷's avatar 刘婷婷

增加脚本

parents f72aee20 b64eaf49
import path_setting
from in_common.base_request import BaseRequest
class answer_request(BaseRequest):
def __init__(self):
self.abc = self.api_load(path_setting.DETAIL_CONFIG)
print(self.data)
# 回答详情页
def detail(self, current_city_id, answer_id=""):
self.params["current_city_id"] = current_city_id
self.params["answer_id"] = answer_id
return self.api_send(self.abc["detail"])
# 回答详情页点赞
def vote(self, answer_id=""):
self.params["answer_id"] = answer_id
return self.api_send(self.abc["vote"])
# 回答详情页取消点赞
def cancel_vote(self, answer_id=""):
self.params["answer_id"] = answer_id
return self.api_send(self.abc["cancel_vote"])
#回答详情页
detail:
method: get
url: /api/answer/detail
params:
current_city_id: ${current_city_id}
data:
answer_id: ${answer_id}
json: {}
# isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#回答详情页——点赞
vote:
method: post
url: /api/answer/vote
params:
current_city_id: ${current_city_id}
data:
answer_id: ${answer_id}
json: {}
isLogin: 1
#回答详情页——取消点赞
cancel_vote:
method: post
url: /api/answer/cancel_vote
params:
current_city_id: ${current_city_id}
data:
answer_id: ${answer_id}
json: {}
isLogin: 1
import path_setting
from in_common.base_request import BaseRequest
class question_request(BaseRequest):
def __init__(self):
self.replyanswer = self.api_load(path_setting.QUESTION_CONFIG)
print(self.data)
# 回答详情页- 一/二级评论
def reply_answer(self, current_city_id, answer_id, content, user_id=""):
self.params["current_city_id"] = current_city_id
self.params["answer_id"] = answer_id
self.params["content"] = content
self.params["user_id"] = user_id
return self.api_send(self.replyanswer["reply_answer"])
#回答详情页- 一/二级评论
reply_answer:
method: post
url: /api/question/reply_answer
params:
current_city_id: ${current_city_id}
data:
answer_id: ${answer_id}
content: ${content}
user_id: ${user_id}
json: {}
isLogin: 1
\ No newline at end of file
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.answer_request import answer_request
class TestCancelVote:
data = BaseRequest().api_load(path_setting.CANCEL_VOTE)
cancelvote_case, cancelvote_data = get_ids(data, "cancel_vote")
@pytest.mark.parametrize("param", cancelvote_data, ids=cancelvote_case)
def test_cancel_vote(self, param):
r = answer_request().cancel_vote(param["answer_id"])
if r["error"] == 1:
assert r["message"] == param["assert"]
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.account_request import account_request
class TestLoginVfc:
data = BaseRequest().api_load(path_setting.LOGIN_VFC)
loginvfc_case, loginvfc_data = get_ids(data, "login_vfc")
@pytest.mark.parametrize("param",loginvfc_data,ids=loginvfc_case)
def test_login_vfc(self,param):
print(param["vfc_code"])
r = account_request().login_vfc(param["current_city_id"], param["phone_num"], param["vfc_code"])
if r["error"] == 0:
assert r["data"]["account_phone"] == param["assert"]
if r["error"] == 1:
assert r["message"] == param["assert"]
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.answer_request import answer_request
class TestVote:
data = BaseRequest().api_load(path_setting.VOTE)
vote_case, vote_data = get_ids(data, "vote")
@pytest.mark.parametrize("param", vote_data, ids=vote_case)
def test_vote(self, param):
r = answer_request().vote(param["answer_id"])
if r["error"] == 1:
assert r["message"] == param["assert"]
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.question_request import question_request
class TestReplyAnswer:
data = BaseRequest().api_load(path_setting.REPLY_ANSWER)
replyanswer_case, replyanswer_data = get_ids(data, "reply_answer")
@pytest.mark.parametrize("param", replyanswer_data, ids=replyanswer_case)
def test_reply_answer(self, param):
r = question_request().reply_answer(param["current_city_id"],param["answer_id"],param["content"],param["user_id"])
if r["message"] == "操作成功":
assert r["message"] == param["assert"]
#!/usr/bin/env python
# -*- coding:utf-8 -*-
cancel_vote:
- case: "接口正常case"
current_city_id: "beijing"
answer_id: "868312"
assert: ""
detail:
#字段正常case
-
case: "接口正常case"
current_city_id: "beijing"
answer_id: "868312"
assert: ""
vote:
- case: "接口正常case"
answer_id: "868312"
assert: ""
#!/usr/bin/env python
# -*- coding:utf-8 -*-
reply_answer:
- case: "接口正常case"
current_city_id: "beijing"
answer_id: "868312"
content: "长知识了"
user_id: "33910245"
assert: "操作成功"
extra: {}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment