-
Notifications
You must be signed in to change notification settings - Fork 1
/
web_test_gen_scene002.py
54 lines (51 loc) · 1.4 KB
/
web_test_gen_scene002.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from pandas import DataFrame
import csv
import time
import sys
import getopt
import random as rd
outputfile = str(sys.argv[1])
k = int(sys.argv[2])
with open(outputfile + '.csv', 'wb') as f:
testbotwriter = csv.writer(f)
#testbot_raw = list()
testbotwriter.writerow(['ssid','uid','lo','act','cat','pid','pcat','paypid','qty','unit_price','eturec','oid','amt','ERCAMP','ERAD','flag'])
for k in range(k):
uidnum = rd.randint(1,999)
before_cart = rd.randint(2,5)
after_cart = 1
i = 0
while i < before_cart:
ssid = "s%03d" %(k+1)
uid = "u%03d" %(uidnum)
lo = "1"
act = "view"
last_cat = rd.randint(0,9)
cat = "catA%1d,catB%1d,catC%1d" %(rd.randint(0,9), rd.randint(0,9), last_cat)
pid = "pC%1d_%02d" %(last_cat, rd.randint(0,99))
pcat = ""
paypid = ""
qty = ""
unit_price = ""
eturec = ""
oid = ""
amt = ""
campid = rd.randint(0,9)
ERCAMP = "camp%02d" %(campid)
ERAD = "ad%02d_%02d" %(campid, rd.randint(0,99))
testbotwriter.writerow([ssid,uid,lo,act,cat,pid,pcat,paypid,qty,unit_price,eturec,oid,amt,ERCAMP,ERAD,0])
i = i + 1
j = 0
while j < after_cart:
lo = "1"
act = "cart"
pcat = cat
paypid = pid
cat = ""
pid = ""
qty = "%d" %(rd.randint(1,5))
unit_price = "%d" %(rd.randint(100,10000))
oid = ""
amt = ""
testbotwriter.writerow([ssid,uid,lo,act,cat,pid,pcat,paypid,qty,unit_price,eturec,oid,amt,ERCAMP,ERAD,1])
j = j + 1