Commit 87849717 authored by 林颖's avatar 林颖

日记本点赞&取消点赞&各个详情页预置词返回

parent dca5c4e8
......@@ -47,4 +47,12 @@ class diary_request(BaseRequest):
self.params["topic_list"] = topic_list
return self.api_send(self.data["update"])
# 日记本卡片点赞
def diary_vote(self, diary_id):
self.params["diary_id"] = diary_id
return self.api_send(self.data["vote"])
# 日记本卡片取消点赞
def diary_cancel_vote(self, diary_id):
self.params["diary_id"] = diary_id
return self.api_send(self.data["cancel_vote"])
......@@ -78,3 +78,25 @@ update:
topic_list: ${topic_list}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#日记本卡片的点赞
vote:
method: post
url: /api/diary/vote
params:
data:
diary_id: ${diary_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
#日记本卡片的取消点赞
cancel_vote:
method: post
url: /api/diary/cancel_vote
params:
data:
diary_id: ${diary_id}
json: {}
isLogin: 1 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
import path_setting
from in_common.base_request import BaseRequest
class query_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.QUERY_CONFIG)
# 详情页预置词
def preset_words(self, id,type ):
self.params["id"] = id
self.params["type"] = type
return self.api_send(self.data["preset_words"])
#详情页预置词
preset_words:
method: get
url: /api/query/preset_words
params:
id: ${id}
type: ${type}
data:
json: {}
isLogin: 0 #需要登录添加这个字段,值为1 0是不需要登录的情况,如不需要登录,可以不添加这个字段
......@@ -22,6 +22,8 @@ DIARY_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data"
DIARY_OPERATION = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "diary_operation.yaml")
# 日记本创建日记贴信息-
DIARY_UPDATE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "diary_update.yaml")
# 日记本点赞&取消点赞
DIARY_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/diary_data", "vote.yaml")
# 日记本创建添加医院-- auto_complete 总配置项
......@@ -31,6 +33,11 @@ AUTO_COMPLE_HOSPITAL = os.path.join(BASE_DIR, "backend_auto/test_backend_data/au
AUTO_COMPLE_DOCTOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/auto_complete_data", "doctor.yaml")
# 详情页搜索预置词--query 总配置项
QUERY_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "query_request.yaml")
QUERY_PRESET_WORDS = os.path.join(BASE_DIR, "backend_auto/test_backend_data/query_data", "preset_words.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")
......@@ -38,7 +45,7 @@ DIARY_ALBUM = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data
# 日记本列表-日记贴点赞相关()
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")
DIARY_TOPIC_VOTE = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hybrid_data", "api_topic_vote.yaml")
# 日记本&帖子&日记贴&帖子&问答各个详情页下方推荐内容
......
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.diary_request import diary_request
class TestVote:
data = BaseRequest().api_load(path_setting.DIARY_VOTE)
diary_vote_case, diary_vote_data = get_ids(data, "diary_vote")
@pytest.mark.parametrize("param", diary_vote_data, ids=diary_vote_case)
def test_vote(self, param):
r = diary_request().diary_vote(param["diary_id"])
# 如果点赞成功,就走取消点赞的流程,否则先取消点赞再去点赞
if r["message"] == param["assert2"]:
# 之后取消点赞。【最后保持取消点赞的状态】
cancel_vote = diary_request().diary_cancel_vote(param["diary_id"])
assert cancel_vote["error"] == 0
else:
# 如果是已经点过赞的状态就直接取消点赞,然后再走一遍点赞-取消点赞;一般不走这边除非手动点过这个卡片
assert r["message"] == param["assert3"]
cancel_vote = diary_request().diary_cancel_vote(param["diary_id"])
assert cancel_vote["error"] == 0
vote = diary_request().diary_vote(param["diary_id"])
assert vote["message"] == param["assert2"]
cancel_vote = diary_request().diary_cancel_vote(param["diary_id"])
assert cancel_vote["error"] == 0
......@@ -7,7 +7,7 @@ from all_backend_api.hybrid_api_topic_request import hybrid_api_topic_request
class TestDiaryVote:
data = BaseRequest().api_load(path_setting.DIARY_VOTE)
data = BaseRequest().api_load(path_setting.DIARY_TOPIC_VOTE)
diary_vote_case, diary_vote_data = get_ids(data, "diary_vote")
@pytest.mark.parametrize("param", diary_vote_data, ids=diary_vote_case)
......
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.query_request import query_request
class TestPresetWords:
data = BaseRequest().api_load(path_setting.QUERY_PRESET_WORDS)
preset_words_case, preset_words_data = get_ids(data, "preset_words")
@pytest.mark.parametrize("param", preset_words_data, ids=preset_words_case)
def test_PresetWords(self, param):
r = query_request().preset_words(param["id"], param["type"])
# 因问答详情页接口返回不一样所以加了个标示位
key = "is_question_answer"
if param["is_preset_words"] == 1:
assert len(r["data"]["tags"]) == param["len"]
else:
if key in param.keys():
assert len(r["data"]["tags"]) == param["len"]
else:
assert len(r["data"]) == param["len"]
diary_vote:
#点赞case--从日记本卡片对日记本点赞
-
case: "日记本卡片点赞日记本--点赞&取消点赞成功case--校验"
diary_id: 17586091
assert1:
assert2: " +1"
assert3: "已经赞过啦"
diary_vote:
#点赞case--从日记本列表点赞
-
case: "日记本列表点赞--点赞&取消点赞成功case--校验"
case: "日记本列表点赞日记贴--点赞&取消点赞成功case--校验"
id: 21249958
topic_id: 21249958
assert1: 0
......
preset_words:
#详情页预置词
#is_preset_words 用来case判断有没有预置词,因为两个的判定条件不一样,这样写简单点
# is_question_answer 问答详情页的单独标示位
-
case: "不存在预置词--日记本详情页--校验"
id: 17586091
type: 1
len: 0
is_preset_words: 0
-
case: "存在一个预置词--日记本详情页--校验"
id: 15714021
type: 1
len: 1
is_preset_words: 1
-
case: "存在两个预置词--日记本详情页--校验"
id: 17004877
type: 1
len: 2
is_preset_words: 1
-
case: "不存在预置词--日记贴详情页--校验"
id: 123456954
type: 2
len: 0
is_preset_words: 0
-
case: "存在一个预置词--日记贴详情页--校验"
id: 21129553
type: 2
len: 1
is_preset_words: 1
-
case: "存在两个预置词--日记贴详情页--校验"
id: 21149097
type: 2
len: 2
is_preset_words: 1
-
case: "不存在预置词--问答详情页--校验---单独校验这个返回方式和别的不一样"
id: 357125
type: 3
len: 0
is_preset_words: 0
is_question_answer : 1
-
case: "存在一个预置词--问答详情页--校验"
id: 181212
type: 3
len: 1
is_preset_words: 1
-
case: "存在两个预置词--问答详情页--校验"
id: 124225
type: 3
len: 2
is_preset_words: 1
-
case: "不存在预置词--回答详情页--校验"
id: 1008579
type: 4
len: 0
is_preset_words: 0
-
case: "存在一个预置词--回答详情页--校验"
id: 246245
type: 4
len: 1
is_preset_words: 1
-
case: "存在两个预置词--回答详情页--校验"
id: 867689
type: 4
len: 2
is_preset_words: 1
-
case: "不存在预置词--帖子详情页--校验"
id: 187937
type: 5
len: 0
is_preset_words: 0
-
case: "存在一个预置词--帖子详情页--校验"
id: 44534
type: 5
len: 1
is_preset_words: 1
-
case: "存在两个预置词--帖子详情页--校验"
id: 172774
type: 5
len: 2
is_preset_words: 1
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