-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocustfile.py
51 lines (42 loc) · 1.17 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
from locust import HttpUser, TaskSet, task, between
class PetStoreTasks(TaskSet):
@task
def add_pet(self):
url = '/v2/pet'
body = {
"id": 103,
"category": {
"id": 1,
"name": "dogs"
},
"name": "jimmyPet",
"photoUrls": [
"./PetDogs.jpg"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
headers = {
'accept': 'application/json',
'Content-Type': 'application/json',
}
self.client.post(url, json=body, headers=headers)
@task
def upload_image_pet(self):
petID = 103
url = f'/v2/pet/{petID}/uploadImage'
headers = {
'accept': 'application/json',
}
files = {
'file': ('PetDogs.jpg', open('Document/UploadFile/PetDogs.jpg', 'rb'), 'image/jpeg')
}
self.client.post(url, headers=headers, files=files)
class WebsiteUser(HttpUser):
tasks = [PetStoreTasks]
wait_time = between(1, 5)