Commit b0818bf0 by liuxiaoxing

receive 对接se

parent e2b61a62
...@@ -6,8 +6,10 @@ import pytest ...@@ -6,8 +6,10 @@ import pytest
import time import time
import random import random
# 生成小写字母加数字组合 # 生成数字组合
n = 10 n = 10
def code_nums(n=6): def code_nums(n=6):
ret = '' ret = ''
for i in range(n): for i in range(n):
...@@ -18,6 +20,20 @@ def code_nums(n=6): ...@@ -18,6 +20,20 @@ def code_nums(n=6):
return ret return ret
# 生成小写字母加数字组合
n = 10
def code_nums2(n=6):
ret = ''
for i in range(n):
num = random.randint(0, 9)
letter = chr(random.randint(97, 122))
s = str(random.choice([num, letter]))
ret += s
return ret
# 153字符 # 153字符
chaochang = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132' chaochang = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132'
cc612 = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131235432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321322132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132' cc612 = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131235432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321325432142232213213213121313131331321312321312321321322132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132'
...@@ -55,7 +71,7 @@ data = [ ...@@ -55,7 +71,7 @@ data = [
"device_id_type": "oaid", "device_id_type": "oaid",
"device_id_md5": "8e488a40a17aed2f6752f51382a4eafc", "device_id_md5": "8e488a40a17aed2f6752f51382a4eafc",
"device_id_md5_type": "oaid_md5", "device_id_md5_type": "oaid_md5",
"os": "Android", "os": "1",
"os_version": "19", "os_version": "19",
"manufacturer": "HUAWEI", "manufacturer": "HUAWEI",
"model": "Mate 40", "model": "Mate 40",
...@@ -93,7 +109,13 @@ data = [ ...@@ -93,7 +109,13 @@ data = [
"placement_id": "23425334", "placement_id": "23425334",
"ad_ecpm": "4.34", "ad_ecpm": "4.34",
# "ad_price_currency_type": "CNY", # "ad_price_currency_type": "CNY",
"is_rendered": "1" "is_rendered": "1",
"ad_id": '',
"ad_appid": '',
"product_name": '',
"product_id": '',
"product_num": '',
"bid_type": ''
}, },
"custom_params": { "custom_params": {
# "add_cart": "234234", # "add_cart": "234234",
...@@ -112,17 +134,15 @@ data = [ ...@@ -112,17 +134,15 @@ data = [
data_temp = json.dumps(data) data_temp = json.dumps(data)
def send_request(): def send_request():
global data global data
# 对接se地址 # 对接se地址
url = 'http://tmtest-se.trackingio.com/receive/tkiov2/sdk' 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://tmtest.trackingio.com/receive/tkiov2/sdk"
# 线上 # 线上
# url = "http://tkio-receive.solar-engine.com/receive/tkiov2/sdk" # url = "http://tkio-receive.solar-engine.com/receive/tkiov2/sdk"
data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000)) # data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000))
print(data) print(data)
response = requests.request("POST", url, headers=headers, data=json.dumps(data)) response = requests.request("POST", url, headers=headers, data=json.dumps(data))
print(response.text) print(response.text)
...@@ -136,6 +156,7 @@ def send_request(): ...@@ -136,6 +156,7 @@ def send_request():
def send_request2(): def send_request2():
global data global data
url = "http://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/sdk" url = "http://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/sdk"
data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000)) data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000))
print(data) print(data)
...@@ -151,8 +172,10 @@ def send_request2(): ...@@ -151,8 +172,10 @@ def send_request2():
def send_requests2s(): def send_requests2s():
global data global data
# 对接se地址
url = 'http://tmtest-se.trackingio.com/receive/tkiov2/s2s'
# url = "http://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/s2s" # url = "http://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/s2s"
url = "http://tkio-receive.solar-engine.com/receive/tkiov2/s2s" # url = "http://tkio-receive.solar-engine.com/receive/tkiov2/s2s"
response = requests.request("POST", url, headers=headers, data=json.dumps(data)) response = requests.request("POST", url, headers=headers, data=json.dumps(data))
print(response.text) print(response.text)
...@@ -166,7 +189,6 @@ def send_requests2s(): ...@@ -166,7 +189,6 @@ def send_requests2s():
# 批量上报的数据中存在异常数据 # 批量上报的数据中存在异常数据
def test_piliang(): def test_piliang():
# data.append(data[0]) # data.append(data[0])
# data[1]['event_info'] = '1' # data[1]['event_info'] = '1'
# data.append(data[0]) # data.append(data[0])
...@@ -182,6 +204,8 @@ def test_piliang(): ...@@ -182,6 +204,8 @@ def test_piliang():
data.append(first) data.append(first)
response = send_request() response = send_request()
assert response["status"] == "406" assert response["status"] == "406"
# #
# #
# 批量上报的数据超过100条 # 批量上报的数据超过100条
...@@ -193,7 +217,6 @@ def test_piliang2(): ...@@ -193,7 +217,6 @@ def test_piliang2():
assert response["status"] == "407" assert response["status"] == "407"
# -------------------------应用信息------------------------- # -------------------------应用信息-------------------------
# application_info为空 # application_info为空
def test_appinfo_empty(): def test_appinfo_empty():
...@@ -263,15 +286,14 @@ def test_app_version3(): ...@@ -263,15 +286,14 @@ def test_app_version3():
# channel_name传HUAWEI,os为iOS # channel_name传HUAWEI,os为iOS
def test_channel_name_error(): def test_channel_name_error():
data[0]["application_info"]["channel_name"] = "HUAWEI" data[0]["application_info"]["channel_name"] = "HUAWEI"
data[0]["device_info"]["os"] = "ios" data[0]["device_info"]["os"] = "2"
response = send_request() response = send_request()
assert response["status"] == "104" assert response["status"] == "104"
def test_channel_name(): def test_channel_name():
data[0]["application_info"]["channel_name"] = "HUAWEI" data[0]["application_info"]["channel_name"] = "HUAWEI"
data[0]["device_info"]["os"] = "android" data[0]["device_info"]["os"] = "1"
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
...@@ -298,18 +320,20 @@ def test_timestamp_info_empty(): ...@@ -298,18 +320,20 @@ def test_timestamp_info_empty():
response = send_request() response = send_request()
assert response["status"] == "105" assert response["status"] == "105"
# time_zone为空 # time_zone为空
def test_time_zone_empty(): def test_time_zone_empty():
data[0]["timestamp_info"]["time_zone"] = "" data[0]["timestamp_info"]["time_zone"] = ""
response = send_request() response = send_request()
assert response["status"] == "106" assert response["status"] == "106"
# ------------------receive接口迭代----------- # ------------------receive接口迭代-----------
# time_zone不等于6个字符 # time_zone不等于6个字符
def test_time_zone__illegal_length(): def test_time_zone__illegal_length():
data[0]["timestamp_info"]["time_zone"] = chaochang data[0]["timestamp_info"]["time_zone"] = chaochang
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "106"
# time_zone等于6个字符 # time_zone等于6个字符
...@@ -337,7 +361,7 @@ def test_time_zone3(): ...@@ -337,7 +361,7 @@ def test_time_zone3():
def test_time_zone4(): def test_time_zone4():
data[0]["timestamp_info"]["time_zone"] = "%¥" data[0]["timestamp_info"]["time_zone"] = "%¥"
response = send_request() response = send_request()
assert response["status"] == "106" assert response["status"] == "0"
# time_zone为17字符,返回106 # time_zone为17字符,返回106
...@@ -375,8 +399,6 @@ def test_install_time_empty1(): ...@@ -375,8 +399,6 @@ def test_install_time_empty1():
assert response["status"] == "0" assert response["status"] == "0"
# install_time不等于13个字符 # install_time不等于13个字符
def test_install_time_illegal_length(): def test_install_time_illegal_length():
data[0]["timestamp_info"]["install_time"] = chaochang data[0]["timestamp_info"]["install_time"] = chaochang
...@@ -523,7 +545,6 @@ def test_integration_types2s3(): ...@@ -523,7 +545,6 @@ def test_integration_types2s3():
assert response["status"] == "111" assert response["status"] == "111"
# integration_type为大写SDK # integration_type为大写SDK
def test_integration_type4(): def test_integration_type4():
data[0]["collector_info"]["integration_type"] = 'SDK' data[0]["collector_info"]["integration_type"] = 'SDK'
...@@ -545,8 +566,6 @@ def test_integration_type6(): ...@@ -545,8 +566,6 @@ def test_integration_type6():
assert response["status"] == "111" assert response["status"] == "111"
# collector_version为空 # collector_version为空
def test_collector_version_empty(): def test_collector_version_empty():
data[0]["collector_info"]["collector_version"] = '' data[0]["collector_info"]["collector_version"] = ''
...@@ -561,7 +580,6 @@ def test_collector_version_illegal_length(): ...@@ -561,7 +580,6 @@ def test_collector_version_illegal_length():
assert response["status"] == "112" assert response["status"] == "112"
# collector_version等于5个字符,但不是规范版本 # collector_version等于5个字符,但不是规范版本
def test_collector_version2(): def test_collector_version2():
data[0]["collector_info"]["collector_version"] = '11111' data[0]["collector_info"]["collector_version"] = '11111'
...@@ -569,7 +587,6 @@ def test_collector_version2(): ...@@ -569,7 +587,6 @@ def test_collector_version2():
assert response["status"] == "0" assert response["status"] == "0"
# collector_version等于5个字符,规范版本 # collector_version等于5个字符,规范版本
def test_collector_version3(): def test_collector_version3():
data[0]["collector_info"]["collector_version"] = '1.8.0' data[0]["collector_info"]["collector_version"] = '1.8.0'
...@@ -577,7 +594,6 @@ def test_collector_version3(): ...@@ -577,7 +594,6 @@ def test_collector_version3():
assert response["status"] == "0" assert response["status"] == "0"
# retried_times为空 # retried_times为空
def test_retried_times_empty(): def test_retried_times_empty():
data[0]["collector_info"]["retried_times"] = "" data[0]["collector_info"]["retried_times"] = ""
...@@ -592,7 +608,6 @@ def test_retried_times_illegal_length(): ...@@ -592,7 +608,6 @@ def test_retried_times_illegal_length():
assert response["status"] == "113" assert response["status"] == "113"
# -------------------------终端设备信息------------------------- # -------------------------终端设备信息-------------------------
...@@ -610,7 +625,6 @@ def test_os_android(): ...@@ -610,7 +625,6 @@ def test_os_android():
assert response["status"] == "0" assert response["status"] == "0"
# os为大写ANDROID # os为大写ANDROID
def test_os_android(): def test_os_android():
data[0]["device_info"]["os"] = 'ANDROID' data[0]["device_info"]["os"] = 'ANDROID'
...@@ -620,7 +634,7 @@ def test_os_android(): ...@@ -620,7 +634,7 @@ def test_os_android():
# os为ios,channel_name等于default,没有传idfa等iOS相关参数 # os为ios,channel_name等于default,没有传idfa等iOS相关参数
def test_os_ios2(): def test_os_ios2():
data[0]["device_info"]["os"] = 'ios' data[0]["device_info"]["os"] = '2'
data[0]['application_info']['channel_name'] = 'default' data[0]['application_info']['channel_name'] = 'default'
response = send_request() response = send_request()
assert response["status"] == "124" assert response["status"] == "124"
...@@ -633,9 +647,9 @@ def test_os_empty(): ...@@ -633,9 +647,9 @@ def test_os_empty():
assert response["status"] == "115" assert response["status"] == "115"
# os为web # os为Windows
def test_os_web(): def test_os_web():
data[0]["device_info"]["os"] = 'web' data[0]["device_info"]["os"] = '3'
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
...@@ -668,8 +682,6 @@ def test_os_version4(): ...@@ -668,8 +682,6 @@ def test_os_version4():
assert response["status"] == "0" assert response["status"] == "0"
# manufacturer为空 # manufacturer为空
def test_manufacturerempty(): def test_manufacturerempty():
data[0]["device_info"]["manufacturer"] = "" data[0]["device_info"]["manufacturer"] = ""
...@@ -691,8 +703,6 @@ def test_manufacturer3(): ...@@ -691,8 +703,6 @@ def test_manufacturer3():
assert response["status"] == "0" assert response["status"] == "0"
# model为空 # model为空
def test_model_empty(): def test_model_empty():
data[0]["device_info"]["model"] = "" data[0]["device_info"]["model"] = ""
...@@ -714,8 +724,6 @@ def test_model_illegal_length(): ...@@ -714,8 +724,6 @@ def test_model_illegal_length():
assert response["status"] == "0" assert response["status"] == "0"
# ipv4 格式非*.*.*.* # ipv4 格式非*.*.*.*
def test_ipv4(): def test_ipv4():
data[0]["device_info"]["ipv4"] = "12.2" data[0]["device_info"]["ipv4"] = "12.2"
...@@ -730,8 +738,6 @@ def test_ipv4_illegal_length(): ...@@ -730,8 +738,6 @@ def test_ipv4_illegal_length():
assert response["status"] == "119" assert response["status"] == "119"
# 集成方式为s2s,ipv4不传 # 集成方式为s2s,ipv4不传
def test_ipv4_s2s(): def test_ipv4_s2s():
data[0]["device_info"]["ipv4"] = "" data[0]["device_info"]["ipv4"] = ""
...@@ -748,8 +754,6 @@ def test_ipv4_s2s2(): ...@@ -748,8 +754,6 @@ def test_ipv4_s2s2():
assert response["status"] == "0" assert response["status"] == "0"
# 集成方式为s2s,ipv6不传 # 集成方式为s2s,ipv6不传
def test_ipv6_s2s(): def test_ipv6_s2s():
data[0]["device_info"]["ipv6"] = "" data[0]["device_info"]["ipv6"] = ""
...@@ -774,8 +778,6 @@ def test_ipv6_illegal_length(): ...@@ -774,8 +778,6 @@ def test_ipv6_illegal_length():
assert response["status"] == "120" assert response["status"] == "120"
# ua为空,os为android # ua为空,os为android
def test_ua_androidempty(): def test_ua_androidempty():
data[0]["device_info"]["ua"] = "" data[0]["device_info"]["ua"] = ""
...@@ -784,7 +786,6 @@ def test_ua_androidempty(): ...@@ -784,7 +786,6 @@ def test_ua_androidempty():
assert response["status"] == "0" assert response["status"] == "0"
# ua为空,os为web # ua为空,os为web
def test_ua_androidempty(): def test_ua_androidempty():
data[0]["device_info"]["ua"] = "" data[0]["device_info"]["ua"] = ""
...@@ -796,22 +797,20 @@ def test_ua_androidempty(): ...@@ -796,22 +797,20 @@ def test_ua_androidempty():
# ua为空,os为iOS # ua为空,os为iOS
def test_ua_iosempty(): def test_ua_iosempty():
data[0]["device_info"]["ua"] = "" data[0]["device_info"]["ua"] = ""
data[0]["device_info"]["os"] = 'ios' data[0]["device_info"]["os"] = '2'
data[0]["application_info"]["channel_name"] = 'default' data[0]["application_info"]["channel_name"] = 'default'
response = send_request() response = send_request()
assert response["status"] == "121" assert response["status"] == "121"
# ua不为空,但是是无法解析的ua # ua不为空,但是是无法解析的ua
def test_ua_androidempty(): def test_ua_androidempty():
data[0]["device_info"]["ua"] = "11111" data[0]["device_info"]["ua"] = "11111"
data[0]["device_info"]["os"] = 'web' data[0]["device_info"]["os"] = '4'
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
# os为android,att_status为空 # os为android,att_status为空
def test_uatt_statusempty(): def test_uatt_statusempty():
data[0]["device_info"]["att_status"] = "" data[0]["device_info"]["att_status"] = ""
...@@ -819,7 +818,6 @@ def test_uatt_statusempty(): ...@@ -819,7 +818,6 @@ def test_uatt_statusempty():
assert response["status"] == "0" assert response["status"] == "0"
# os为android,lat_status为空 # os为android,lat_status为空
def test_lat_statusempt(): def test_lat_statusempt():
data[0]["device_info"]["att_status"] = "" data[0]["device_info"]["att_status"] = ""
...@@ -827,7 +825,6 @@ def test_lat_statusempt(): ...@@ -827,7 +825,6 @@ def test_lat_statusempt():
assert response["status"] == "0" assert response["status"] == "0"
# oaid为空 # oaid为空
def test_oaidempty(): def test_oaidempty():
data[0]["device_info"]["oaid"] = "" data[0]["device_info"]["oaid"] = ""
...@@ -859,6 +856,7 @@ def test_oaid_md5_empty(): ...@@ -859,6 +856,7 @@ def test_oaid_md5_empty():
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
# ios系统,上报oaid,oaid_md5,imei1,imei1_md5,imei2,imei2_md5,gaid,gaid_md5,mac,mac_md5,android_id,android_id_md5,在"3237receiveios"脚本里 # ios系统,上报oaid,oaid_md5,imei1,imei1_md5,imei2,imei2_md5,gaid,gaid_md5,mac,mac_md5,android_id,android_id_md5,在"3237receiveios"脚本里
...@@ -1142,6 +1140,13 @@ def test_device_id_type_empty2(): ...@@ -1142,6 +1140,13 @@ def test_device_id_type_empty2():
assert response["status"] == "138" assert response["status"] == "138"
# device_id_type为one_id
def test_device_id_type_empty3():
data[0]["device_info"]["device_id_type"] = 'one_id'
response = send_request()
assert response["status"] == "0"
# device_id为空,device_id_md5不为空 # device_id为空,device_id_md5不为空
def test_device_idmd5_empty(): def test_device_idmd5_empty():
data[0]["device_info"]["device_id"] = '' data[0]["device_info"]["device_id"] = ''
...@@ -1306,21 +1311,21 @@ def test_event_type(): ...@@ -1306,21 +1311,21 @@ def test_event_type():
def test_event_data(): def test_event_data():
data[0]["event_info"]["event_data"] = "" data[0]["event_info"]["event_data"] = ""
response = send_request() response = send_request()
assert response["status"] == "145" assert response["status"] == "0"
# user_id为空 # user_id为空
def test_user_id1(): def test_user_id1():
data[0]["event_info"]["event_data"]['user_id'] = "" data[0]["event_info"]["event_data"]['user_id'] = ""
response = send_request() response = send_request()
assert response["status"] == "146" assert response["status"] == "0"
# user_id超长 # user_id超长
def test_user_id2(): def test_user_id2():
data[0]["event_info"]["event_data"]['user_id'] = chaochang data[0]["event_info"]["event_data"]['user_id'] = chaochang
response = send_request() response = send_request()
assert response["status"] == "146" assert response["status"] == "0"
# 事件为install时,user_id为-1 # 事件为install时,user_id为-1
...@@ -1343,7 +1348,7 @@ def test_user_id4(): ...@@ -1343,7 +1348,7 @@ def test_user_id4():
def test_register_type1(): def test_register_type1():
data[0]["event_info"]["event_data"]['register_type'] = chaochang data[0]["event_info"]["event_data"]['register_type'] = chaochang
response = send_request() response = send_request()
assert response["status"] == "147" assert response["status"] == "0"
# event_name为register,register_type为空 # event_name为register,register_type为空
...@@ -1351,7 +1356,7 @@ def test_register_type2(): ...@@ -1351,7 +1356,7 @@ def test_register_type2():
data[0]["event_info"]["event_data"]['register_type'] = "" data[0]["event_info"]["event_data"]['register_type'] = ""
data[0]['event_info']['event_name'] = 'register' data[0]['event_info']['event_name'] = 'register'
response = send_request() response = send_request()
assert response["status"] == "147" assert response["status"] == "0"
# event_name为register,register_type不为空 # event_name为register,register_type不为空
...@@ -1389,7 +1394,7 @@ def test_register_type5(): ...@@ -1389,7 +1394,7 @@ def test_register_type5():
def test_login_type1(): def test_login_type1():
data[0]["event_info"]["event_data"]['login_type'] = chaochang data[0]["event_info"]["event_data"]['login_type'] = chaochang
response = send_request() response = send_request()
assert response["status"] == "148" assert response["status"] == "0"
# event_name为login,login_type为空 # event_name为login,login_type为空
...@@ -1397,7 +1402,7 @@ def test_login_type2(): ...@@ -1397,7 +1402,7 @@ def test_login_type2():
data[0]["event_info"]["event_data"]['login_type'] = "" data[0]["event_info"]["event_data"]['login_type'] = ""
data[0]['event_info']['event_name'] = 'login' data[0]['event_info']['event_name'] = 'login'
response = send_request() response = send_request()
assert response["status"] == "148" assert response["status"] == "0"
# event_name为login,login_type不为空 # event_name为login,login_type不为空
...@@ -1436,7 +1441,7 @@ def test_login_type5(): ...@@ -1436,7 +1441,7 @@ def test_login_type5():
def test_order_id1(): def test_order_id1():
data[0]["event_info"]["event_data"]['order_id'] = chaochang data[0]["event_info"]["event_data"]['order_id'] = chaochang
response = send_request() response = send_request()
assert response["status"] == "149" assert response["status"] == "0"
# event_name为order,order_id为空 # event_name为order,order_id为空
...@@ -1444,7 +1449,7 @@ def test_order_id2(): ...@@ -1444,7 +1449,7 @@ def test_order_id2():
data[0]["event_info"]["event_data"]['order_id'] = "" data[0]["event_info"]["event_data"]['order_id'] = ""
data[0]['event_info']['event_name'] = 'order' data[0]['event_info']['event_name'] = 'order'
response = send_request() response = send_request()
assert response["status"] == "149" assert response["status"] == "0"
# event_name为order,order_id不为空 # event_name为order,order_id不为空
...@@ -1482,14 +1487,14 @@ def test_order_id6(): ...@@ -1482,14 +1487,14 @@ def test_order_id6():
data[0]["event_info"]["event_data"]['order_id'] = "" data[0]["event_info"]["event_data"]['order_id'] = ""
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "149" assert response["status"] == "0"
# order_amount非0以及正整数 # order_amount非0以及正整数
def test_order_amount1(): def test_order_amount1():
data[0]["event_info"]["event_data"]['order_amount'] = "23.232131" data[0]["event_info"]["event_data"]['order_amount'] = "23.232131"
response = send_request() response = send_request()
assert response["status"] == "150" assert response["status"] == "0"
# event_name为order,order_amount为空 # event_name为order,order_amount为空
...@@ -1497,7 +1502,7 @@ def test_order_amount2(): ...@@ -1497,7 +1502,7 @@ def test_order_amount2():
data[0]["event_info"]["event_data"]['order_amount'] = "" data[0]["event_info"]["event_data"]['order_amount'] = ""
data[0]['event_info']['event_name'] = 'order' data[0]['event_info']['event_name'] = 'order'
response = send_request() response = send_request()
assert response["status"] == "150" assert response["status"] == "0"
# event_name为order,order_amount不为空 # event_name为order,order_amount不为空
...@@ -1535,7 +1540,7 @@ def test_order_amount6(): ...@@ -1535,7 +1540,7 @@ def test_order_amount6():
data[0]["event_info"]["event_data"]['order_amount'] = "" data[0]["event_info"]["event_data"]['order_amount'] = ""
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "150" assert response["status"] == "0"
# event_name为purchase,order_amount不为空 # event_name为purchase,order_amount不为空
...@@ -1551,7 +1556,7 @@ def test_currency_type1(): ...@@ -1551,7 +1556,7 @@ def test_currency_type1():
data[0]['event_info']['event_data']['currency_type'] = '' data[0]['event_info']['event_data']['currency_type'] = ''
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "151" assert response["status"] == "0"
# event_name为purchase,currency_type不为空 # event_name为purchase,currency_type不为空
...@@ -1567,7 +1572,7 @@ def test_currency_type3(): ...@@ -1567,7 +1572,7 @@ def test_currency_type3():
data[0]['event_info']['event_data']['currency_type'] = 'aa' data[0]['event_info']['event_data']['currency_type'] = 'aa'
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "151" assert response["status"] == "0"
# event_name为非purchase,currency_type为空 # event_name为非purchase,currency_type为空
...@@ -1585,7 +1590,7 @@ def test_purchase_type1(): ...@@ -1585,7 +1590,7 @@ def test_purchase_type1():
data[0]['event_info']['event_data']['purchase_type'] = '' data[0]['event_info']['event_data']['purchase_type'] = ''
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "152" assert response["status"] == "0"
# event_name为purchase,purchase_type不为空 # event_name为purchase,purchase_type不为空
...@@ -1611,7 +1616,7 @@ def test_purchase_type4(): ...@@ -1611,7 +1616,7 @@ def test_purchase_type4():
data[0]['event_info']['event_data']['purchase_type'] = chaochang data[0]['event_info']['event_data']['purchase_type'] = chaochang
data[0]['event_info']['event_name'] = 'purchase' data[0]['event_info']['event_name'] = 'purchase'
response = send_request() response = send_request()
assert response["status"] == "152" assert response["status"] == "0"
# event_name为adimpression和adclick,ad_platform为空 # event_name为adimpression和adclick,ad_platform为空
...@@ -1621,7 +1626,7 @@ def test_ad_platform1(): ...@@ -1621,7 +1626,7 @@ def test_ad_platform1():
data[0]["event_info"]['event_data']['ad_platform'] = '' data[0]["event_info"]['event_data']['ad_platform'] = ''
data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
response = send_request() response = send_request()
assert response["status"] == "153" assert response["status"] == "0"
# event_name为adimpression和adclick,ad_platform不为空 # event_name为adimpression和adclick,ad_platform不为空
...@@ -1659,7 +1664,7 @@ def test_ad_platform5(): ...@@ -1659,7 +1664,7 @@ def test_ad_platform5():
data[0]["event_info"]['event_data']['ad_platform'] = chaochang data[0]["event_info"]['event_data']['ad_platform'] = chaochang
data[0]['event_info']['event_name'] = "adclick" data[0]['event_info']['event_name'] = "adclick"
response = send_request() response = send_request()
assert response["status"] == "153" assert response["status"] == "0"
# # event_name为adimpression和adclick,placement_type为空 # # event_name为adimpression和adclick,placement_type为空
...@@ -1669,7 +1674,7 @@ def test_placement_type1(): ...@@ -1669,7 +1674,7 @@ def test_placement_type1():
data[0]["event_info"]['event_data']['placement_type'] = '' data[0]["event_info"]['event_data']['placement_type'] = ''
data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
response = send_request() response = send_request()
assert response["status"] == "154" assert response["status"] == "0"
# # event_name为adimpression和adclick,placement_type不为空 # # event_name为adimpression和adclick,placement_type不为空
...@@ -1717,7 +1722,7 @@ def test_placement_id1(): ...@@ -1717,7 +1722,7 @@ def test_placement_id1():
data[0]["event_info"]['event_data']['placement_id'] = '' data[0]["event_info"]['event_data']['placement_id'] = ''
data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
response = send_request() response = send_request()
assert response["status"] == "155" assert response["status"] == "0"
# # event_name为adimpression和adclick,placement_id不为空 # # event_name为adimpression和adclick,placement_id不为空
...@@ -1755,18 +1760,18 @@ def test_placement_type5(): ...@@ -1755,18 +1760,18 @@ def test_placement_type5():
data[0]["event_info"]['event_data']['placement_id'] = chaochang data[0]["event_info"]['event_data']['placement_id'] = chaochang
data[0]['event_info']['event_name'] = "adclick" data[0]['event_info']['event_name'] = "adclick"
response = send_request() response = send_request()
assert response["status"] == "155" assert response["status"] == "0"
# event_name为adimpression,ad_price为空 # event_name为adimpression,ad_ecpm为空,返回0
def test_ad_price1(): def test_ad_price1():
data[0]["event_info"]['event_data']['ad_ecpm'] = '' data[0]["event_info"]['event_data']['ad_ecpm'] = ''
data[0]['event_info']['event_name'] = 'adimpression' data[0]['event_info']['event_name'] = 'adimpression'
response = send_request() response = send_request()
assert response["status"] == "156" assert response["status"] == "0"
# event_name为adimpression,ad_price不为空 # event_name为adimpression,ad_ecpm不为空
def test_ad_price2(): def test_ad_price2():
data[0]["event_info"]['event_data']['ad_ecpm'] = '765453434' data[0]["event_info"]['event_data']['ad_ecpm'] = '765453434'
data[0]['event_info']['event_name'] = 'adimpression' data[0]['event_info']['event_name'] = 'adimpression'
...@@ -1774,7 +1779,7 @@ def test_ad_price2(): ...@@ -1774,7 +1779,7 @@ def test_ad_price2():
assert response["status"] == "0" assert response["status"] == "0"
# event_name非adimpression,ad_price为空 # event_name非adimpression,ad_ecpm为空
def test_ad_price3(): def test_ad_price3():
newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick'] newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
for event in newlist: for event in newlist:
...@@ -1784,7 +1789,7 @@ def test_ad_price3(): ...@@ -1784,7 +1789,7 @@ def test_ad_price3():
assert response["status"] == "0" assert response["status"] == "0"
# event_name非adimpression,ad_price不为空 # event_name非adimpression,ad_ecpm不为空
def test_ad_price4(): def test_ad_price4():
newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick'] newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
for event in newlist: for event in newlist:
...@@ -1794,12 +1799,13 @@ def test_ad_price4(): ...@@ -1794,12 +1799,13 @@ def test_ad_price4():
assert response["status"] == "0" assert response["status"] == "0"
# ad_price超长 # ad_ecpm超长,返回0
def test_ad_price5(): def test_ad_price5():
data[0]["event_info"]['event_data']['ad_ecpm'] = chaochang data[0]["event_info"]['event_data']['ad_ecpm'] = chaochang
data[0]['event_info']['event_name'] = "adimpression" data[0]['event_info']['event_name'] = "adimpression"
response = send_request() response = send_request()
assert response["status"] == "156" assert response["status"] == "0"
# -------------------receive接口迭代------------- # -------------------receive接口迭代-------------
# # event_name为adimpression,ad_price_currency_type为空 # # event_name为adimpression,ad_price_currency_type为空
...@@ -1871,7 +1877,7 @@ def test_is_rendered3(): ...@@ -1871,7 +1877,7 @@ def test_is_rendered3():
def test_is_rendered3(): def test_is_rendered3():
data[0]['event_info']['event_data']['is_rendered'] = 'qqq' data[0]['event_info']['event_data']['is_rendered'] = 'qqq'
response = send_request() response = send_request()
assert response["status"] == "158" assert response["status"] == "0"
# custom_params为空,已在postman执行 # custom_params为空,已在postman执行
...@@ -1945,6 +1951,254 @@ def test_custom_params3(): ...@@ -1945,6 +1951,254 @@ def test_custom_params3():
# response = send_request() # response = send_request()
# assert response["status"] == "0" # assert response["status"] == "0"
# country为空
def test_country1():
data[0]['timestamp_info']['country'] = ''
response = send_request()
assert response["status"] == "216"
# country为16个字符
def test_country2():
data[0]['timestamp_info']['country'] = code_nums(16)
response = send_request()
assert response["status"] == "0"
# country为17个字符
def test_country3():
data[0]['timestamp_info']['country'] = code_nums(17)
response = send_request()
assert response["status"] == "216"
# country包含特殊字符
def test_country4():
data[0]['timestamp_info']['country'] = '312@!#@!三大程'
response = send_request()
assert response["status"] == "0"
# language为空
def test_language1():
data[0]['device_info']['language'] = ''
response = send_request()
assert response["status"] == "0"
# language为32字符
def test_language2():
data[0]['device_info']['language'] = code_nums2(32)
response = send_request()
assert response["status"] == "0"
# language为33字符
def test_language3():
data[0]['device_info']['language'] = code_nums2(33)
response = send_request()
assert response["status"] == "217"
# language包含中文
def test_language4():
data[0]['device_info']['language'] = '测试测试语言'
response = send_request()
assert response["status"] == "0"
# language包含特殊字符
def test_language5():
data[0]['device_info']['language'] = '测试测试语@#¥言'
response = send_request()
assert response["status"] == "0"
# device_type为空
def test_device_type1():
data[0]['device_info']['device_type'] = ''
response = send_request()
assert response["status"] == "0"
# device_type为16字符
def test_device_type2():
data[0]['device_info']['device_type'] = code_nums2(16)
response = send_request()
assert response["status"] == "0"
# device_type为17字符
def test_device_type3():
data[0]['device_info']['device_type'] = code_nums2(17)
response = send_request()
assert response["status"] == "218"
# device_type包含中文
def test_device_type4():
data[0]['device_info']['device_type'] = '测试测试语言'
response = send_request()
assert response["status"] == "0"
# device_type包含特殊字符
def test_device_type5():
data[0]['device_info']['device_type'] = '测试测试语@#¥言'
response = send_request()
assert response["status"] == "0"
# device_type为15字符
def test_device_type6():
data[0]['device_info']['device_type'] = code_nums2(15)
response = send_request()
assert response["status"] == "0"
# device_type为15字符
def test_device_type6():
data[0]['device_info']['device_type'] = code_nums2(15)
response = send_request()
assert response["status"] == "0"
# ad_id为空
def test_ad_id1():
data[0]['event_info']['event_data']['ad_id'] = ''
response = send_request()
assert response["status"] == "0"
# ad_id为100字符
def test_ad_id2():
data[0]['event_info']['event_data']['ad_id'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# ad_id包含特殊字符和汉字
def test_ad_id3():
data[0]['event_info']['event_data']['ad_id'] = '测试#@#'
response = send_request()
assert response["status"] == "0"
# ad_appid为空
def test_ad_appid1():
data[0]['event_info']['event_data']['ad_appid'] = ''
response = send_request()
assert response["status"] == "0"
# ad_appid为100字符
def test_ad_appid2():
data[0]['event_info']['event_data']['ad_appid'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# ad_appid包含特殊字符和汉字
def test_ad_appid3():
data[0]['event_info']['event_data']['ad_appid'] = '测试#@#'
response = send_request()
assert response["status"] == "0"
# product_name为空
def test_product_name1():
data[0]['event_info']['event_data']['product_name'] = ''
response = send_request()
assert response["status"] == "0"
# product_name为100字符
def test_product_name2():
data[0]['event_info']['event_data']['product_name'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# product_name包含特殊字符和汉字
def test_product_name3():
data[0]['event_info']['event_data']['product_name'] = '测试#@_+#'
response = send_request()
assert response["status"] == "0"
# product_id为空
def test_product_id1():
data[0]['event_info']['event_data']['product_id'] = ''
response = send_request()
assert response["status"] == "0"
# product_id为100字符
def test_product_id2():
data[0]['event_info']['event_data']['product_id'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# product_id包含特殊字符和汉字
def test_product_id3():
data[0]['event_info']['event_data']['product_id'] = '测试#@_+#'
response = send_request()
assert response["status"] == "0"
# product_num为空
def test_product_num1():
data[0]['event_info']['event_data']['product_num'] = ''
response = send_request()
assert response["status"] == "0"
# product_num为100字符
def test_product_num2():
data[0]['event_info']['event_data']['product_num'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# product_num包含特殊字符和汉字
def test_product_num3():
data[0]['event_info']['event_data']['product_num'] = '测试#@_+#'
response = send_request()
assert response["status"] == "0"
# product_num为number类型
def test_product_num4():
data[0]['event_info']['event_data']['product_num'] = 232
response = send_request()
assert response["status"] == "0"
# bid_type为空
def test_bid_type1():
data[0]['event_info']['event_data']['bid_type'] = ''
response = send_request()
assert response["status"] == "0"
# bid_type为100字符
def test_bid_type2():
data[0]['event_info']['event_data']['bid_type'] = code_nums2(100)
response = send_request()
assert response["status"] == "0"
# bid_type包含特殊字符和汉字
def test_bid_type3():
data[0]['event_info']['event_data']['bid_type'] = '测试#@_+#'
response = send_request()
assert response["status"] == "0"
......
...@@ -17,12 +17,13 @@ data = [ ...@@ -17,12 +17,13 @@ data = [
"application_info": { "application_info": {
# 线上-55705dbd45dd246751b87bba94b8c73c # 线上-55705dbd45dd246751b87bba94b8c73c
# 测试-55705dbd45dd246751b87bba94b8c73c # 测试-55705dbd45dd246751b87bba94b8c73c
"appkey": "55705dbd45dd246751b87bba94b8c73c", "appkey": "904305d99f74ce0349b11238f3eeff69",
"bundleid": "3423232", "bundleid": "3423232",
"app_version": "1.9.0", "app_version": "1.9.0",
"channel_name": "default" "channel_name": "default"
}, },
"timestamp_info": { "timestamp_info": {
"country": "chi",
"time_zone": "GMT+08", "time_zone": "GMT+08",
"install_time": int(round(time.time() * 1000)), "install_time": int(round(time.time() * 1000)),
"current_event_time": int(round(time.time() * 1000)), "current_event_time": int(round(time.time() * 1000)),
...@@ -39,7 +40,7 @@ data = [ ...@@ -39,7 +40,7 @@ data = [
"device_id_type": "idfa_md5", "device_id_type": "idfa_md5",
"device_id_md5": "c3381276ae145b3663c8e0f6dd9f628a", "device_id_md5": "c3381276ae145b3663c8e0f6dd9f628a",
"device_id_md5_type": "idfa_md5", "device_id_md5_type": "idfa_md5",
"os": "ios", "os": "2",
"os_version": "19", "os_version": "19",
"manufacturer": "HUAWEI", "manufacturer": "HUAWEI",
"model": "Mate 40", "model": "Mate 40",
...@@ -79,6 +80,65 @@ data = [ ...@@ -79,6 +80,65 @@ data = [
# "refund": "234234", # "refund": "234234",
# "refund_amount": "234234" # "refund_amount": "234234"
} }
},
"asa_info": {
"iad_info": {
# //iad归因结果。选传,限制16字符内。
"iad-attribution": "true",
# //iad 活动组名称。选传,限制128字符内。
"iad-org-name": "org name",
# //iad 活动组id,选传。限制32字符内。
"iad-org-id": "40669820",
# //iad 活动id,选传。限制32字符内。
"iad-campaign-id": "542370539",
# // iad 活动名称。选传,限制128字符内。
"iad-campaign-name": "campaign name",
# //iad 该Apple账号首次购买(下载)该App的时间。选传,限制32字符内。
"iad-purchase-date": "2020-08-04T17:18:07Z",
# //iad 该Apple账号本次转化(下载)该App的时间。选传,限制32字符内。
"iad-conversion-date": "2020-08-04T17:18:07Z",
# //iad 转化配型。选传,限制32字符内。
"iad-conversion-type": "newdownload",
# //iad 本次转化匹配到广告点击的时间。选传,限制32字符内。
"iad-click-date": "2020-08-04T17:17:00Z",
# // iad 广告组id。选传,限制32字符内。
"iad-adgroup-id": "542317095",
# //iad 广告组名称。选传,限制128字符内。
"iad-adgroup-name": "adgroup name",
# //iad Apple账号的国家或地区。选传,限制16字符内。
"iad-country-or-region": "US",
# //iad 关键词名称。选传,限制128字符内。
"iad-keyword": "keyword",
# //iad 关键词id。选传,限制32字符内。
"iad-keyword-id": "87675432",
# //iad 关键词匹配类型。选传,限制32字符内。
"iad-keyword-matchtype": "Broad",
# //iad 广告素材id。选传,限制32字符内。
"iad-ad-id": "542317136",
# //iad lineitem id。选传,限制32字符内。
"iad-lineitem-id": "587848614",
# //iad lineitem名称。选传,限制128字符内。
"iad-lineitem-name": "Brand-Exact_All-All_Test02",
# //通过iad框架获取归因信息时的重试次数。选传,限制2字符内。
"iad_retry_times": 3,
# //任何能够描述未能获取到归因结果的错误提示。选传,无字符限制。
"iad_error_info": "xxx"
},
"adservices_info": {
"token": "sbBoZZnCpY3Ps32Xv8K5PhyZtPKxB8i/rmjJfWATPQAuqawcQLalTgJ4Zaa4LzZohZK/bWxWg3TmynLv3XKAO+oTbn7FGmSdYAAAAVADAAAA/QAAAIAjeU4Eb6GRAsnafeLL8Ucpfzz5ErqPpxV4n5SoZ6n3q9U8tYixHXKsOcSFnEjBVYNX60xFABXS62TzYQieVzkjt4vjC6GYedWDX+IuYx7K4p6iUvUg5FAhX6kSeVF627i2Xj6Ie5K7Xi3LSM8uNWvADZQESKvdkWF9CQoNY37dEgAAABJfluG0V1jsF3OcqXJPotzTE1YAAACfAe5iGXrTDo893L1XIXjACtCXvdjaAAAAhgAGP0aWIK/sat96xlkNAzEZ8WJd/AGhKQCKZ7dTc+NvyRyic1WsAryc6dkpfhzKUot2l9wrft8I/+dRLggPPFGTTmgdXzaabldMH4iVdaIRDtVQPsxTQw1naa1ainIrehF/VXVsUgngZ0ONhi01Bqw75hq2yuyWRGb1CXkm0dlCtR8L8DVXAAAAAAAAAAAAAAAAAAABBEYXAAA=",
"attribution": 'true',
"orgId": 40669820,
"campaignId": 542370539,
"conversionType": "Download",
"clickDate": "2020-04-08T17:17Z",
"adGroupId": 542317095,
"countryOrRegion": "US",
"keywordId": 87675432,
"adId": 542317136,
"adservices_retry_times": 3,
"adservices_error_info": "xxx"
}
} }
} }
] ]
...@@ -87,10 +147,12 @@ data_temp = json.dumps(data) ...@@ -87,10 +147,12 @@ data_temp = json.dumps(data)
def send_request(): def send_request():
global data 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://tkiomicro-receive-788931749.cn-north-1.elb.amazonaws.com.cn/receive/tkiov2/sdk"
# 线上 # 线上
url = "http://tkio-receive.solar-engine.com/receive/tkiov2/sdk" # url = "http://tkio-receive.solar-engine.com/receive/tkiov2/sdk"
data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000)) data[0]['timestamp_info']['install_time'] = int(round(time.time() * 1000))
data[0]['timestamp_info']['current_event_time'] = int(round(time.time() * 1000)) data[0]['timestamp_info']['current_event_time'] = int(round(time.time() * 1000))
...@@ -123,6 +185,22 @@ def send_request2(): ...@@ -123,6 +185,22 @@ def send_request2():
return response return response
# iad_retry_times为num型,应该返回214,但是实时接收时接收到的是string类型,无法判断number
def test_se1():
data[0]["asa_info"]["iad_info"]['iad_retry_times'] = 3
response = send_request()
assert response["status"] == "0"
# iad_retry_times为num型,同上test_se1
def test_se2():
data[0]["asa_info"]["adservices_info"]['adservices_retry_times'] = 3
response = send_request()
assert response["status"] == "0"
# os为ios,channel_name不等于default # os为ios,channel_name不等于default
def test_os_ios(): def test_os_ios():
data[0]["device_info"]["os"] = 'ios' data[0]["device_info"]["os"] = 'ios'
......
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