Commit 36dc680b by liuxiaoxing

Revert: receive 对接se

parent e2b61a62
import random
import requests import requests
import json import json
import pytest import pytest
import time 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字符 # 153字符
chaochang = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132' chaochang = '543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132543214223221321321312131313133132131232131232132132'
...@@ -32,13 +17,12 @@ data = [ ...@@ -32,13 +17,12 @@ data = [
"application_info": { "application_info": {
# 线上-a8ed96ae9051499fd98bc46ab9c9495c # 线上-a8ed96ae9051499fd98bc46ab9c9495c
# 测试-decbeb4d840b4bcd1a068ca7233e6ac2 # 测试-decbeb4d840b4bcd1a068ca7233e6ac2
"appkey": "904305d99f74ce0349b11238f3eeff69", "appkey": "a8ed96ae9051499fd98bc46ab9c9495c",
"bundleid": "3423232", "bundleid": "3423232",
"app_version": "1.9.0", "app_version": "1.9.0",
"channel_name": "HUAWEI" "channel_name": "HUAWEI"
}, },
"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)),
...@@ -55,7 +39,7 @@ data = [ ...@@ -55,7 +39,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": "android",
"os_version": "19", "os_version": "19",
"manufacturer": "HUAWEI", "manufacturer": "HUAWEI",
"model": "Mate 40", "model": "Mate 40",
...@@ -85,14 +69,14 @@ data = [ ...@@ -85,14 +69,14 @@ data = [
"register_type": "WeChat", "register_type": "WeChat",
"login_type": "Wechat", "login_type": "Wechat",
"order_id": "2341242342676398724", "order_id": "2341242342676398724",
"order_amount": "30", "order_amount": "343432",
"currency_type": "CNY", "currency_type": "CNY",
"purchase_type": "Alipay", "purchase_type": "Alipay",
"ad_platform": "csj", "ad_platform": "csj",
"placement_type": "interstitial", "placement_type": "interstitial",
"placement_id": "23425334", "placement_id": "23425334",
"ad_ecpm": "4.34", "ad_price": "4.34",
# "ad_price_currency_type": "CNY", "ad_price_currency_type": "CNY",
"is_rendered": "1" "is_rendered": "1"
}, },
"custom_params": { "custom_params": {
...@@ -116,13 +100,9 @@ data_temp = json.dumps(data) ...@@ -116,13 +100,9 @@ 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))
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)
...@@ -298,18 +278,19 @@ def test_timestamp_info_empty(): ...@@ -298,18 +278,19 @@ 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接口迭代-----------
# 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个字符
...@@ -340,43 +321,13 @@ def test_time_zone4(): ...@@ -340,43 +321,13 @@ def test_time_zone4():
assert response["status"] == "106" assert response["status"] == "106"
# time_zone为17字符,返回106 # install_time为空
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
def test_install_time_empty(): def test_install_time_empty():
data[0]["timestamp_info"]["install_time"] = "" data[0]["timestamp_info"]["install_time"] = ""
data[0]["event_info"]["event_name"] = "install"
response = send_request() response = send_request()
assert response["status"] == "107" 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个字符 # 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
...@@ -1760,7 +1711,7 @@ def test_placement_type5(): ...@@ -1760,7 +1711,7 @@ def test_placement_type5():
# event_name为adimpression,ad_price为空 # event_name为adimpression,ad_price为空
def test_ad_price1(): 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' data[0]['event_info']['event_name'] = 'adimpression'
response = send_request() response = send_request()
assert response["status"] == "156" assert response["status"] == "156"
...@@ -1768,7 +1719,7 @@ def test_ad_price1(): ...@@ -1768,7 +1719,7 @@ def test_ad_price1():
# event_name为adimpression,ad_price不为空 # event_name为adimpression,ad_price不为空
def test_ad_price2(): 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' data[0]['event_info']['event_name'] = 'adimpression'
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
...@@ -1778,7 +1729,7 @@ def test_ad_price2(): ...@@ -1778,7 +1729,7 @@ def test_ad_price2():
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:
data[0]["event_info"]['event_data']['ad_ecpm'] = '' data[0]["event_info"]['event_data']['ad_price'] = ''
data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
...@@ -1788,7 +1739,7 @@ def test_ad_price3(): ...@@ -1788,7 +1739,7 @@ def test_ad_price3():
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:
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 data[0]['event_info']['event_name'] = event
response = send_request() response = send_request()
assert response["status"] == "0" assert response["status"] == "0"
...@@ -1796,54 +1747,54 @@ def test_ad_price4(): ...@@ -1796,54 +1747,54 @@ def test_ad_price4():
# ad_price超长 # ad_price超长
def test_ad_price5(): 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" data[0]['event_info']['event_name'] = "adimpression"
response = send_request() response = send_request()
assert response["status"] == "156" assert response["status"] == "156"
# -------------------receive接口迭代-------------
# # event_name为adimpression,ad_price_currency_type为空 # event_name为adimpression,ad_price_currency_type为空
# def test_ad_price_currency_type1(): def test_ad_price_currency_type1():
# data[0]["event_info"]['event_data']['ad_price_currency_type'] = '' data[0]["event_info"]['event_data']['ad_price_currency_type'] = ''
# data[0]['event_info']['event_name'] = 'adimpression' data[0]['event_info']['event_name'] = 'adimpression'
# response = send_request() response = send_request()
# assert response["status"] == "157" assert response["status"] == "157"
#
#
# # event_name为adimpression,ad_price_currency_type不为空 # event_name为adimpression,ad_price_currency_type不为空
# def test_ad_price_currency_type2(): def test_ad_price_currency_type2():
# data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY' data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY'
# data[0]['event_info']['event_name'] = 'adimpression' data[0]['event_info']['event_name'] = 'adimpression'
# response = send_request() response = send_request()
# assert response["status"] == "0" assert response["status"] == "0"
#
#
# # event_name非adimpression,ad_price_currency_type为空 # event_name非adimpression,ad_price_currency_type为空
# def test_ad_price_currency_type3(): def test_ad_price_currency_type3():
# newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick'] newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
# for event in newlist: for event in newlist:
# data[0]["event_info"]['event_data']['ad_price_currency_type'] = '' data[0]["event_info"]['event_data']['ad_price_currency_type'] = ''
# data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
# response = send_request() response = send_request()
# assert response["status"] == "0" assert response["status"] == "0"
#
#
# # event_name非adimpression,ad_price_currency_type不为空 # event_name非adimpression,ad_price_currency_type不为空
# def test_ad_price_currency_type4(): def test_ad_price_currency_type4():
# newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick'] newlist = ['install', 'startup', 'register', 'login', 'order', 'purchase', 'adclick']
# for event in newlist: for event in newlist:
# data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY' data[0]["event_info"]['event_data']['ad_price_currency_type'] = 'CNY'
# data[0]['event_info']['event_name'] = event data[0]['event_info']['event_name'] = event
# response = send_request() response = send_request()
# assert response["status"] == "0" assert response["status"] == "0"
#
#
# # ad_price_currency_type非三个字符 # ad_price_currency_type非三个字符
# def test_ad_price_currency_type5(): def test_ad_price_currency_type5():
# data[0]["event_info"]['event_data']['ad_price_currency_type'] = "0" data[0]["event_info"]['event_data']['ad_price_currency_type'] = "0"
# data[0]['event_info']['event_name'] = "adimpression" data[0]['event_info']['event_name'] = "adimpression"
# response = send_request() response = send_request()
# assert response["status"] == "157" assert response["status"] == "157"
# is_rendered为空 # is_rendered为空
......
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