-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocustfile.py
More file actions
25 lines (22 loc) · 877 Bytes
/
locustfile.py
File metadata and controls
25 lines (22 loc) · 877 Bytes
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
from locust import HttpUser, task
from json import JSONDecodeError
class QuickstartUser(HttpUser):
@task
def hello_world(self):
with self.client.post("/new?uri=/", json={
"author": "Arash Hatami",
"email": "info@arash-hatami.ir",
"website": "https://arash-hatami.ir",
"text": "Comment's Body",
"parent": None,
"title": None,
"notification": 0
}, catch_response=True) as response:
try:
if response.json()["mode"] != 1:
response.failure("Did not get expected value in greeting")
except JSONDecodeError:
response.failure("Response could not be decoded as JSON")
except KeyError:
response.failure(
"Response did not contain expected key 'mode'")