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 @@ ...@@ -5,33 +5,64 @@
@time: 2020/8/6 17:34 @time: 2020/8/6 17:34
@desc: @desc:
""" """
from numpy import long
# 测试环境: from common import randomUtil
import time
# 生产环境: # 生产环境:
prod = { prod = {
"click": { "click": {
"url": "http://t.uri6.com/tkio/EFbIzya", "url": "http://t.uri6.com/tkio/EFbIzya?noredirect=true",
"appkey": "9b17c1568c3ce34599c5fd2778483ff9" "appkey": "9b17c1568c3ce34599c5fd2778483ff9"
}, },
"events":{ "events": {
"url": "http://t.uri6.com/tkio/EFbIzya", "url": "http://t.uri6.com/tkio/EFbIzya",
"appkey": "9b17c1568c3ce34599c5fd2778483ff9" "appkey": "9b17c1568c3ce34599c5fd2778483ff9",
} },
} }
prod_params = { prod_params = {
# 'androidid': "43214532142142", 'androidid': "43214532142142",
'imei': i, 'imei': randomUtil.r.randimei(),
# "idfa": 'DBC13622-E34B-440C-B7A7-FB6641D0D9AB', "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) "ua": "Mozilla/5.0 (iPhone; CPU iPhone OS 8_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko)Version/5.1 "
# Version/5.1 Mobile/9A334 Safari/7534.48.3", 'creativeId':'21321321312123', 'requestId':'312321321312', "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, 'adId': long('21231'),
# 'ry_adcreative_name': ry_adcreative_name, 'ry_adgroup_name': "头条广告组2",
"ry_adgroup_id": ry_adgroup_id, 'ry_adplan_name': "头条广告计划2",
"ry_adplan_id": ry_adplan_id, 'ry_adcreative_name': "头条广告名称2",
"ry_adcreative_id": ry_adcreative_id, "ry_adgroup_id": 999,
} "ry_adplan_id": 999,
\ No newline at end of file "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 ...@@ -10,6 +10,8 @@ import random
import socket import socket
import struct import struct
from config.envcfg import prod from config.envcfg import prod
from common import randomUtil
from config.envcfg import prod_params
import sys import sys
import requests import requests
...@@ -37,17 +39,17 @@ w = 0 ...@@ -37,17 +39,17 @@ w = 0
for _ in range(1): for _ in range(1):
#随机生成12为数组 #随机生成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' # i = '167070728336'
#随机生成ip #随机生成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' # ip = '175.93.28.70'
try: try:
parms = { '''parms = {
# 'androidid': "43214532142142", # 'androidid': "43214532142142",
'imei': i, 'imei': randomUtil.r.randimei(),
# "idfa": 'DBC13622-E34B-440C-B7A7-FB6641D0D9AB', # "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) # "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', # 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, # 'adId': long('21231'), 'ry_adgroup_name': ry_adgroup_name, 'ry_adplan_name': ry_adplan_name,
...@@ -55,28 +57,25 @@ for _ in range(1): ...@@ -55,28 +57,25 @@ for _ in range(1):
"ry_adgroup_id": ry_adgroup_id, "ry_adgroup_id": ry_adgroup_id,
"ry_adplan_id": ry_adplan_id, "ry_adplan_id": ry_adplan_id,
"ry_adcreative_id": ry_adcreative_id, "ry_adcreative_id": ry_adcreative_id,
} }'''
#timeout可以超时四秒 #timeout可以超时四秒
# verify = False # verify = False
print(prod['click']['url']) p = requests.get(url=prod['click']['url'], params=prod_params, timeout=30, verify=False)
p = requests.get(url=prod['click']['url'], params=parms, timeout=30, verify= False)
print('success:',s) print('success:', s)
# print(p.text) # print(p.text)
print('imei:',i) print('imei:',randomUtil.r.randimei())
#print('ip:',ip)
s=s+1
except requests.exceptions.RequestException: except requests.exceptions.RequestException:
print('wrong:',w) print('wrong:',w)
print('imei:', i) print('imei:', randomUtil.r.randimei())
print('ip', ip) print('ip', randomUtil.r.randip())
w=w+1 w=w+1
continue continue
# time.sleep(7) # time.sleep(7)
# try: # try:
# allEvent().installUpload(i, ip, appkey, cmpaignid) allEvent().installUpload(i, ip, appkey, cmpaignid)
# except Exception as err: # except Exception as err:
# print('install_wrong:', w) # print('install_wrong:', w)
# w = w + 1 # w = w + 1
......
...@@ -7,16 +7,58 @@ ...@@ -7,16 +7,58 @@
""" """
import unittest 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 requests
import socket
import struct
import yaml
import os import os
import sys import sys
base_path = os.getcwd() base_path = os.getcwd()
sys.path.append(base_path) sys.path.append(base_path)
class clickTestCase(unittest.TestCase): class clickTestCase(unittest.TestCase):
def click(self): 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