-
Notifications
You must be signed in to change notification settings - Fork 0
/
locustfile1.py
68 lines (59 loc) · 2.26 KB
/
locustfile1.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from locust import HttpLocust, TaskSet, task
from providers.cpsProviders import Providers as cps
import utility
import json
from tests.common.customRequests import Requests as requests
from tests.correct.locustWebStickers import LocustWebStickers as webStickers
from tests.correct.locustAlcs import LocustAlcs as alcsRequests
from tests.correct.locustBOK import LocustBOK as bokRequests
import time
from random import randint
#import response.webSticker.responses as webResp
class UserBehavior(TaskSet):
#c = open('card', 'r+')
#cards = c.read().splitlines()
#c.close()
#h = open('hmac', 'r+')
#hmacs = h.read().splitlines()
#h.close()
counterStart = 999001045000
counter = 999001045000
#cardNumber = counter * 10
@task
def test1(self):
#rand = randint(7950000000000,7950000999999)
#for i in range(1000):
#bokRequests.changePassword(self, str(rand))
#cardNumber = alcsRequests.registerClient(self)[0]
# sessionId = bokRequests.changePassword(self, '7157834569333')
UserBehavior.counter += 1
cardNumber = UserBehavior.counter * 10
if UserBehavior.counter - UserBehavior.counterStart >= 9999:
UserBehavior.counter = UserBehavior.counterStart
#print(cardNumber)
sessionId = webStickers.login(self, cardNumber)["SessionId"]
if (str(sessionId) != str(-1)):
#print(sessionId)
webStickers.changePassword(self, sessionId, cardNumber)
# time.sleep(1)
ifMatch, phoneNumberGet = webStickers.getCustomer(self, sessionId)
phoneNumberPatch = webStickers.changeClientData(self, sessionId, ifMatch)
patchTime = time.strftime("[%d/%b/%Y:%H:%M:%S +0200]", time.localtime())
f = open(str(UserBehavior.counterStart) + ".log", "a+")
f.write(patchTime + " CardNumber: " + str(cardNumber) + " Old: " + str(phoneNumberGet) + " New: " + str(phoneNumberPatch) + "\n")
f.close()
webStickers.logout(self, sessionId)
#else:
#print(cardNumber, sessionId)
#time.sleep(2)
#ifMatch = webStickers.getCustomer(self, sessionId)
#print (ifMatch)
#webStickers.changePassword(self, sessionId, cardNumber)
#webStickers.changeClientData(self, ifMatch)
#alcsRequests.activateClient(self)
#webStickers.getClientName(self, sessionId)
#webStickers.logout(self, sessionId)
class WebsiteUser(HttpLocust):
task_set = UserBehavior
min_wait=1000
max_wait=5000