forked from abruneau/hipstershop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocustfile.py
61 lines (51 loc) · 1.52 KB
/
locustfile.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
#!/usr/bin/python
import random
from locust import HttpUser, task, between
products = [
'0PUK6V6EV0',
'1YMWWN1N4O',
'2ZYFJ3GM2N',
'66VCHSJNUP',
'6E92ZMYYFZ',
'9SIQT8TOJO',
'L9ECAV7KIM',
'LS4PSXUNUM',
'OLJCESPC7Z']
class WebsiteUser(HttpUser):
wait_time = between(1, 10)
@task
def index(self):
self.client.get("/")
@task(2)
def setCurrency(self):
currencies = ['EUR', 'USD', 'JPY', 'CAD']
self.client.post("/setCurrency",
{'currency_code': random.choice(currencies)})
@task(10)
def browseProduct(self):
self.client.get("/product/" + random.choice(products))
@task(3)
def viewCart(self):
self.client.get("/cart")
@task(2)
def addToCart(self):
product = random.choice(products)
self.client.get("/product/" + product)
self.client.post("/cart", {
'product_id': product,
'quantity': random.choice([1,2,3,4,5,10])})
@task
def checkout(self):
self.addToCart()
self.client.post("/cart/checkout", {
'email': '[email protected]',
'street_address': '1600 Amphitheatre Parkway',
'zip_code': '94043',
'city': 'Mountain View',
'state': 'CA',
'country': 'United States',
'credit_card_number': '4432-8015-6152-0454',
'credit_card_expiration_month': '1',
'credit_card_expiration_year': '2039',
'credit_card_cvv': '672',
})