Commit 12826e40 by zhaihuitao

添加base_event

parent 004fc5ba
# -*- coding: utf-8 -*-
"""
@author:zhaiht
@file: randomUtil.py
@time: 2020/8/7 15:23
@desc:
"""
import struct
import socket
import random
class randomUtil:
def randip(self):
ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
return ip
def randimei(self):
i = ''.join(str(random.choice(range(10))) for _ in range(12))
return i
r = randomUtil()
\ No newline at end of file
......@@ -5,33 +5,64 @@
@time: 2020/8/6 17:34
@desc:
"""
from numpy import long
# 测试环境:
from common import randomUtil
import time
# 生产环境:
prod = {
"click": {
"url": "http://t.uri6.com/tkio/EFbIzya",
"url": "http://t.uri6.com/tkio/EFbIzya?noredirect=true",
"appkey": "9b17c1568c3ce34599c5fd2778483ff9"
},
"events":{
"events": {
"url": "http://t.uri6.com/tkio/EFbIzya",
"appkey": "9b17c1568c3ce34599c5fd2778483ff9"
}
"appkey": "9b17c1568c3ce34599c5fd2778483ff9",
},
}
prod_params = {
# 'androidid': "43214532142142",
'imei': i,
# "idfa": 'DBC13622-E34B-440C-B7A7-FB6641D0D9AB',
'ip': ip,
# "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)
# Version/5.1 Mobile/9A334 Safari/7534.48.3", 'creativeId':'21321321312123', 'requestId':'312321321312',
# 'adId': long('21231'), 'ry_adgroup_name': ry_adgroup_name, 'ry_adplan_name': ry_adplan_name,
# 'ry_adcreative_name': ry_adcreative_name,
"ry_adgroup_id": ry_adgroup_id,
"ry_adplan_id": ry_adplan_id,
"ry_adcreative_id": ry_adcreative_id,
}
\ No newline at end of file
'androidid': "43214532142142",
'imei': randomUtil.r.randimei(),
"idfa": 'DBC13622-E34B-440C-B7A7-FB6641D0D9AB',
'ip': randomUtil.r.randip(),
"ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)Version/5.1 "
"Mobile/9A334 Safari/7534.48.3", 'creativeId': '21321321312123', 'requestId': '312321321312',
'adId': long('21231'),
'ry_adgroup_name': "头条广告组2",
'ry_adplan_name': "头条广告计划2",
'ry_adcreative_name': "头条广告名称2",
"ry_adgroup_id": 999,
"ry_adplan_id": 999,
"ry_adcreative_id": 999,
"appduration": 10,
"pageduration": 1000,
"istablet": "istablet",
"lib": "IOS",
"when1": "'2020-06-06 16:44:31'",
"model": "测试1",
"ryosversion": "10.0.0",
"network_type": "5G",
"carrier": "中国联通",
"lv": "1.5.0",
"cmpaignid": 3333,
"current_time_13": int(round(time.time() * 1000)),
"when": time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time())),
"ds": time.strftime('%Y-%m-%d', time.localtime(time.time())),
"manufacturer": "VIVO",
"ryos": "android",
"rydevicetype": "vivox9",
"network": "wifi",
"resolution": "1344*750",
"op": "中国移动",
# 支付类型 支付宝(alipay),银联(unionpay),微信支付(weixinpay),易宝支付(yeepay)
"paymenttype": "alipay",
"currencytype": "CNY",
"currencyamount": 10,
"adid": 839296815,
# 填充广告的变现平台,例如穿山甲(csj)、优量汇(ylh)、百青藤(bqt)、Sigmob(sigmob)、快手(ks)、Mintegral(mintegral)、OneWay(oneway)、Vungle(vungle)等
"adPlatform": "mintegral"
}
print(prod_params['carrier'])
\ No newline at end of file
# -*- coding: utf-8 -*-
"""
@author:zhaiht
@file: baseEvent.py
@time: 2020/8/7 17:45
@desc:
"""
......@@ -10,6 +10,8 @@ import random
import socket
import struct
from config.envcfg import prod
from common import randomUtil
from config.envcfg import prod_params
import sys
import requests
......@@ -37,17 +39,17 @@ w = 0
for _ in range(1):
#随机生成12为数组
i = ''.join(str(random.choice(range(10))) for _ in range(12))
# i = ''.join(str(random.choice(range(10))) for _ in range(12))
# i = '167070728336'
#随机生成ip
ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
# ip = socket.inet_ntoa(struct.pack('>I', random.randint(1, 0xffffffff)))
# ip = '175.93.28.70'
try:
parms = {
'''parms = {
# 'androidid': "43214532142142",
'imei': i,
'imei': randomUtil.r.randimei(),
# "idfa": 'DBC13622-E34B-440C-B7A7-FB6641D0D9AB',
'ip': ip,
'ip': randomUtil.r.randip(),
# "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)
# Version/5.1 Mobile/9A334 Safari/7534.48.3", 'creativeId':'21321321312123', 'requestId':'312321321312',
# 'adId': long('21231'), 'ry_adgroup_name': ry_adgroup_name, 'ry_adplan_name': ry_adplan_name,
......@@ -55,28 +57,25 @@ for _ in range(1):
"ry_adgroup_id": ry_adgroup_id,
"ry_adplan_id": ry_adplan_id,
"ry_adcreative_id": ry_adcreative_id,
}
}'''
#timeout可以超时四秒
# verify = False
print(prod['click']['url'])
p = requests.get(url=prod['click']['url'], params=parms, timeout=30, verify= False)
p = requests.get(url=prod['click']['url'], params=prod_params, timeout=30, verify=False)
print('success:',s)
print('success:', s)
# print(p.text)
print('imei:',i)
#print('ip:',ip)
s=s+1
print('imei:',randomUtil.r.randimei())
except requests.exceptions.RequestException:
print('wrong:',w)
print('imei:', i)
print('ip', ip)
print('imei:', randomUtil.r.randimei())
print('ip', randomUtil.r.randip())
w=w+1
continue
# time.sleep(7)
# try:
# allEvent().installUpload(i, ip, appkey, cmpaignid)
allEvent().installUpload(i, ip, appkey, cmpaignid)
# except Exception as err:
# print('install_wrong:', w)
# w = w + 1
......
......@@ -7,16 +7,58 @@
"""
import unittest
import random
import time
from config.envcfg import prod
from common import randomUtil
from config.envcfg import prod_params
import sys
import requests
import socket
import struct
import yaml
import os
import sys
base_path = os.getcwd()
sys.path.append(base_path)
class clickTestCase(unittest.TestCase):
def click(self):
pass
try:
p = requests.get(url=prod['click']['url'], params=prod_params, timeout=30, verify=False)
# self.assertEqual(p.status_code, 200, msg='接口异常,请检查')
print(prod['click']['url'])
print('执行结果:\n=================')
print(p)
print('imei:', randomUtil.r.randimei())
except requests.exceptions.RequestException:
print('imei:', randomUtil.r.randimei())
print('ip', randomUtil.r.randip())
# time.sleep(7)
# try:
# allEvent().installUpload(randomUtil.r.randimei(), randomUtil.r.randip(), prod['events']['appkey'], prod['cmpaignid'])
# except Exception as err:
# print('install_wrong:', w)
# w = w + 1
# print(err)
# time.sleep(1)
# try:
# allEvent().registerEvent(i, ip, appkey)
# except Exception as e:
# print('注册_wrong:', w)
# print(e)
# # continue
# time.sleep(2)
# try:
# allEvent().loginEvent(i, ip, appkey)
# except Exception:
# print('登录_wrong:', w)
# time.sleep(5)
# try:
# allEvent().payEvent(i, ip, appkey)
# except Exception:
# print('付费_wrong:', w)
# time.sleep(2)
# try:
# allEvent().ziding_event(i, ip, appkey,event)
# except Exception:
# print('自定义_wrong:', w)
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