Commit 9d990c2e authored by 林颖's avatar 林颖

整合部分代码--新增帖子&问答部分

parent 2e45e176
......@@ -41,6 +41,18 @@ class hybrid_request(BaseRequest):
return self.api_send(self.data['brand'])
# 问答详情页问题详情
def question_v1(self):
return self.api_send(self.data['question_v1'])
# 问答详情页--回答列表
def question_new_answer_list(self, question_id):
self.params['question_id'] = question_id
return self.api_send(self.data['question_new_answer_list'])
if __name__ == '__main__':
# print(self.data)
......
......@@ -38,3 +38,26 @@ brand:
data: {}
json: {}
#问答详情页--问题详情
question_v1:
method: GET
url: /hybrid/question_v1/210502
params:
data: {}
json: {}
isLogin: 1
#问答详情页--回答列表
question_new_answer_list:
method: GET
url: /hybrid/question/new_answer_list/_data
params:
question_id: ${question_id}
data: {}
json: {}
isLogin: 1
import path_setting
from in_common.base_request import BaseRequest
class qa_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.QA_CONFIG)
# print(self.replyanswer)
# 帖子收藏
def favor(self, answer_id):
self.params["answer_id"] = answer_id
return self.api_send(self.data["favor"])
# 帖子取消收藏
def cancelfavor(self, answer_id):
self.params["answer_id"] = answer_id
return self.api_send(self.data["cancelfavor"])
#问题收藏
favor:
method: post
url: /api/qa/favor
params:
data:
answer_id: ${answer_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#问题取消收藏
cancelfavor:
method: post
url: /api/qa/favor/cancel
params:
data:
answer_id: ${answer_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
......@@ -8,7 +8,7 @@ topic_reply_vote:
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
topic_reply_canclevote:
topic_reply_cancelvote:
method: post
url: /hybrid/api/topicreply/cancel_vote/_data
params:
......
......@@ -10,9 +10,9 @@ class topicreply_vote_request(BaseRequest):
self.params["id"] = id
return self.api_send(self.data["topic_reply_vote"])
def topic_reply_canclevote(self, id):
def topic_reply_cancelvote(self, id):
self.params["id"] = id
return self.api_send(self.data["topic_reply_canclevote"])
return self.api_send(self.data["topic_reply_cancelvote"])
# 进入日记贴详情页-用来判断这篇日记贴点赞过没
# def diary_detail(self, topic_id):
......
......@@ -27,19 +27,40 @@ class tractate_request(BaseRequest):
self.params["data_type"] = data_type
return self.api_send(self.data["reply"])
# 帖子点赞
# 帖子收藏
def favor(self, tractate_id, data_type):
self.params["tractate_id"] = tractate_id
self.params["data_type"] = data_type
return self.api_send(self.data["favor"])
# 帖子取消点赞
# 帖子取消收藏
def cancelfavor(self, tractate_id, data_type):
self.params["tractate_id"] = tractate_id
self.params["data_type"] = data_type
return self.api_send(self.data["cancelfavor"])
# 帖子点赞
def tractate_vote(self, tractate_id, data_type, reply_id):
self.params["tractate_id"] = tractate_id
self.params["data_type"] = data_type
self.params["reply_id"] = reply_id
return self.api_send(self.data["tractate_vote"])
# 帖子取消点赞
def tractate_cancelvote(self, tractate_id, data_type, reply_id):
self.params["tractate_id"] = tractate_id
self.params["data_type"] = data_type
self.params["reply_id"] = reply_id
return self.api_send(self.data["tractate_cancelvote"])
# 帖子创建一级&二级评论
def publish_reply(self, tractate_id, data_type, reply_id, content):
self.params["tractate_id"] = tractate_id
self.params["data_type"] = data_type
self.params["reply_id"] = reply_id
self.params["content"] = content
return self.api_send(self.data["publish_reply"])
......@@ -38,10 +38,6 @@ reply:
isLogin: 0 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#帖子收藏
favor:
method: post
......@@ -66,3 +62,42 @@ cancelfavor:
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#帖子点赞
tractate_vote:
method: post
url: /api/tractate/vote
params:
data:
tractate_id: ${tractate_id}
data_type: ${data_type}
reply_id: ${reply_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#帖子取消点赞
tractate_cancelvote:
method: post
url: /api/tractate/vote/cancel
params:
data:
tractate_id: ${tractate_id}
data_type: ${data_type}
reply_id: ${reply_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#
#帖子创建一级评论
publish_reply:
method: post
url: /api/tractate/publish_reply
params:
data:
tractate_id: ${tractate_id}
data_type: ${data_type}
reply_id: ${reply_id}
content: ${content}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#
\ No newline at end of file
......@@ -17,27 +17,25 @@ DIARY_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data",
#日记本关联美购
DIARY_SERVICE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "diary_service.yaml")
DIARY_SERVICE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "diary_service.yaml")
#日记本收藏&取消收藏
DIARY_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "favor.yaml")
# 日记本列表-日记贴点赞相关()
DIARY_VOTE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "hybrid_api_topic_request.yaml")
DIARY_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "api_topic_vote.yaml")
# 日记本修改日记信息operation--目前好像直接用接口写无权限稍后解决
DIARY_OPERATION_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "diary_operation.yaml")
DIARY_OPERATION = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "diary_operation.yaml")
# 日记本创建日记贴信息-
DIARY_UPDATE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "diary_update.yaml")
DIARY_UPDATE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "diary_update.yaml")
# 日记本进入相册页
DIARY_ALBUM_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "hybrid_diary_request.yaml")
DIARY_ALBUM = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "diary_album.yaml")
# 日记本列表-日记贴点赞相关()
DIARY_VOTE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "hybrid_api_topic_request.yaml")
DIARY_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "api_topic_vote.yaml")
# 日记本&帖子&日记贴&帖子&问答各个详情页下方推荐内容
PERSONAL_RECOMMENDS_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "personal_recommends.yaml")
PERSONAL_RECOMMENDS = os.path.join(BASE_DIR, "backend_auto/test_backend_data/personal_data", "personal_recommends.yaml")
......@@ -55,14 +53,17 @@ TOPIC_SUB_COMMON = os.path.join(BASE_DIR, "backend_auto/test_backend_data/common
TOPIC_REPLY_CREATE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "topic_reply_create.yaml")
TOPIC_REPLY_CREATE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/topic_data", "topic_reply_create.yaml")
# 日记贴-一级评论点赞&取消点赞topicreply
TOPIC_REPLY_VOTE_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "topicreply_vote.yaml")
TOPIC_REPLY_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/topic_data", "reply_vote.yaml")
# 日记贴-收藏&取消收藏--config文件代表,data代表接口
TOPIC_FAVOR_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "user_request.yaml")
TOPIC_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/user_data", "problem_favor.yaml")
# 日记贴-topic总的接口的请求配置
TOPIC_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "topic_request.yaml")
# 日记贴-详情页内容
......@@ -83,7 +84,24 @@ TRACTATE_RELATED_SERVICE = os.path.join(BASE_DIR, "backend_auto/test_backend_dat
TRACTATE_REPLY = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate_data", "reply.yaml")
# 帖子详情页--收藏&取消收藏
TRACTATE_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate_data", "favor.yaml")
# 帖子详情页--点赞&取消点赞
TRACTATE_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate_data", "vote.yaml")
# 帖子详情页--一级评论创建
TRACTATE_PUBLISH_REPLY = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate_data", "publish_reply.yaml")
# 问答详情页--问题详情
QUESTION_DETAIL = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "question_v1.yaml")
# 问答详情页--回答列表
ANSWER_LIST = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "question_new_answer_list.yaml")
# qa接口总的配置项--问答·相关
QA_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "qa_request.yaml")
# -问题的收藏&取消收藏
QA_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/qa_data", "favor.yaml")
# -test的文件,尝试在不动原函数的基础上加参数而不是用默认参数。--没必要
# TEST_QA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/qa_data", "test.yaml")
......
......@@ -8,7 +8,7 @@ from all_backend_api.common_request import common_request
class TestReply:
data = BaseRequest().api_load(path_setting.DIARY_COMMON_REPLY)
diary_common_reply_case, diary_common_reply_data = get_ids(data, "diary_common_reply")
diary_common_reply_case, diary_common_reply_data = get_ids(data, "common_reply")
@pytest.mark.parametrize("param", diary_common_reply_data, ids=diary_common_reply_case)
def test_reply(self, param):
......@@ -30,24 +30,6 @@ class TestReply:
assert r["data"]["reply_data"][0]["_type"] == param["type"] # 校验评论列表返回类型
# 帖子的评论列表
# r = common_request().tractate_common_reply(param["id"], param["type"])
# # print(r)
# if r["error"] == 0:
# assert r["error"] == param["assert1"]
# # 先判断有没有评论,然后判断里面需要的那些字段,如点赞字段,评论总数等,不传值,传空值
# if r["data"]["reply_data"]:
# assert r["data"]["reply_data"][0]["user_id"] is not None and r["data"]["reply_data"][0]["user_id"] is not "" # 用户id
# assert r["data"]["reply_data"][0]["user_portrait"] is not None and r["data"]["reply_data"][0]["user_portrait"] is not "" # 用户头像
# assert r["data"]["reply_data"][0]["gm_url"] is not None and r["data"]["reply_data"][0]["gm_url"] is not "" # 头像跳转链接
# assert r["data"]["reply_data"][0]["user_nickname"] is not None and r["data"]["reply_data"][0]["user_nickname"] is not "" # 用户名
# assert r["data"]["reply_data"][0]["content"] is not None and r["data"]["reply_data"][0]["content"] is not "" # 评论内容
# assert r["data"]["reply_data"][0]["reply_count"] is not None and r["data"]["reply_data"][0]["reply_count"] is not "" # 评论总数
# assert r["data"]["reply_data"][0]["reply_id"] is not None and r["data"]["reply_data"][0]["reply_id"] is not "" # 评论id
# assert r["data"]["reply_data"][0]["is_voted"] is not None and r["data"]["reply_data"][0]["is_voted"] is not "" # 是否点赞
# assert r["data"]["reply_data"][0]["_type"] == param["type4"] # 校验评论列表返回类型
......
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.hybrid_request import hybrid_request
class TestQuestionNewAnswerLiist:
data = BaseRequest().api_load(path_setting.ANSWER_LIST)
test_case, test_data = get_ids(data, "question_new_answer_list")
@pytest.mark.parametrize("param", test_data, ids=test_case)
def test_question_v1(self, param):
r = hybrid_request().question_new_answer_list(param["question_id"])
if r["error"] == 0:
if r["data"]["answers_list"]:
# 看下是否有回答
assert r["data"]["answer_total_nums"] is not None and r["data"]["answer_total_nums"] is not ""
assert r["data"]["answers_list"][0]["is_author"] is not None and r["data"]["answers_list"][0]["is_author"] is not ""
assert r["data"]["answers_list"][0]["content_level"] is not None and r["data"]["answers_list"][0]["content_level"] is not ""
assert r["data"]["answers_list"][0]["first_reply_count"] is not None and r["data"]["answers_list"][0]["first_reply_count"] is not ""
assert r["data"]["answers_list"][0]["content"] is not None and r["data"]["answers_list"][0]["content"] is not ""
assert r["data"]["answers_list"][0]["comment_count"] is not None and r["data"]["answers_list"][0]["comment_count"] is not ""
assert r["data"]["answers_list"][0]["like_num"] is not None and r["data"]["answers_list"][0]["like_num"] is not ""
assert r["data"]["answers_list"][0]["is_voted"] is not None and r["data"]["answers_list"][0]["is_voted"] is not ""
assert r["data"]["answers_list"][0]["id"] is not None and r["data"]["answers_list"][0]["id"] is not ""
assert r["data"]["answers_list"][0]["answer_id"] is not None and r["data"]["answers_list"][0]["answer_id"] is not ""
else:
assert r["message"] == param["message"]
assert r["message"] == param["message"]
# 如果没有点过赞,就先校验点赞之后再取消点赞。【最后保持取消点赞的状态】
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.hybrid_request import hybrid_request
class TestQuestionV1:
data = BaseRequest().api_load(path_setting.QUESTION_DETAIL)
test_case, test_data = get_ids(data, "question_v1")
@pytest.mark.parametrize("param", test_data, ids=test_case)
def test_question_v1(self, param):
r = hybrid_request().question_v1()
assert r["error"] == param["error"]
if r["error"] == 0:
assert r["config"]["has_login"] is not None and r["config"]["has_login"] is not ""
assert r["config"]["url_base"] is not None and r["config"]["url_base"] is not ""
assert r["config"]["host_url"] is not None and r["config"]["host_url"] is not ""
assert r["data"]["is_favored"] is not None and r["data"]["is_favored"] is not ""
assert r["data"]["answer_count"] is not None and r["data"]["answer_count"] is not ""
assert r["data"]["answer_level_lte2_nums"] is not None and r["data"]["answer_level_lte2_nums"] is not ""
assert r["data"]["answer_level_gte3_nums"] is not None and r["data"]["answer_level_gte3_nums"] is not ""
assert r["data"]["is_following"] is not None and r["data"]["is_following"] is not ""
assert r["data"]["id"] is not None and r["data"]["id"] is not ""
assert r["data"]["title"] is not None and r["data"]["title"] is not ""
assert r["data"]["content"] is not None and r["data"]["content"] is not ""
# 如果没有点过赞,就先校验点赞之后再取消点赞。【最后保持取消点赞的状态】
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.qa_request import qa_request
class TestFavor:
data = BaseRequest().api_load(path_setting.QA_FAVOR)
test_case, test_data = get_ids(data, "favor")
@pytest.mark.parametrize("param", test_data, ids=test_case)
def test_favor(self, param):
r = qa_request().favor(param["answer_id"])
assert r["error"] == param["error"]
r = qa_request().cancelfavor(param["answer_id"])
assert r["error"] == param["error"]
......@@ -22,11 +22,11 @@ class TestVote:
assert vote["error"] == 0
assert vote["message"] == param["message1"]
# 取消点赞,回到取消点赞的状态
canclevote = topic_request().topic_canclevote(param["topic_id"])
canclevote = topic_request().topic_cancelvote(param["topic_id"])
assert canclevote["error"] == 0
else:
# 如果是已经点过赞的状态就直接取消点赞
canclevote = topic_request().topic_canclevote(param["topic_id"])
canclevote = topic_request().topic_cancelvote(param["topic_id"])
assert canclevote["error"] == 0
assert canclevote["message"] == param["message2"]
......
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.tractate_request import tractate_request
class TestPublishReply:
data = BaseRequest().api_load(path_setting.TRACTATE_PUBLISH_REPLY)
test_case, test_data = get_ids(data, "publish_reply")
@pytest.mark.parametrize("param", test_data, ids=test_case)
def test_publish_reply(self, param):
r = tractate_request().publish_reply(param["tractate_id"], param["data_type"], param["reply_id"], param["content"])
# print(r)
assert r["error"] == param["error"]
if r["error"] == 0:
assert r["data"]["reply_data"]["content"] is not None and r["data"]["reply_data"]["content"] is not ""
assert r["data"]["reply_data"]["user_type"] is not None and r["data"]["reply_data"]["user_type"] is not ""
assert r["data"]["reply_data"]["user_gm_url"] is not None and r["data"]["reply_data"]["user_gm_url"] is not ""
assert r["data"]["reply_data"]["is_vote"] is not None and r["data"]["reply_data"]["is_vote"] is not ""
assert r["data"]["reply_data"]["id"] is not None and r["data"]["reply_data"]["id"] is not ""
assert r["data"]["reply_data"]["user_portrait"] is not None and r["data"]["reply_data"]["user_portrait"] is not ""
assert r["data"]["reply_data"]["vote_num"] is not None and r["data"]["reply_data"]["vote_num"] is not ""
assert r["data"]["reply_data"]["content"] is not None and r["data"]["reply_data"]["content"] is not ""
assert r["data"]["reply_data"]["reply_count"] is not None and r["data"]["reply_data"]["reply_count"] is not ""
assert r["data"]["reply_data"]["user_name"] is not None and r["data"]["reply_data"]["user_name"] is not ""
assert r["data"]["reply_data"]["content"] == param["content"]
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.tractate_request import tractate_request
class TestVote:
data = BaseRequest().api_load(path_setting.TRACTATE_VOTE)
test_case, test_data = get_ids(data, "tractate_vote")
@pytest.mark.parametrize("param", test_data, ids=test_case)
def test_vote(self, param):
r = tractate_request().tractate_detail(param["current_city_id"], param["tractate_id"], param["data_type"])
if r["error"] == 0:
assert r["error"] == param["assert1"]
# 如果没有点过赞,就先校验点赞之后再取消点赞。【最后保持取消点赞的状态】
if not r["data"]["tractate_list"]["is_voted"]:
vote = tractate_request().tractate_vote(param["tractate_id"], param["data_type"], param["reply_id"])
assert vote["error"] == 0
assert vote["message"] == param["message1"]
# 取消点赞,回到取消点赞的状态
canclevote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
assert canclevote["error"] == 0
else:
# 如果是已经点过赞的状态就直接取消点赞
canclevote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
assert canclevote["message"] == param["message2"]
diary_common_reply:
common_reply:
#日记本列表评论列表--校验
-
case: "日记本列表评论列表--校验"
......
question_new_answer_list:
#问题详情页--回答列表
-
case: "问题详情页--回答列表--有回答"
error: 0
error1: 1
message: "没有更多了"
question_id: 210502
assert: false
assert2: true
-
case: "问题详情页--回答列表--无回答"
error: 0
question_id: 358247
assert: false
assert2: true
error1: 1
message: "没有更多了"
question_v1:
#问题详情
-
case: "问题详情"
error: 0
assert: false
assert2: true
personal_recommends:
#日记本详情页推荐接口校验
#详情页推荐接口校验
-
case: "校验详情页推荐数据--日记本"
current_city_id: "beijiing"
......
favor:
#问题详情页--收藏&取消收藏校验
-
case: "问题详情页--收藏&取消收藏校验-"
current_city_id: "beijiing"
answer_id: 357124
error: 0
error1: 1
message1: "收藏成功"
message2: "请登录后再试"
message3: "取消收藏成功"
publish_reply:
#帖子发布一级评论&二级评论
-
case: "贴子详情页--帖子发布一级评论--用接口校验可以发重复内容"
tractate_id: 175152
content: "太丰富发个刚刚"
data_type: "user_post"
current_city_id: "beijing"
reply_id: ""
assert1: 0
error: 0
message1: "点赞成功"
message2: "取消点赞成功"
- case: "贴子详情页--帖子发布二级评论--用接口校验可以发重复内容"
tractate_id: 175152
content: "太丰富发个刚刚"
data_type: "user_post"
current_city_id: "beijing"
reply_id: "2167124"
assert1: 0
error: 0
message1: "点赞成功"
message2: "取消点赞成功"
tractate_vote:
#贴子详情页点赞
-
case: "贴子详情页--点赞&取消点赞--用接口校验"
tractate_id: 175152
reply_id: ""
data_type: "user_post"
current_city_id: "beijing"
assert1: 0
message1: "点赞成功"
message2: "取消点赞成功"
-
case: "贴子详情页--一级评论点赞&取消点赞--用接口校验"
tractate_id: 175152
reply_id: "2167124"
data_type: "user_post"
current_city_id: "beijing"
assert1: 0
message1: "点赞成功"
message2: "取消点赞成功"
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