Commit 092587ad authored by admin's avatar admin

Merge branch 'common_dev' into zhanghui_dev

parents 1c2399d6 e4a30ede
File added
......@@ -4,7 +4,7 @@ from in_common.base_request import BaseRequest
class account_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.APYAML_CONFIG)
self.loginvfc = self.api_load(path_setting.APYAML_CONFIG)
def login_vfc(self,current_city_id,phone_num,vfc_code,vfc_type="",face_token=""):
self.params["current_city_id"] = current_city_id
......@@ -12,7 +12,8 @@ class account_request(BaseRequest):
self.params["vfc_code"] = vfc_code
self.params["vfc_type"] = vfc_type
self.params["face_token"] = face_token
return self.api_send(self.data["login_vfc"])
return self.api_send(self.loginvfc["login_vfc"])
if __name__ == '__main__':
......
import path_setting
from in_common.base_request import BaseRequest
import pytest
class send_reqest(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.LOGIN_CONFIG)
print(self.data)
def login_passwd(self,current_city_id,phone,password,face_token=""):
self.params["current_city_id"] = current_city_id
self.params["phone"] = phone
self.params["password"] = password
self.params["face_token"] = face_token
return self.api_send(self.data["password"])
if __name__ == '__main__':
print(send_reqest().login_passwd("beijing", "17796839512", 123456, ""))
password:
method: post
url: /api/accounts/login/password
params:
current_city_id: ${current_city_id}
data:
phone: ${phone}
password: ${password}
face_token: ${face_token}
json: {}
from backend_auto import path_setting
from backend_auto.in_common.base_request import BaseRequest
class diary_data_reqest(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.DIARY_DATA_CONFIG)
def diary_data(self, current_city_id, diary_referrer, sort, count , start_num):
self.params["current_city_id"] = current_city_id
self.params["diary_referrer"] = diary_referrer
self.params["sort"] = sort
self.params["count"] = count
self.params["start_num"] = start_num
return self.api_send(self.data["diary_data"])
# if __name__ == '__main__':
# print(send_reqest().login_vfc("beijing", "+8612345678912", 1234, "", ""))
# print(send_reqest().diary_data("beijing", "my_diary", 0, 8, 2))
# print(1)
\ No newline at end of file
diary_data:
method: get
url: /api/diary/topic/15261339/_data
params:
current_city_id: ${current_city_id}
diary_referrer: ${diary_referrer}
sort: ${sort}
count: ${count}
start_num: ${start_num}
data:
json: {}
import path_setting
from in_common.base_request import BaseRequest
class feed_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.FEED_INDEXV9_CONFIG)
def index_v9(self,tabtype,version,current_city_id):
self.params["tabtype"] = tabtype
self.params["version"] = version
self.params["current_city_id"] = current_city_id
return self.api_send(self.data["index_v9"])
if __name__ == '__main__':
print(feed_request().index_v9("choice", "7.42.2", "beijing"))
\ No newline at end of file
index_v9:
method: get
url: /api/feed/index/v9
params:
tabtype: ${tabtype}
version: ${version}
current_city_id: ${current_city_id}
data:
json: {}
import path_setting
from in_common.base_request import BaseRequest
class search_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.KEYWORDS_CONFIG)
#搜索首页-热门搜索模块(点击搜索框即调接口)
def keywords(self,current_city_id,search_tab):
self.params["current_city_id"] = current_city_id
self.params["search_tab"] = search_tab
return self.api_send(self.data["keywords"])
\ No newline at end of file
keywords:
method: get
#接口地址
url: /api/search/keywords
#列出所有定义函数时的参数
params:
current_city_id: ${current_city_id}
search_tab: ${search_tab}
data: {}
json: {}
\ No newline at end of file
import path_setting
from in_common.base_request import BaseRequest
class web2_request(BaseRequest):
def __init__(self):
self.data = self.api_load(path_setting.SERVICE_URL)
def service_list(self, page,pagesize,is_online):
self.params["page"] = page
self.params["pagesize"] = pagesize
self.params["is_online"] = is_online
return self.api_send(self.data["service_list"])
if __name__ == '__main__':
print(web2_request().service_list("1", "10", "-1"))
\ No newline at end of file
service_list:
method: get
url: /api/web2/service/list
params:
page: ${page}
pagesize: ${pagesize}
is_online: ${is_online}
data: {}
json: {}
\ No newline at end of file
......@@ -6,3 +6,5 @@ def pytest_collection_modifyitems(items):
for item in items:
item.name = item.name.encode("utf-8").decode("unicode_escape")
item._nodeid = item.nodeid.encode("utf-8").decode("unicode_escape")
develop_host:
url: http://backend.paas-develop.env
# url: http://doctor.paas-develop.env/
......@@ -70,11 +70,12 @@ class BaseRequest:
# 接口请求的封装
def api_send(self, req: dict):
host = self.api_load(path_setting.HOSTYAML_CONFIG)
raw = yaml.dump(req) # 将一个python对象生成为yaml文档
for key, value in self.params.items():
raw = raw.replace(f"${{{key}}}", repr(value))
req = yaml.safe_load(raw)
print('req:',req)
# print('------', req.get('headers'))
# hd = req.get('headers')
# if hd == None:
......
......@@ -4,8 +4,26 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__))
sys.path.append(BASE_DIR)
HOSTYAML_CONFIG = os.path.join(BASE_DIR, "backend_auto", "host.yaml")
APYAML_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "account_request.yaml")
LOGIN_VFC = os.path.join(BASE_DIR, "backend_auto/test_backend_data/account_data", "login_vfc.yaml")
DIARY_DATA_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "diary_data_request.yaml")
DIARY_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/account_data", "diary_data.yaml")
#搜索首页-热门搜索
KEYWORDS_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "search_request.yaml")
KEYWORDS = os.path.join(BASE_DIR, "backend_auto/test_backend_data/search_data", "keywords.yaml")
SERVICE_DATA=os.path.join(BASE_DIR, "backend_auto/test_doctor_data/web2_data", "service_list.yaml")
SERVICE_URL=os.path.join(BASE_DIR, "backend_auto/all_doctor_api", "web2_request.yaml")
FEED_INDEXV9_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "feed_request.yaml")
FEED_INDEXV9_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/feed_data", "index_v9.yaml")
LOGIN_PASSWD = os.path.join(BASE_DIR, "backend_auto/test_backend_data/accounts_data", "login_passwd.yaml")
LOGIN_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "accounts_request.yaml")
#医院主页详情
HDYAML_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "hospitals_request.yaml")
......@@ -13,5 +31,6 @@ HOSPITAL_DETAIL = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hospita
#医院主页医生列表
HOSPITAL_DOCTOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/hospitals_data", "doctor.yaml")
if __name__ == '__main__':
print("==========",HOSTYAML_CONFIG)
......@@ -6,7 +6,9 @@
- 公共分支 common_dev
- 其他分支 参与项目的人每人创建一个已自己名字命名的分支,格式 dyy_dev
### 提交代码规范
### 提交代码及编写规范
- !!!切记一,在本地写代码时,一定要再三确认是在自己的分支进行改动,不要在master分支修改
- !!!切记二:提交代码,Git add时,不要添加in_common文件里面的文件,这个是公共方法,不能随意改动,如果本地误改动了,提交后,会影响整个流程
- 为了便于项目的管理维护,参与者可以将自己的代码确保运行成功的前提下,提交到自己分支,然后每周往commo_dev
分支提交代码,负责人会将common_dev分支每周往master分支合并,参与者可每周一更新本地代码,确保自己的代码是最新的
- 本地代码提交Git仓库时,避免已经上传的代码被覆盖,请Git push之前,先操作git pull,在本地解决好冲突后,再Git push
......@@ -47,15 +49,21 @@
```
![](.readme_images/request请求方法.png)
- 然后在account_request.yaml中写请求数据,结构如图
- 并且需要在该类中,读取path_setting路径中,配置的接口的yaml数据文件
![](.readme_images/接口yaml数据读取.png)
- 然后在account_request.yaml中写接口请求数据(接口路径,传参),结构如图
![](.readme_images/yaml文件.png)
- 然后写test_data,在test_backend_data目录下,找到account_data文件,创建yaml文件,yaml文件格式介绍,如图
![](.readme_images/yaml.png)
- 将用例的路径放到path_setting.py下
- 将用例的路径放到path_setting.py下,这里面有2个路径需要放到里面,第一个是all_backend_api下创建的XXX_request.yaml文件
第二个是test_backend_case下创建的XXX.yaml文件
![](.readme_images/路径.png)
......
from test_backend_case.account_case import test_login_vfc
from test_backend_case.account_case import test_diary_data
import pytest
......
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.diary_data_request import diary_data_reqest
class TestDIARYDATA:
data = BaseRequest().api_load(path_setting.DIARY_DATA)
diary_data_case, diary_data_data = get_ids(data, "diary_data")
@pytest.mark.parametrize("param",diary_data_data,ids=diary_data_case)
def test_diary_data(self,param):
# print(2)
r = diary_data_reqest().diary_data(param["current_city_id"], param["diary_referrer"], param["sort"], param["count"], param["start_num"])
# print(1)
if r["error"] == 0:
assert r["error"] == param["assert"]
# assert(r[""])
if r["error"] == 1:
assert r["error"] == param["assert"]
......@@ -20,5 +20,3 @@ class TestLoginVfc:
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.accounts_request import send_reqest
class TestLoginPasswd:
data = BaseRequest().api_load(path_setting.LOGIN_PASSWD)
loginpasswd_case, loginpasswd_data = get_ids(data, "password")
@pytest.mark.parametrize("param",loginpasswd_data,ids=loginpasswd_case)
def test_login_passwd(self,param):
print(param["password"])
r = send_reqest().login_passwd(param["current_city_id"], param["phone"], param["password"])
if r["error"] == 1:
assert r["message"] == param["assert"]
import pytest
import path_setting
@pytest.fixture()
def login():
self.data = self.api_load(path_setting.APYAML_CONFIG)
import pytest
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
from all_backend_api.feed_request import feed_request
class TestIndexV9:
data = BaseRequest().api_load(path_setting.FEED_INDEXV9_DATA)
indexv9_case, indexv9_data = get_ids(data, "index_v9")
@pytest.mark.parametrize("param",indexv9_data,ids=indexv9_case)
def test_index_v9(self,param):
r = feed_request().index_v9(param["tabtype"], param["version"], param["current_city_id"])
if r["error"] == 0:
features = r.get("data").get("features",[])
assert len(features) > param["assert"]
import pytest
import path_setting
from all_backend_api.search_request import search_request
from ids_list import get_ids
from in_common.base_request import BaseRequest
#搜索首页-热门搜索
class TestKeywords:
data = BaseRequest().api_load(path_setting.KEYWORDS)
keywords_case, keywords_data = get_ids(data, "keywords")
@pytest.mark.parametrize("param", keywords_data, ids=keywords_case)
def test_keywords(self, param):
r = search_request().keywords(param["current_city_id"], param["search_tab"])
if r["error"] == 0:
assert r["error"] == param["assert"]
print("接口调用成功了~")
diary_data:
#字段正常case
-
case: "接口正常case"
current_city_id: "beijing"
diary_referrer: "my_diary"
sort: 0
count: 8
start_num: 2
assert: 0
-
case: "接口传参数失败,但不报错case"
current_city_id: "beijing"
diary_referrer: "my_diary"
sort: 0
count: 8
start_num: 2
assert: 0
password:
#成功登录case
-
case: "成功登录case--密码正常登录case"
current_city_id: "beijing"
phone: "17796839512"
password: 123456
assert: "17796839512"
#登录失败case
-
case: "登录失败case--手机号错误"
current_city_id: "beijing"
phone: "17796839510"
password: 123456
assert: "手机号或密码不正确"
-
case: "登录失败case--密码错误"
current_city_id: "beijing"
phone: "17796839512"
password: 1234567
assert: "手机号或密码不正确"
-
case: "登录失败case--手机号格式非数字"
current_city_id: "beijing"
phone: "177968395qq"
password: 123456
assert: "该手机号未注册过更美,请先注册!"
-
case: "登录失败case--手机号为空"
current_city_id: "beijing"
phone: ""
password: 123456
assert: "该手机号未注册过更美,请先注册!"
-
case: "登录失败case--密码为空"
current_city_id: "beijing"
phone: "17796839512"
password:
assert: "手机号或密码不正确"
-
case: "登录失败case--都为空"
current_city_id: "beijing"
phone:
password:
assert: "该手机号未注册过更美,请先注册!"
\ No newline at end of file
index_v9:
#成功登录case
-
case: "请求成功,有数据返回"
current_city_id: "beijing"
tabtype: "choice"
version: "7.42.2"
assert: 0
\ No newline at end of file
keywords:
-
#进入搜索首页
case : "进入搜索首页-成功调用搜索首页接口"
current_city_id : "beijing"
search_tab : "0"
assert : 0
import pytest
import path_setting
from all_doctor_api.web2_request import web2_request
from ids_list import get_ids
from in_common.base_request import BaseRequest
class TestServiceList:
data = BaseRequest().api_load(path_setting.SERVICE_DATA)
ServiceList_case, ServiceList_data = get_ids(data, "service_list")
@pytest.mark.parametrize("params",ServiceList_data,ids=ServiceList_case)
def test_ServiceList(self,params):
r = web2_request().service_list(params['page'],params['pagesize'],params['is_online'])
if r["error"] == 0:
assert r["data"]["page"] == params["assert"]
elif r["error"] == 1:
assert r["message"] == params["assert"]
# else:
# assert r['error'] == 0
\ No newline at end of file
service_list:
#有数据返回
-
case: "数据"
page: "1"
pagesize: "10"
is_online: "-1"
assert: "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