Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
backend_auto
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
邓莹莹
backend_auto
Commits
1d1abe62
You need to sign in or sign up before continuing.
Commit
1d1abe62
authored
May 21, 2021
by
张伟男
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'common_dev' into zwn_dev
parents
b18b749e
ad31b5fe
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
167 additions
and
44 deletions
+167
-44
.gitignore
.gitignore
+4
-0
shopcart_request.py
all_backend_api/shopcart_request.py
+10
-0
shopcart_request.yaml
all_backend_api/shopcart_request.yaml
+13
-0
thirdphonelogin_request
all_backend_api/thirdphonelogin_request
+10
-0
thirdphonelogin_request.py
all_backend_api/thirdphonelogin_request.py
+17
-0
host.yaml
host.yaml
+1
-0
base_request.py
in_common/base_request.py
+29
-34
path_setting.py
path_setting.py
+7
-10
test_thirdPhone_login.py
test_backend_case/account_case/test_thirdPhone_login.py
+21
-0
test_add.py
test_backend_case/shopcart_case/test_add.py
+18
-0
login_thirdphone
test_backend_data/account_data/login_thirdphone
+29
-0
add.yaml
test_backend_data/shopcart_data/add.yaml
+8
-0
No files found.
.gitignore
View file @
1d1abe62
.gitignore
host.yaml
base_request.py
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
...
...
all_backend_api/shopcart_request.py
View file @
1d1abe62
...
...
@@ -11,7 +11,16 @@ class shopcart_request(BaseRequest):
def
list
(
self
):
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__'
:
#打印购物车列表接口返回
print
(
shopcart_request
()
.
list
())
#打印商祥页-加入购物车接口返回
print
(
shopcart_request
()
.
add
(
""
,
1
,
"618788"
))
\ No newline at end of file
all_backend_api/shopcart_request.yaml
View file @
1d1abe62
...
...
@@ -6,3 +6,15 @@ list:
data
:
{}
json
:
{}
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
all_backend_api/thirdphonelogin_request
0 → 100644
View file @
1d1abe62
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
all_backend_api/thirdphonelogin_request.py
0 → 100644
View file @
1d1abe62
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"
])
host.yaml
View file @
1d1abe62
...
...
@@ -2,3 +2,4 @@ develop_host:
backend
:
http://backend.paas-develop.env
# doctor: http://doctor.paas-develop.env
# backend: https://backend.igengmei.com
in_common/base_request.py
View file @
1d1abe62
...
...
@@ -11,9 +11,7 @@ import path_setting
class
BaseRequest
:
params
=
{}
data
=
{}
@classmethod
def
format
(
cls
,
r
):
...
...
@@ -34,35 +32,10 @@ class BaseRequest:
if
r
is
None
:
r
=
self
.
r
.
json
()
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
):
host
=
self
.
api_load
(
path_setting
.
HOSTYAML_CONFIG
)
url_host
=
""
# 获取调用该方法的路径
import
inspect
ins_file
=
inspect
.
stack
()[
1
]
.
filename
...
...
@@ -89,10 +62,6 @@ class BaseRequest:
s
=
LoginFunction
()
.
get_session
()
# 调用具体case的url
print
(
req
[
'method'
])
print
(
url_host
+
req
[
'url'
])
print
(
req
.
get
(
'params'
))
print
(
req
.
get
(
'data'
))
r
=
s
.
request
(
req
[
'method'
],
url
=
url_host
+
req
[
'url'
],
...
...
@@ -101,6 +70,7 @@ class BaseRequest:
data
=
req
.
get
(
'data'
),
json
=
req
.
get
(
'json'
),
# proxies={"http":"172.30.9.226:8888"}
)
return
r
.
json
()
...
...
@@ -108,8 +78,33 @@ class BaseRequest:
def
trace_id
(
self
):
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__'
:
# BaseRequest().api_load("../api/api.yaml")
# print(BaseApi().trace_id())
BaseRequest
()
.
a
()
print
(
BaseRequest
()
.
trace_id
())
path_setting.py
View file @
1d1abe62
...
...
@@ -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"
)
#搜索首页-热门搜索
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
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"
)
...
...
@@ -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
=
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
=
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
#商祥页-分享
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"
)
#商祥页-加入购物车
SHOPCART_ADD
=
os
.
path
.
join
(
BASE_DIR
,
"backend_auto/test_backend_data/shopcart_data"
,
"add.yaml"
)
#捜索结果页-医生/医院tab
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", "
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"
)
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__'
:
print
(
"=========="
,
LIVEYAML_CONFIG
)
test_backend_case/account_case/test_thirdPhone_login.py
0 → 100644
View file @
1d1abe62
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
test_backend_case/shopcart_case/test_add.py
0 → 100644
View file @
1d1abe62
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"
]
test_backend_data/account_data/login_thirdphone
0 → 100644
View file @
1d1abe62
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
test_backend_data/shopcart_data/add.yaml
0 → 100644
View file @
1d1abe62
add
:
-
case
:
"
校验添加成功case"
from_live
:
"
"
number
:
1
service_item_id
:
"
618788"
assert_message
:
"
添加成功"
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment