Commit 1d1abe62 authored by 张伟男's avatar 张伟男

Merge branch 'common_dev' into zwn_dev

parents b18b749e ad31b5fe
.gitignore
host.yaml
base_request.py
# Byte-compiled / optimized / DLL files # Byte-compiled / optimized / DLL files
__pycache__/ __pycache__/
*.py[cod] *.py[cod]
......
...@@ -11,7 +11,16 @@ class shopcart_request(BaseRequest): ...@@ -11,7 +11,16 @@ class shopcart_request(BaseRequest):
def list(self): def list(self):
return self.api_send(self.data["list"]) return self.api_send(self.data["list"])
#商祥页-加入购物车
def add(self, from_live, number, service_item_id):
self.params["from_live"] = from_live
self.params["number"] = number
self.params["service_item_id"] = service_item_id
return self.api_send(self.data["add"])
if __name__ == '__main__': if __name__ == '__main__':
#打印购物车列表接口返回 #打印购物车列表接口返回
print(shopcart_request().list()) print(shopcart_request().list())
#打印商祥页-加入购物车接口返回
print(shopcart_request().add("", 1, "618788"))
\ No newline at end of file
...@@ -6,3 +6,15 @@ list: ...@@ -6,3 +6,15 @@ list:
data: {} data: {}
json: {} json: {}
isLogin: 1 isLogin: 1
#商祥页-加入购物车
add:
method: post
url: /api/shopcart/add/v1
params: {}
data:
from_live: ${from_live}
number: ${number}
service_item_id: ${service_item_id}
json: {}
isLogin: 1
\ No newline at end of file
login_thirdphone:
method: post
url: /api/account/login/third_phone_login
params:
version: ${version}
data:
phone_data: ${phone_data}
phone_from_type: ${phone_from_type}
json: {}
\ No newline at end of file
import path_setting
from in_common.base_request import BaseRequest
class thirdphonelogin_request(BaseRequest):
def __init__(self):
self.thirdphonelogin = self.api_load(path_setting.THIRD_PHONE_LOGIN_CONFIG)
def thirdphone_login(self,version,phone_data,phone_from_type):
self.params["version"] = version
self.params["phone_data"] = phone_data
self.params["phone_from_type"] = phone_from_type
return self.api_send(self.thirdphonelogin["login_thirdphone"])
...@@ -2,3 +2,4 @@ develop_host: ...@@ -2,3 +2,4 @@ develop_host:
backend: http://backend.paas-develop.env backend: http://backend.paas-develop.env
# doctor: http://doctor.paas-develop.env # doctor: http://doctor.paas-develop.env
# backend: https://backend.igengmei.com # backend: https://backend.igengmei.com
...@@ -11,9 +11,7 @@ import path_setting ...@@ -11,9 +11,7 @@ import path_setting
class BaseRequest: class BaseRequest:
params = {} params = {}
data = {}
@classmethod @classmethod
def format(cls, r): def format(cls, r):
...@@ -34,35 +32,10 @@ class BaseRequest: ...@@ -34,35 +32,10 @@ class BaseRequest:
if r is None: if r is None:
r = self.r.json() r = self.r.json()
return jsonpath(r, path) return jsonpath(r, path)
'''
def get_cookie(self, req: dict):
host = self.api_load(path_setting.HOSTYAML_CONFIG)
print(host)
r = requests.request(
req['method'],
url=host['develop_host']['url'] + req['url'],
params=req['params'],
headers=req['headers'],
data=req['data'],
json=req['json']
)
dict = {}
for i in r.cookies:
dict[i.name] = i.value
headers = '_gtid={};sessionid={}'.format(dict["_gtid"], dict["sessionid"])
return headers
def read_header(self):
with open("../in_common/get_cookie.txt", 'r', encoding='utf-8') as f:
cookies = f.read()
headers = {"cookie": cookies}
return headers
'''
def api_send(self, req: dict): def api_send(self, req: dict):
host = self.api_load(path_setting.HOSTYAML_CONFIG) host = self.api_load(path_setting.HOSTYAML_CONFIG)
url_host = ""
# 获取调用该方法的路径 # 获取调用该方法的路径
import inspect import inspect
ins_file = inspect.stack()[1].filename ins_file = inspect.stack()[1].filename
...@@ -89,10 +62,6 @@ class BaseRequest: ...@@ -89,10 +62,6 @@ class BaseRequest:
s = LoginFunction().get_session() s = LoginFunction().get_session()
# 调用具体case的url # 调用具体case的url
print(req['method'])
print(url_host + req['url'])
print(req.get('params'))
print(req.get('data'))
r = s.request( r = s.request(
req['method'], req['method'],
url=url_host + req['url'], url=url_host + req['url'],
...@@ -101,6 +70,7 @@ class BaseRequest: ...@@ -101,6 +70,7 @@ class BaseRequest:
data=req.get('data'), data=req.get('data'),
json=req.get('json'), json=req.get('json'),
# proxies={"http":"172.30.9.226:8888"} # proxies={"http":"172.30.9.226:8888"}
) )
return r.json() return r.json()
...@@ -108,8 +78,33 @@ class BaseRequest: ...@@ -108,8 +78,33 @@ class BaseRequest:
def trace_id(self): def trace_id(self):
return ''.join(random.sample(string.ascii_lowercase + string.digits, 32)) return ''.join(random.sample(string.ascii_lowercase + string.digits, 32))
'''
def get_cookie(self, req: dict):
host = self.api_load(path_setting.HOSTYAML_CONFIG)
print(host)
r = requests.request(
req['method'],
url=host['develop_host']['url'] + req['url'],
params=req['params'],
headers=req['headers'],
data=req['data'],
json=req['json']
)
dict = {}
for i in r.cookies:
dict[i.name] = i.value
headers = '_gtid={};sessionid={}'.format(dict["_gtid"], dict["sessionid"])
return headers
def read_header(self):
with open("../in_common/get_cookie.txt", 'r', encoding='utf-8') as f:
cookies = f.read()
headers = {"cookie": cookies}
return headers
'''
if __name__ == '__main__': if __name__ == '__main__':
# BaseRequest().api_load("../api/api.yaml") # BaseRequest().api_load("../api/api.yaml")
# print(BaseApi().trace_id()) print(BaseRequest().trace_id())
BaseRequest().a()
...@@ -22,16 +22,6 @@ SERVICE_DATA=os.path.join(BASE_DIR, "backend_auto/test_doctor_data/web2_data", " ...@@ -22,16 +22,6 @@ SERVICE_DATA=os.path.join(BASE_DIR, "backend_auto/test_doctor_data/web2_data", "
SERVICE_URL=os.path.join(BASE_DIR, "backend_auto/all_doctor_api", "web2_request.yaml") SERVICE_URL=os.path.join(BASE_DIR, "backend_auto/all_doctor_api", "web2_request.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")
# 首页灰度v9,精选tab # 首页灰度v9,精选tab
FEED_INDEXV9_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "feed_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") FEED_INDEXV9_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/feed_data", "index_v9.yaml")
...@@ -105,6 +95,7 @@ MY_CONVERSATION = os.path.join(BASE_DIR, "backend_auto/test_backend_data/my_conv ...@@ -105,6 +95,7 @@ MY_CONVERSATION = os.path.join(BASE_DIR, "backend_auto/test_backend_data/my_conv
HOME_V5_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "service_request.yaml") HOME_V5_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "service_request.yaml")
HOME_V5=os.path.join(BASE_DIR,"backend_auto/test_backend_data/service_data","home_v5.yaml") HOME_V5=os.path.join(BASE_DIR,"backend_auto/test_backend_data/service_data","home_v5.yaml")
PERSONAL_CENTER_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "user_request.yaml") PERSONAL_CENTER_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "user_request.yaml")
PERSONAL_CENTER = os.path.join(BASE_DIR, "backend_auto/test_backend_data/user_data", "personal_center.yaml") PERSONAL_CENTER = os.path.join(BASE_DIR, "backend_auto/test_backend_data/user_data", "personal_center.yaml")
...@@ -146,6 +137,8 @@ SERVICE_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/service_d ...@@ -146,6 +137,8 @@ SERVICE_FAVOR = os.path.join(BASE_DIR, "backend_auto/test_backend_data/service_d
#商祥页-分享 #商祥页-分享
SERVICES_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "services_request.yaml") SERVICES_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "services_request.yaml")
SERVICES_SHARE_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/services_data", "share_data.yaml") SERVICES_SHARE_DATA = os.path.join(BASE_DIR, "backend_auto/test_backend_data/services_data", "share_data.yaml")
#商祥页-加入购物车
SHOPCART_ADD = os.path.join(BASE_DIR, "backend_auto/test_backend_data/shopcart_data", "add.yaml")
#捜索结果页-医生/医院tab #捜索结果页-医生/医院tab
CONTENTV6_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "search_request.yaml") CONTENTV6_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "search_request.yaml")
...@@ -168,6 +161,10 @@ COMMUNITY = os.path.join(BASE_DIR, "backend_auto/test_backend_data/feed_data", " ...@@ -168,6 +161,10 @@ COMMUNITY = os.path.join(BASE_DIR, "backend_auto/test_backend_data/feed_data", "
POLYMER_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "janus_request.yaml") POLYMER_CONFIG = os.path.join(BASE_DIR, "backend_auto/all_backend_api", "janus_request.yaml")
POLYMER = os.path.join(BASE_DIR, "backend_auto/test_backend_data/janus_data", "polymer.yaml") POLYMER = os.path.join(BASE_DIR, "backend_auto/test_backend_data/janus_data", "polymer.yaml")
THIRD_PHONE_LOGIN_CONFIG = os.path.join(BASE_DIR,"backend_auto/all_backend_api", "thirdphonelogin_request")
THIRD_PHONE_LOGIN =os.path.join(BASE_DIR,"backend_auto/test_backend_data/account_data","login_thirdphone")
if __name__ == '__main__': if __name__ == '__main__':
print("==========",LIVEYAML_CONFIG) print("==========",LIVEYAML_CONFIG)
from in_common.base_request import BaseRequest
import path_setting
from ids_list import get_ids
import pytest
from all_backend_api.thirdphonelogin_request import *
class TestThirdPhoneLogin:
data = BaseRequest().api_load(path_setting.THIRD_PHONE_LOGIN)
thirdphonelogin_case,thirdphonelogin_data = get_ids(data,"login_thirdphone")
@pytest.mark.parametrize("param",thirdphonelogin_data,ids = thirdphonelogin_case)
def test_thirdphone_login(self,param):
r = thirdphonelogin_request().thirdphone_login(param["version"],param["phone_data"],param["phone_from_type"])
if r["error"] == 1:
assert r['message'] == param["assert"]
\ No newline at end of file
import pytest
from all_backend_api.shopcart_request import shopcart_request
from ids_list import get_ids
import path_setting
from in_common.base_request import BaseRequest
class TestAdd:
data = BaseRequest().api_load(path_setting.SHOPCART_ADD)
add_case, add_data = get_ids(data, "add")
@pytest.mark.parametrize("param", add_data, ids=add_case)
def test_add(self, param):
r = shopcart_request().add(param["from_live"], param["number"], param["service_item_id"])
if r["error"] == 0:
assert r["message"] == param["assert_message"]
login_thirdphone:
- case: "无版本号手机号一键登录case"
phone_data: '{
"token" : "A4-lVEf_Fk2ekkxSFgSZ59yD6bPaIxHWzJfsGgaEBDrbZzFyxMueOODIoBeXXQuHU8REjG42jvyjQa2a3rkDm8ufKlI8DL3ny2FfxnUrnuQOycWRaHKN3664onbOetr54dvb4wkVaV7X33yBlw7u_ZCNqIOwTnRQ9kPgHDBpvyN4NTdYYf2tJWhF4VeiVOqc7OiRz-Nzt08AUvbtWpw6sPQjA==",
"appId" : "xK5yFMfJ"
}'
phone_from_type: 1
version:
assert: "获取手机号失败"
- case: "大于7.32手机号一键登录case"
phone_data: '{
"token" : "A4-lVEf_Fk2ekkxSFgSZ59yD6bPaIxHWzJfsGgaEBDrbZzFyxMueOODIoBeXXQuHU8REjG42jvyjQa2a3rkDm8ufKlI8DL3ny2FfxnUrnuQOycWRaHKN3664onbOetr54dvb4wkVaV7X33yBlw7u_ZCNqIOwTnRQ9kPgHDBpvyN4NTdYYf2tJWhF4VeiVOqc7OiRz-Nzt08AUvbtWpw6sPQjA==",
"appId" : "xK5yFMfJ"
}'
phone_from_type: 1
version: "7.43.0"
assert: "获取手机号失败"
- case: "小于7.32手机号一键登录case"
phone_data: '{
"token" : "A4-lVEf_Fk2ekkxSFgSZ59yD6bPaIxHWzJfsGgaEBDrbZzFyxMueOODIoBeXXQuHU8REjG42jvyjQa2a3rkDm8ufKlI8DL3ny2FfxnUrnuQOycWRaHKN3664onbOetr54dvb4wkVaV7X33yBlw7u_ZCNqIOwTnRQ9kPgHDBpvyN4NTdYYf2tJWhF4VeiVOqc7OiRz-Nzt08AUvbtWpw6sPQjA==",
"appId" : "xK5yFMfJ"
}'
phone_from_type: 1
version: "7.32.0"
assert: "获取手机号失败"
\ No newline at end of file
add:
-
case: "校验添加成功case"
from_live: ""
number: 1
service_item_id: "618788"
assert_message: "添加成功"
\ No newline at end of file
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