Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jk_interface_test
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
huangqiang
jk_interface_test
Commits
db573bf4
Commit
db573bf4
authored
Apr 14, 2021
by
蒲肖建
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'puxiaojian' into 'master'
极运营营销banner0414 See merge request
!3
parents
df525eda
1d4fd334
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
190 additions
and
3 deletions
+190
-3
operation_time.py
common/operation_time.py
+6
-0
conftest.py
script/conftest.py
+14
-0
defalut_account.py
script/defalut_account.py
+3
-3
__init__.py
script/ji_yun_ying_pc/marketing/__init__.py
+0
-0
conftest.py
script/ji_yun_ying_pc/marketing/conftest.py
+1
-0
__init__.py
script/ji_yun_ying_pc/marketing/data_config/__init__.py
+0
-0
banner_area_data.py
.../ji_yun_ying_pc/marketing/data_config/banner_area_data.py
+24
-0
test_banner_area.py
script/ji_yun_ying_pc/marketing/test_banner_area.py
+142
-0
No files found.
common/operation_time.py
View file @
db573bf4
...
@@ -93,6 +93,12 @@ class GetTime:
...
@@ -93,6 +93,12 @@ class GetTime:
**
GetTime
.
get_today_before
(
30
)
**
GetTime
.
get_today_before
(
30
)
}
}
# 获取当前时间毫秒数
@staticmethod
def
get_current_time_millis
():
current_time
=
time
.
time
()
return
int
(
round
(
current_time
*
1000
))
# now = datetime.datetime.now()
# now = datetime.datetime.now()
# # 今天
# # 今天
...
...
script/conftest.py
View file @
db573bf4
...
@@ -6,6 +6,7 @@ from script.db_config import db_configs
...
@@ -6,6 +6,7 @@ from script.db_config import db_configs
from
script.base_api.service_user.auth
import
auth_employee_post
from
script.base_api.service_user.auth
import
auth_employee_post
from
script.defalut_account
import
accounts
from
script.defalut_account
import
accounts
from
script.base_api.service_user.departments
import
departments_schools_get
from
script.base_api.service_user.departments
import
departments_schools_get
from
script.base_api.service_user.wxMini
import
wxMini_auth_post
def
pytest_addoption
(
parser
):
def
pytest_addoption
(
parser
):
...
@@ -46,6 +47,19 @@ def ji_yun_ying_login(pytestconfig):
...
@@ -46,6 +47,19 @@ def ji_yun_ying_login(pytestconfig):
default_header
.
jyy_header
.
setdefault
(
"Authorization"
,
"token not found"
)
default_header
.
jyy_header
.
setdefault
(
"Authorization"
,
"token not found"
)
@pytest.fixture
(
scope
=
"session"
,
autouse
=
True
)
def
gos_login
(
pytestconfig
):
account
=
accounts
.
get
(
pytestconfig
.
getoption
(
'--account'
)
.
upper
())
gos_account
=
account
.
get
(
"gos_account"
)
body_data
=
{
"identifier"
:
gos_account
.
get
(
"account"
),
"credential"
:
gos_account
.
get
(
"password"
)}
res_json
=
wxMini_auth_post
(
body
=
body_data
,
header
=
default_header
.
gos_header
)
tokens
=
jsonpath
.
jsonpath
(
res_json
,
"$.data.token"
)
if
tokens
:
default_header
.
gos_header
.
setdefault
(
"Authorization"
,
f
"Bearer {tokens[0]}"
)
else
:
default_header
.
gos_header
.
setdefault
(
"Authorization"
,
"token not found"
)
@pytest.fixture
(
scope
=
"session"
)
@pytest.fixture
(
scope
=
"session"
)
def
get_big_area_schools
():
def
get_big_area_schools
():
res
=
departments_schools_get
(
headers
=
default_header
.
jyy_header
)
res
=
departments_schools_get
(
headers
=
default_header
.
jyy_header
)
...
...
script/defalut_account.py
View file @
db573bf4
...
@@ -26,7 +26,7 @@ accounts = {
...
@@ -26,7 +26,7 @@ accounts = {
"B"
:
{
"B"
:
{
# 极运营默认账号
# 极运营默认账号
"jyy_account"
:
{
"jyy_account"
:
{
"account"
:
"15
300000000
"
,
"account"
:
"15
208176554
"
,
"password"
:
"88888888"
"password"
:
"88888888"
},
},
# 极运营app默认账号
# 极运营app默认账号
...
@@ -41,8 +41,8 @@ accounts = {
...
@@ -41,8 +41,8 @@ accounts = {
},
},
# gos微信小程序默认账号
# gos微信小程序默认账号
"gos_account"
:
{
"gos_account"
:
{
"account"
:
"
xxxx
"
,
"account"
:
"
19900665188
"
,
"password"
:
"
xxxx
"
"password"
:
"
88888888
"
}
}
},
},
"C"
:
{
"C"
:
{
...
...
script/ji_yun_ying_pc/marketing/__init__.py
0 → 100644
View file @
db573bf4
script/ji_yun_ying_pc/marketing/conftest.py
0 → 100644
View file @
db573bf4
from
script.conftest
import
get_host
,
ji_yun_ying_login
,
gos_login
script/ji_yun_ying_pc/marketing/data_config/__init__.py
0 → 100644
View file @
db573bf4
script/ji_yun_ying_pc/marketing/data_config/banner_area_data.py
0 → 100644
View file @
db573bf4
areas
=
[
{
"area_data"
:
[
3364
]
},
{
"area_data"
:
[
3103
,
3159
,
3364
,
3016
,
3017
,
3018
]
}
]
platform
=
[
{
"platform_type"
:
"APP"
,
},
{
"platform_type"
:
"APPLET"
,
}
]
status
=
[
{
"status"
:
"ENABLED"
},
{
"status"
:
"DISABLED"
}
]
script/ji_yun_ying_pc/marketing/test_banner_area.py
0 → 100644
View file @
db573bf4
import
allure
import
pytest
import
jsonpath
from
common.operation_time
import
GetTime
from
script.base_api.api_operation_web.banner
import
banner_area_query_post
from
script.base_api.api_operation_web.banner
import
banner_area_add_post
from
script.base_api.api_operation_web.banner
import
banner_area_changeStatus_get
from
script.base_api.api_jksxb_mini.banner
import
banner_display_post
from
script.ji_yun_ying_pc.marketing.data_config
import
banner_area_data
from
script
import
public_asserts
from
script.default_header
import
jyy_header
,
gos_header
@allure.feature
(
"测试区域广告"
)
class
TestBannerArea
:
@allure.story
(
"测试区域广告查询-筛选"
)
@pytest.mark.parametrize
(
"area"
,
banner_area_data
.
areas
)
@pytest.mark.parametrize
(
"platform"
,
banner_area_data
.
platform
)
@pytest.mark.parametrize
(
"status"
,
banner_area_data
.
status
)
def
test_banner_area_list_search
(
self
,
area
,
platform
,
status
):
area_value
=
area
.
get
(
"area_data"
)
platform_value
=
platform
.
get
(
"platform_type"
)
status_value
=
status
.
get
(
"status"
)
body
=
{
"title"
:
""
,
"platform"
:
platform_value
,
"locationLabel"
:
"HOME"
,
"areaIds"
:
area_value
,
"status"
:
status_value
,
"pageNum"
:
1
,
"pageSize"
:
10
}
res
=
banner_area_query_post
(
body
=
body
,
header
=
jyy_header
)
print
(
res
)
data_list_json
=
jsonpath
.
jsonpath
(
res
,
"$.data.list"
)
if
data_list_json
:
data_list
=
data_list_json
[
0
]
if
len
(
data_list
)
>
0
:
platforms
=
jsonpath
.
jsonpath
(
res
,
"$.data.list..platform"
)
result1
=
public_asserts
.
assert_res_field_equal_value
(
platforms
,
platform_value
)
pytest
.
assume
(
result1
)
banner_status
=
jsonpath
.
jsonpath
(
res
,
"$.data.list..status"
)
result2
=
public_asserts
.
assert_res_field_equal_value
(
banner_status
,
status_value
)
pytest
.
assume
(
result2
)
banner_area_infos
=
jsonpath
.
jsonpath
(
res
,
"$.data.list..areaInfos"
)
if
banner_area_infos
:
for
banner_area_info_arr
in
banner_area_infos
:
if
banner_area_info_arr
:
banner_area_info
=
banner_area_info_arr
[
0
]
banner_area
=
banner_area_info
[
"areaId"
]
result3
=
banner_area
in
area_value
pytest
.
assume
(
result3
)
@allure.story
(
"测试区域广告新增"
)
def
test_banner_area_add
(
self
):
current_time
=
GetTime
.
get_current_time_millis
()
body
=
{
"title"
:
"接口自动化测试区域广告"
+
str
(
current_time
),
"platform"
:
"APPLET"
,
"locationLabel"
:
"HOME"
,
"odr"
:
1
,
"areaIds"
:
[
3014
],
"url"
:
"www.baidu.com"
,
"bannerInfos"
:
[
{
"type"
:
"IMAGE"
,
"value"
:
"https://test-1257124244.image.myqcloud.com/gosGoodsImage/image/0f3cbef1-dfd2-4620-90e5-9fb87d1ef7bc.jpeg"
}
]
}
res
=
banner_area_add_post
(
body
=
body
,
header
=
jyy_header
)
print
(
res
)
public_asserts
.
public_assert
(
res
)
@allure.story
(
"测试区域广告停用/启用及停用启用后的效果"
)
@pytest.mark.parametrize
(
"platform"
,
banner_area_data
.
platform
)
def
test_banner_area_enable
(
self
,
platform
):
platform_value
=
platform
.
get
(
"platform_type"
)
# 新增一个区域广告
current_time
=
GetTime
.
get_current_time_millis
()
add_banner_body
=
{
"title"
:
"接口自动化测试区域广告"
+
str
(
current_time
),
"platform"
:
platform_value
,
"locationLabel"
:
"HOME"
,
"odr"
:
1
,
"areaIds"
:
[
3014
],
"url"
:
"www.baidu.com"
,
"bannerInfos"
:
[
{
"type"
:
"IMAGE"
,
"value"
:
"https://test-1257124244.image.myqcloud.com/gosGoodsImage/image/0f3cbef1-dfd2-4620-90e5-9fb87d1ef7bc.jpeg"
}
]
}
res_add_banner
=
banner_area_add_post
(
body
=
add_banner_body
,
header
=
jyy_header
)
public_asserts
.
public_assert
(
res_add_banner
)
# 获取新增的区域广告ID
query_banner_body
=
{
"title"
:
add_banner_body
[
"title"
],
"platform"
:
add_banner_body
[
"platform"
],
"locationLabel"
:
"HOME"
,
"status"
:
"ENABLED"
,
"pageNum"
:
1
,
"pageSize"
:
10
}
res_query_banner
=
banner_area_query_post
(
body
=
query_banner_body
,
header
=
jyy_header
)
public_asserts
.
public_assert
(
res_query_banner
)
print
(
res_query_banner
)
data_list_json
=
jsonpath
.
jsonpath
(
res_query_banner
,
"$.data.list"
)
data_list
=
data_list_json
[
0
]
if
len
(
data_list
)
>
0
:
banner_ids
=
jsonpath
.
jsonpath
(
res_query_banner
,
"$.data.list..id"
)
if
banner_ids
:
banner_id
=
str
(
banner_ids
[
0
])
# 停用新增的区域广告
disable_param
=
"id="
+
banner_id
+
"&status=DISABLED"
res_changestaus
=
banner_area_changeStatus_get
(
params
=
disable_param
,
header
=
jyy_header
)
print
(
res_changestaus
)
public_asserts
.
public_assert
(
res_changestaus
)
query_banner_body
=
{
"locationLabel"
:
"HOME"
,
"areaIds"
:
[
3014
],
}
if
platform_value
==
"APPLET"
:
# 小程序是否能查询到停用的区域广告
query_banner_body
[
"platform"
]
=
"APPLET"
res_banner_applet
=
banner_display_post
(
body
=
query_banner_body
,
header
=
gos_header
)
display_banners_applet_ids
=
jsonpath
.
jsonpath
(
res_banner_applet
,
"$.data.displayBanners..id"
)
if
display_banners_applet_ids
:
result
=
int
(
banner_id
)
in
display_banners_applet_ids
pytest
.
assume
(
not
result
)
print
(
res_banner_applet
)
else
:
# 家长APP是否能查询到停用的区域广告
query_banner_body
[
"platform"
]
=
"APP"
res_banner_app
=
banner_display_post
(
body
=
query_banner_body
,
header
=
gos_header
)
display_banners_app_ids
=
jsonpath
.
jsonpath
(
res_banner_app
,
"$.data.displayBanners..id"
)
if
display_banners_app_ids
:
result
=
int
(
banner_id
)
in
display_banners_app_ids
pytest
.
assume
(
not
result
)
print
(
res_banner_app
)
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