Skip to content
Snippets Groups Projects

feat(Scenario): Added runnable scenario

Merged Michal Badin requested to merge python-scenario into develop
Files
2
from locust import HttpUser, task
import random
class Admin(HttpUser):
id = 0
fixed_count = 1
def on_start(self):
@task
def update_random_application_status(self):
response = self.client.get("/application")
if len(response.json()) == 0:
self.client.post("/application", json={
"name": "Jozko",
"surname": "Example",
"birthday": "2023-05-06",
"email": "jozko.example@example.com"
})
response = self.client.get("/application")
return
self.id = response.json()[0]['id']
@task
def update_application_status(self):
self.client.get("/application")
applicationNumber = random.choice([i for i in range(1, len(response.json()))])
status = random.choice(["accepted", "rejected"])
self.client.put(f"/application/status?id={self.id}&applicationStatus={status}")
self.client.put(f"/application/status?id={applicationNumber}&applicationStatus={status}")
@task
def get_application(self):
@@ -41,6 +30,6 @@ class User(HttpUser):
self.client.post("/application", json={
"name": "Jozko",
"surname": "Example",
"birthday": "2023-05-06",
"email": "jozko.example@example.com"
"birthday": "2000-05-06",
"email": "john@example.com"
})
Loading