-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlocustfile.py
More file actions
89 lines (76 loc) · 2.53 KB
/
Copy pathlocustfile.py
File metadata and controls
89 lines (76 loc) · 2.53 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import time, uuid
from random import random,randint
import sys
from locust import User, HttpUser, task, between
from locust.clients import HttpSession
class QuickstartUser(HttpUser):
wait_time = between(0.09, 0.4)
def on_start(self):
self.client.post("/login",data={"username":"bob","password":"bobpass"},headers={"content-type":"application/x-www-form-urlencoded"})
def on_end(self):
self.client.cookies.clear()
@task(1)
def testLockerPUT(self):
payload = {
"locker_code":"A104",
"locker_type":"Large",
"area":19,
"status":"Free",
"key":str(randint(10000,11000)),
}
self.client.request('PUT',"/api/locker",json=payload,headers={'Content-Type':'application/json'})
"""def testLocker(self):
self.client.get("/locker")
payload = {
"locker_code": str(uuid.uuid4()).split("-")[0]+"TEST4",
"locker_type": "Small",
"status": "Free",
"key": "PASS",
"area": "1"
}
response = self.client.post("/locker", data=payload)
if response.status_code == 200:
print("Form submitted successfully")
else:
print("Form submission failed")
@task(1)
def testArea(self):
self.client.get("/area")
payload = {
"description": "ENGEN",
"longitude": "10",
"latitude": "12"
}
response = self.client.post("/area", data=payload)
if response.status_code == 200:
print("Form submitted successfully")
else:
print("Form submission failed")
@task(4)
def testTransactionLog(self):
#self.client.get("/transactionLog")
@task(3)
def testStudent(self):
self.client.get("/student")
payload = {
"student_id": random.randint(10000000, 99999999),
"f_name": "Kristopher",
"l_name": "Bholai",
"faculty": "FST",
"p_no": "2927492",
"email": str(uuid.uuid4()).split("-")[0]+"kristopher.bholai@gmail.com"
}
response = self.client.post("/student", data=payload)
if response.status_code == 200:
print("Form submitted successfully")
else:
print("Form submission failed")
@task(2)
def testRentType(self):
self.client.get("/rentType")
@task(4)
def testKey(self):
#self.client.get("/key")
@task(4)
def testMasterkey(self):
#self.client.get("/masterkey")"""