Commit ca5c338b authored by 林颖's avatar 林颖

修改代码规范--新增创建帖子接口

parent ecc83e8f
......@@ -53,7 +53,6 @@ class tractate_request(BaseRequest):
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
......@@ -62,5 +61,10 @@ class tractate_request(BaseRequest):
self.params["content"] = content
return self.api_send(self.data["publish_reply"])
# 帖子创建--登录下
def create(self):
return self.api_send(self.data["create"])
# 帖子创建--未登录下
def create_unlogin(self):
return self.api_send(self.data["create_unlogin"])
......@@ -100,4 +100,24 @@ publish_reply:
content: ${content}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#
#帖子创建一-未登录
create_unlogin:
method: get
url: /api/tractate/create
params:
data:
json: {}
isLogin: 0 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#
#帖子创建一-登录
create:
method: get
url: /api/tractate/create
params:
data:
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#
\ No newline at end of file
......@@ -85,6 +85,8 @@ TRACTATE_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate
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")
#发帖子--帖子内容创建
TRACTATE_CREATE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/tractate_data", "create.yaml")
# 问答详情页--问题详情
......@@ -97,8 +99,6 @@ ANSWER_LIST = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data
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,14 +8,13 @@ from all_backend_api.hybrid_request import hybrid_request
class TestAnswerAnswerReplyVote:
data = BaseRequest().api_load(path_setting.QA_REPLY_VOTE)
test_case, test_data = get_ids(data, "answer_reply_vote")
answeranswerreplyvote_case, answeranswerreplyvote_data = get_ids(data, "answer_reply_vote")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", answeranswerreplyvote_data, ids=answeranswerreplyvote_case)
def test_answer_answer_reply_vote(self, param):
# 直接点赞,看是否能点赞,如果返回1,就直接进入取消点赞
vote = hybrid_request().answer_reply_vote(param["id"])
if vote["error"] == 0:
print(1)
# 校验二次点赞无效
vote = hybrid_request().answer_reply_vote(param["id"])
assert vote["message"] == param["assert3"]
......@@ -23,14 +22,12 @@ class TestAnswerAnswerReplyVote:
# 取消点赞,回到取消点赞的状态
cancelvote = hybrid_request().answer_reply_cancel_vote(param["id"])
assert cancelvote["error"] == 0
print(2)
else:
assert vote["error"] == 1
assert vote["message"] == param["assert3"]
# 取消点赞,回到取消点赞的状态
cancelvote = hybrid_request().answer_reply_cancel_vote(param["id"])
assert cancelvote["error"] == 0
print(2)
......
......@@ -7,11 +7,11 @@ from all_backend_api.hybrid_request import hybrid_request
class TestQuestionNewAnswerLiist:
class TestQuestionNewAnswerList:
data = BaseRequest().api_load(path_setting.ANSWER_LIST)
test_case, test_data = get_ids(data, "question_new_answer_list")
questionnewanswerlist_case, questionnewanswerlist_data = get_ids(data, "question_new_answer_list")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", questionnewanswerlist_data, ids=questionnewanswerlist_case)
def test_question_v1(self, param):
r = hybrid_request().question_new_answer_list(param["question_id"])
if r["error"] == 0:
......
......@@ -9,9 +9,9 @@ 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")
questionv1_case, questionv1_data = get_ids(data, "question_v1")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", questionv1_case, ids=questionv1_data)
def test_question_v1(self, param):
r = hybrid_request().question_v1()
assert r["error"] == param["error"]
......
......@@ -8,9 +8,9 @@ from all_backend_api.janus_request import janus_request
class TestProductMallServiceHomeFeed:
data = BaseRequest().api_load(path_setting.FEED_TAB_SERVICE)
test_case, test_data = get_ids(data, "feed_service")
productmallservicehomefeed_case, productmallservicehomefeed_data = get_ids(data, "feed_service")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", productmallservicehomefeed_data, ids=productmallservicehomefeed_case)
def test_product_mall_service_home_feed(self,param):
r = janus_request().feed_service(param["tab_value"], param["first_load"])
assert r["error"] == 0
......
......@@ -8,9 +8,9 @@ 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")
favor_case, favor_data = get_ids(data, "favor")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", favor_data, ids=favor_case)
def test_favor(self, param):
r = qa_request().favor(param["answer_id"])
assert r["error"] == param["error"]
......
......@@ -8,9 +8,9 @@ from all_backend_api.service_request import service_request
class TestProductMallServiceHomeFeed:
data = BaseRequest().api_load(path_setting.FEED_TAB_SERVICE_DOCTORS)
test_case, test_data = get_ids(data, "home_feed")
productmallservicehomefeed_case, productmallservicehomefeed_data = get_ids(data, "home_feed")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", productmallservicehomefeed_data, ids=productmallservicehomefeed_case)
def test_product_mall_service_home_feed(self,param):
r = service_request().feed_home(param["tab_value"], param["input_type"])
assert r["error"] == 0
......
import json
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 TestCreate:
data = BaseRequest().api_load(path_setting.TRACTATE_CREATE)
create_case, create_data = get_ids(data, "create")
@pytest.mark.parametrize("param", create_data, ids=create_case)
def test_create(self, param):
# 登录了的-校验
r = tractate_request().create()
assert r["error"] == param["error1"]
# 未登录的-校验
s = tractate_request().create_unlogin()
s = json.loads(s)
# r = json.loads(r)
# print(type(r))
assert s["message"] == param["message1"]
......@@ -8,9 +8,9 @@ from all_backend_api.tractate_request import tractate_request
class TestFavor:
data = BaseRequest().api_load(path_setting.TRACTATE_FAVOR)
test_case, test_data = get_ids(data, "favor")
favor_case, favor_data = get_ids(data, "favor")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", favor_data, ids=favor_case)
def test_favor(self, param):
r = tractate_request().favor(param["tractate_id"], param["data_type"])
# print(r)
......
......@@ -8,9 +8,9 @@ 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")
publishreply_case, publishreply_data = get_ids(data, "publish_reply")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", publishreply_data, ids=publishreply_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)
......
......@@ -7,9 +7,9 @@ from all_backend_api.tractate_request import tractate_request
class TestReply:
data = BaseRequest().api_load(path_setting.TRACTATE_REPLY)
test_case, test_data = get_ids(data, "reply")
reply_case, reply_data = get_ids(data, "reply")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", reply_data, ids=reply_case)
def test_reply(self, param):
r = tractate_request().reply( param["current_city_id"], param["id"], param["data_type"] )
# print(r)
......
......@@ -9,9 +9,9 @@ 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")
vote_case, vote_data = get_ids(data, "tractate_vote")
@pytest.mark.parametrize("param", test_data, ids=test_case)
@pytest.mark.parametrize("param", vote_data, ids=vote_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:
......@@ -22,12 +22,62 @@ class TestVote:
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
cancelvote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
assert cancelvote["error"] == 0
else:
# 如果是已经点过赞的状态就直接取消点赞
canclevote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
assert canclevote["message"] == param["message2"]
cancelvote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
assert cancelvote["message"] == param["message2"]
# 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["message"]
# print(param["position"])
# # # 取消点赞,回到取消点赞的状态
# # cancelvote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
# # assert cancelvote["error"] == 0
# elif param["position"] == 1:
# vote = tractate_request().tractate_vote(param["tractate_id"], param["data_type"], param["reply_id"])
# assert vote["error"] == 0
# assert vote["message"] == param["message"]
# print(param["position"])
# else:
# # 如果是已经点过赞的状态就直接取消点赞
# cancelvote = tractate_request().tractate_cancelvote(param["tractate_id"], param["data_type"], param["reply_id"])
# assert cancelvote["message"] == param["message"]
# print(param["position"])
......
create:
#发帖子--创建帖子页面接口校验
-
case: "发帖子--创建帖子页面接口校验-"
current_city_id: "beijiing"
error1: 0
message1: "请登录后再试"
tractate_vote:
#贴子详情页点赞
#贴子详情页点赞----简单粗暴直接全部用写死的数据【不同帖子代表不同类型--并且把取消点赞接口迁移出去--指定输入-指定输出】
#position代表要用的是什么类型的case---不是必须有但有了比较好区分--从0开始【已废弃这个想法】
#技术水准有限拆不开,就写个点赞-二次点赞--取消点赞的闭环了;
-
case: "贴子详情页--点赞&取消点赞--用接口校验"
case: "贴子详情页--点赞--二次点赞---取消点赞--校验"
tractate_id: 175152
reply_id: ""
data_type: "user_post"
......@@ -12,7 +15,7 @@ tractate_vote:
-
case: "贴子详情页--一级评论点赞&取消点赞--用接口校验"
case: "贴子详情页--一级评论点赞--二次点赞--取消点赞--校验"
tractate_id: 175152
reply_id: "2167124"
data_type: "user_post"
......@@ -22,3 +25,100 @@ tractate_vote:
message2: "取消点赞成功"
# -
# case: "贴子详情页--点赞&取消点赞--用接口校验 --测试单纯点赞"
# tractate_id: 175152
# reply_id: ""
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "点赞成功"
# position: 0
# -
# case: "贴子详情页--点赞&取消点赞--用接口校验--二次点赞校验"
# tractate_id: 175152
# reply_id: ""
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "点赞成功"
# position: 1
# -
# case: "贴子详情页--点赞&取消点赞--用接口校验---取消点赞"
# tractate_id: 175152
# reply_id: ""
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "取消点赞成功"
# position: 2
##
# -
# case: "贴子详情页--一级评论点赞--用接口校验"
# tractate_id: 175152
# reply_id: "2167124"
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "点赞成功"
# position: 0
#
# -
# case: "贴子详情页--一级评论点赞--用接口校验"
# tractate_id: 175152
# reply_id: "2167124"
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "点赞成功"
# position: 1
#
#
# -
# case: "贴子详情页--一级评论取消点赞--用接口校验"
# tractate_id: 175152
# reply_id: "2167124"
# data_type: "user_post"
# current_city_id: "beijing"
# assert1: 0
# message: "取消点赞成功"
# position: 2
#
#
#
# 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