Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
test
autotest-airtest-web-cmdc
Commits
ad944112
Commit
ad944112
authored
Nov 03, 2023
by
liguangyu06
Browse files
新增特价单品新增验证用例
parent
342cde12
Changes
2
Hide whitespace changes
Inline
Side-by-side
air_case/cmdc_special_fresenius_group/特价单品新增验证.air/特价单品新增验证.py
0 → 100644
View file @
ad944112
# -*- encoding=utf8 -*-
__author__
=
"liguangyu"
import
random
"""
case_tag:cmdc_api,cmdc特价单品新增功能验证,2264,2264-60,sit,bs
主数据平台:后台运营系统客户列表查询、商品列表查询、特价单品新增等接口
"""
from
common.common_func
import
commonFuc
from
air_case.cmdc_login.后台管理系统登录.后台管理系统登录
import
CmdcDoLogin
from
datetime
import
timedelta
,
date
from
common.db.db
import
mySql
import
random
import
requests
import
json
module
=
"cmdc_special_fresenius_group"
# 第一步登录后台运营平台获取cmdc_access_token
# 获取登录所需账号密码
username
=
commonFuc
().
get_business_data
(
module
,
"username1"
)
password
=
commonFuc
().
get_business_data
(
module
,
"password1"
)
# 获取登录后Cmdc_access_token
cmdc_access_token
=
CmdcDoLogin
(
username
,
password
).
get_token
()
headers
=
commonFuc
().
get_business_data
(
module
,
"json_headers"
,
cmdc_access_token
)
# 第二步客户列表获取
url
=
commonFuc
().
get_api_url
()
+
commonFuc
().
get_business_data
(
module
,
"customer_list_url"
)
request_body
=
commonFuc
().
get_business_data
(
module
,
"customer_payload"
)
# 发送请求
result
=
requests
.
post
(
url
,
json
=
request_body
,
headers
=
headers
)
result
=
json
.
loads
(
result
.
content
)
# 生成随机数
customer_quantity
=
random
.
randint
(
1
,
len
(
result
[
"data"
][
"list"
]))
# 客户信息获取
customer_code
=
result
[
"data"
][
"list"
][
customer_quantity
][
"customerCode"
]
customer_name
=
result
[
"data"
][
"list"
][
customer_quantity
][
"customerName"
]
user_name
=
result
[
"data"
][
"list"
][
customer_quantity
][
"userName"
]
# 第三步商品信息获取
url
=
commonFuc
().
get_api_url
()
+
commonFuc
().
get_business_data
(
module
,
"product_list"
)
request_body
=
commonFuc
().
get_business_data
(
module
,
"product_payload"
)
# 发送请求
result
=
requests
.
post
(
url
,
json
=
request_body
,
headers
=
headers
)
result
=
json
.
loads
(
result
.
content
)
# 获取商品信息
product_detail
=
result
[
"data"
][
"list"
][
random
.
randint
(
1
,
len
(
result
[
"data"
][
"list"
]))]
product_detail
[
"activityUnitAmount"
]
=
customer_quantity
# 随机生成日期
start_date
=
date
(
2000
,
1
,
1
)
end_date
=
date
.
today
()
def
random_date
(
start
,
end
):
delta
=
end
-
start
random_days
=
random
.
randint
(
0
,
delta
.
days
)
return
start
+
timedelta
(
days
=
random_days
)
random_date
=
random_date
(
start_date
,
end_date
)
# 第四步特价单品新增
url
=
commonFuc
().
get_api_url
()
+
commonFuc
().
get_business_data
(
module
,
"url17"
)
request_body
=
{
"manufacturerGroupName"
:
""
,
"manufacturerGroupCode"
:
""
,
"groupName"
:
""
,
"limitPurchase"
:
""
,
"isLimit"
:
0
,
"products"
:
[
product_detail
],
"customerCode"
:
customer_code
,
"userName"
:
user_name
,
"customerName"
:
customer_name
,
"times"
:
[
str
(
start_date
),
str
(
random_date
)],
"documentNo"
:
customer_quantity
,
"supplementNo"
:
customer_quantity
,
"salesProvince"
:
customer_quantity
,
"salesArea"
:
customer_quantity
,
"applicationType"
:
customer_quantity
,
"effectiveTime"
:
str
(
start_date
),
"expirationTime"
:
str
(
random_date
),
"freseniusProduct"
:
product_detail
}
"""
场景: 特价单品新增功能验证
用例名称:特价单品新增功能验证
输出:{"total": 1}
"""
# 发送请求
result
=
requests
.
post
(
url
,
json
=
request_body
,
headers
=
headers
)
result
=
json
.
loads
(
result
.
content
)
# 数据库操作
mysql_handle
=
mySql
()
# 获取conf.ini文件中配置的数据库信息
host
,
port
,
user
,
pwd
=
mysql_handle
.
getConf
(
db
=
"cmdc_db"
)
# 数据库查询新增特价单品
sql
=
"SELECT t.groupId FROM `cmdc-order`.tc_fresenius_agreement_price t "
\
"WHERE customerCode = {} and documentNo = {};"
.
format
(
customer_code
,
customer_quantity
)
total
=
len
(
mysql_handle
.
selectSql
(
host
,
port
,
user
,
pwd
,
"cmdc-order"
,
sql
))
result
=
{
"total"
:
total
}
# 获取预期结果
check_dict
=
commonFuc
().
get_business_data
(
module
,
"checkDict17"
)
# 断言实际结果中是否包含预期结果的内容
commonFuc
().
check_result
(
check_dict
,
result
)
data/cmdc_special_fresenius_group/data
View file @
ad944112
...
@@ -142,8 +142,10 @@ checkDict15: {"success":true,"code":"200","message":"OK"}
...
@@ -142,8 +142,10 @@ checkDict15: {"success":true,"code":"200","message":"OK"}
#预期结果
#预期结果
checkDict16: {"customerCode":"%s"}
checkDict16: {"customerCode":"%s"}
#测试场景:特价单品新增验证
"url17": "/order/public/saveSingleProductPrice"
#预期结果
checkDict17: {"total": 1}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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