Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
tkio-test-case
Project
Overview
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
liuxiaoxing
tkio-test-case
Commits
36dc680b
Commit
36dc680b
authored
May 25, 2022
by
liuxiaoxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert: receive 对接se
parent
e2b61a62
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
108 deletions
+59
-108
receiveandroid.py
microservices/receiveandroid.py
+59
-108
No files found.
microservices/receiveandroid.py
View file @
36dc680b
import
random
import
requests
import
json
import
pytest
import
time
import
random
# 生成小写字母加数字组合
n
=
10
def
code_nums
(
n
=
6
):
ret
=
''
for
i
in
range
(
n
):
num
=
random
.
randint
(
0
,
9
)
# letter = chr(random.randint(97, 122))
s
=
str
(
random
.
choice
([
num
]))
ret
+=
s
return
ret
# 153字符
chaochang
=
'543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132'
...
...
@@ -32,13 +17,12 @@ data = [
"application_info"
:
{
# 线上-a8ed96ae9051499fd98bc46ab9c9495c
# 测试-decbeb4d840b4bcd1a068ca7233e6ac2
"appkey"
:
"
904305d99f74ce0349b11238f3eeff69
"
,
"appkey"
:
"
a8ed96ae9051499fd98bc46ab9c9495c
"
,
"bundleid"
:
"3423232"
,
"app_version"
:
"1.9.0"
,
"channel_name"
:
"HUAWEI"
},
"timestamp_info"
:
{
"country"
:
"chi"
,
"time_zone"
:
"GMT+08"
,
"install_time"
:
int
(
round
(
time
.
time
()
*
1000
)),
"current_event_time"
:
int
(
round
(
time
.
time
()
*
1000
)),
...
...
@@ -55,7 +39,7 @@ data = [
"device_id_type"
:
"oaid"
,
"device_id_md5"
:
"8e488a40a17aed2f6752f51382a4eafc"
,
"device_id_md5_type"
:
"oaid_md5"
,
"os"
:
"
A
ndroid"
,
"os"
:
"
a
ndroid"
,
"os_version"
:
"19"
,
"manufacturer"
:
"HUAWEI"
,
"model"
:
"Mate 40"
,
...
...
@@ -85,14 +69,14 @@ data = [
"register_type"
:
"WeChat"
,
"login_type"
:
"Wechat"
,
"order_id"
:
"2341242342676398724"
,
"order_amount"
:
"3
0
"
,
"order_amount"
:
"3
43432
"
,
"currency_type"
:
"CNY"
,
"purchase_type"
:
"Alipay"
,
"ad_platform"
:
"csj"
,
"placement_type"
:
"interstitial"
,
"placement_id"
:
"23425334"
,
"ad_
ecpm
"
:
"4.34"
,
#
"ad_price_currency_type": "CNY",
"ad_
price
"
:
"4.34"
,
"ad_price_currency_type"
:
"CNY"
,
"is_rendered"
:
"1"
},
"custom_params"
:
{
...
...
@@ -116,13 +100,9 @@ data_temp = json.dumps(data)
def
send_request
():
global
data
# 对接se地址
url
=
'http://tmtest-se.trackingio.com/receive/tkiov2/sdk'
# 测试
# url = "http://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/sdk"
# 线上
# url = "http://tkio-receive.solar-engine.com/receive/tkiov2/sdk"
data
[
0
][
'timestamp_info'
][
'install_time'
]
=
int
(
round
(
time
.
time
()
*
1000
))
url
=
"http://tkio-receive.solar-engine.com/receive/tkiov2/sdk"
# data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000))
print
(
data
)
response
=
requests
.
request
(
"POST"
,
url
,
headers
=
headers
,
data
=
json
.
dumps
(
data
))
print
(
response
.
text
)
...
...
@@ -298,18 +278,19 @@ def test_timestamp_info_empty():
response
=
send_request
()
assert
response
[
"status"
]
==
"105"
# time_zone为空
def
test_time_zone_empty
():
data
[
0
][
"timestamp_info"
][
"time_zone"
]
=
""
response
=
send_request
()
assert
response
[
"status"
]
==
"106"
# ------------------receive接口迭代-----------
# time_zone不等于6个字符
def
test_time_zone__illegal_length
():
data
[
0
][
"timestamp_info"
][
"time_zone"
]
=
chaochang
response
=
send_request
()
assert
response
[
"status"
]
==
"
0
"
assert
response
[
"status"
]
==
"
106
"
# time_zone等于6个字符
...
...
@@ -340,43 +321,13 @@ def test_time_zone4():
assert
response
[
"status"
]
==
"106"
# time_zone为17字符,返回106
def
test_time_zone5
():
data
[
0
][
"timestamp_info"
][
"time_zone"
]
=
code_nums
(
17
)
response
=
send_request
()
assert
response
[
"status"
]
==
"106"
# time_zone为16字符,返回0
def
test_time_zone5
():
data
[
0
][
"timestamp_info"
][
"time_zone"
]
=
code_nums
(
16
)
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
# -----------------------receive接口迭代-------------
# install_time为空,event_name为install,返回107
# install_time为空
def
test_install_time_empty
():
data
[
0
][
"timestamp_info"
][
"install_time"
]
=
""
data
[
0
][
"event_info"
][
"event_name"
]
=
"install"
response
=
send_request
()
assert
response
[
"status"
]
==
"107"
# install_time为空,event_name为非install,返回0
def
test_install_time_empty1
():
newList
=
[
'startup'
,
'register'
,
'login'
,
'order'
,
'purchase'
,
'adimpression'
,
'adclick'
]
for
event
in
newList
:
data
[
0
][
"timestamp_info"
][
"install_time"
]
=
""
data
[
0
][
"event_info"
][
'event_name'
]
=
event
data
[
0
][
"event_info"
][
'event_type'
]
=
'preset'
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
# install_time不等于13个字符
def
test_install_time_illegal_length
():
data
[
0
][
"timestamp_info"
][
"install_time"
]
=
chaochang
...
...
@@ -1760,7 +1711,7 @@ def test_placement_type5():
# event_name为adimpression,ad_price为空
def
test_ad_price1
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
ecpm
'
]
=
''
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
price
'
]
=
''
data
[
0
][
'event_info'
][
'event_name'
]
=
'adimpression'
response
=
send_request
()
assert
response
[
"status"
]
==
"156"
...
...
@@ -1768,7 +1719,7 @@ def test_ad_price1():
# event_name为adimpression,ad_price不为空
def
test_ad_price2
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
ecpm
'
]
=
'765453434'
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
price
'
]
=
'765453434'
data
[
0
][
'event_info'
][
'event_name'
]
=
'adimpression'
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
...
...
@@ -1778,7 +1729,7 @@ def test_ad_price2():
def
test_ad_price3
():
newlist
=
[
'install'
,
'startup'
,
'register'
,
'login'
,
'order'
,
'purchase'
,
'adclick'
]
for
event
in
newlist
:
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
ecpm
'
]
=
''
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
price
'
]
=
''
data
[
0
][
'event_info'
][
'event_name'
]
=
event
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
...
...
@@ -1788,7 +1739,7 @@ def test_ad_price3():
def
test_ad_price4
():
newlist
=
[
'install'
,
'startup'
,
'register'
,
'login'
,
'order'
,
'purchase'
,
'adclick'
]
for
event
in
newlist
:
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
ecpm
'
]
=
'98765434567654'
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
price
'
]
=
'98765434567654'
data
[
0
][
'event_info'
][
'event_name'
]
=
event
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
...
...
@@ -1796,54 +1747,54 @@ def test_ad_price4():
# ad_price超长
def
test_ad_price5
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
ecpm
'
]
=
chaochang
data
[
0
][
"event_info"
][
'event_data'
][
'ad_
price
'
]
=
chaochang
data
[
0
][
'event_info'
][
'event_name'
]
=
"adimpression"
response
=
send_request
()
assert
response
[
"status"
]
==
"156"
# -------------------receive接口迭代-------------
#
#
event_name为adimpression,ad_price_currency_type为空
#
def test_ad_price_currency_type1():
#
data[0]["event_info"]['event_data']['ad_price_currency_type'] = ''
#
data[0]['event_info']['event_name'] = 'adimpression'
#
response = send_request()
#
assert response["status"] == "157"
#
#
#
#
event_name为adimpression,ad_price_currency_type不为空
#
def test_ad_price_currency_type2():
#
data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY'
#
data[0]['event_info']['event_name'] = 'adimpression'
#
response = send_request()
#
assert response["status"] == "0"
#
#
#
#
event_name非adimpression,ad_price_currency_type为空
#
def test_ad_price_currency_type3():
#
newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
#
for event in newlist:
#
data[0]["event_info"]['event_data']['ad_price_currency_type'] = ''
#
data[0]['event_info']['event_name'] = event
#
response = send_request()
#
assert response["status"] == "0"
#
#
#
#
event_name非adimpression,ad_price_currency_type不为空
#
def test_ad_price_currency_type4():
#
newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
#
for event in newlist:
#
data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY'
#
data[0]['event_info']['event_name'] = event
#
response = send_request()
#
assert response["status"] == "0"
#
#
#
#
ad_price_currency_type非三个字符
#
def test_ad_price_currency_type5():
#
data[0]["event_info"]['event_data']['ad_price_currency_type'] = "0"
#
data[0]['event_info']['event_name'] = "adimpression"
#
response = send_request()
#
assert response["status"] == "157"
# event_name为adimpression,ad_price_currency_type为空
def
test_ad_price_currency_type1
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_price_currency_type'
]
=
''
data
[
0
][
'event_info'
][
'event_name'
]
=
'adimpression'
response
=
send_request
()
assert
response
[
"status"
]
==
"157"
# event_name为adimpression,ad_price_currency_type不为空
def
test_ad_price_currency_type2
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_price_currency_type'
]
=
'CNY'
data
[
0
][
'event_info'
][
'event_name'
]
=
'adimpression'
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
# event_name非adimpression,ad_price_currency_type为空
def
test_ad_price_currency_type3
():
newlist
=
[
'install'
,
'startup'
,
'register'
,
'login'
,
'order'
,
'purchase'
,
'adclick'
]
for
event
in
newlist
:
data
[
0
][
"event_info"
][
'event_data'
][
'ad_price_currency_type'
]
=
''
data
[
0
][
'event_info'
][
'event_name'
]
=
event
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
# event_name非adimpression,ad_price_currency_type不为空
def
test_ad_price_currency_type4
():
newlist
=
[
'install'
,
'startup'
,
'register'
,
'login'
,
'order'
,
'purchase'
,
'adclick'
]
for
event
in
newlist
:
data
[
0
][
"event_info"
][
'event_data'
][
'ad_price_currency_type'
]
=
'CNY'
data
[
0
][
'event_info'
][
'event_name'
]
=
event
response
=
send_request
()
assert
response
[
"status"
]
==
"0"
# ad_price_currency_type非三个字符
def
test_ad_price_currency_type5
():
data
[
0
][
"event_info"
][
'event_data'
][
'ad_price_currency_type'
]
=
"0"
data
[
0
][
'event_info'
][
'event_name'
]
=
"adimpression"
response
=
send_request
()
assert
response
[
"status"
]
==
"157"
# is_rendered为空
...
...
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