From bdf23410e7b1ccf9a11a05efb7faa7909b908c65 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A1n=20Mach=C3=A1=C4=8Dek?= <xmachac5@fi.muni.cz>
Date: Sat, 6 May 2023 16:24:05 +0200
Subject: [PATCH] scenario - adding report

---
 locust-scenarios/locustfile.py | 108 ++++-----------------------------
 1 file changed, 12 insertions(+), 96 deletions(-)

diff --git a/locust-scenarios/locustfile.py b/locust-scenarios/locustfile.py
index 79a661f..1311589 100644
--- a/locust-scenarios/locustfile.py
+++ b/locust-scenarios/locustfile.py
@@ -2,102 +2,24 @@ from locust import HttpUser, task
 
 
 class Admin(HttpUser):
-
-    def on_start(self):
-    #create airplane type - just once because creating airplane type more times would report fail due to not unique name
-    self.client.post(":8080/api/airplaneTypes", json=
-    {
-        "name": "Práškovač 2000"
-    })
-
-    self.client.post(":8080/api/countries", json=
-    {
-        "name": "Slovensko"
-    })
-    self.client.post(":8080/api/cities", json=
-    {
-        "name": "HolĂ­ÄŤ"
-    })
-    self.client.post(":8080/api/cities", json=
-    {
-        "name": "Senica"
-    })
-    self.client.post(":8080/api/cities/1/countries/1", json=
-    {
-        "name": "Senica"
-    })
-    self.client.post(":8080/api/cities/2/countries/1", json=
-    {
-        "name": "Senica"
-    })
-    #create 2 airports - just once because airport need to have unique code
-    self.client.post(":8080/api/airports", json=
-    {
-        "name": "Trávník Holíč",
-        "code": "TH",
-        "location": {
-            "latitude": 48.48440,
-            "longitude": 17.9380
-        }
-    })
-    self.client.post(":8080/api/airports", json=
-    {
-        "name": "Hlinište Senica",
-        "code": "HS",
-        "location": {
-            "latitude": 48.40500,
-            "longitude": 17.22000
-        }
-    })
-
-    @task
-    def create_airplane(self):
-        response  = self.client.get(":8080/api/airplaneTypes/1")
-
-        if response.status_code == 200:
-            self.client.post(":8080/api/airplanes", json=
-            {
-                "name": "Prášek",
-                "capacity": 2,
-                "airplaneTypeId": 1
-            })
-
     @task
-    def create_steward(self):
-        self.client.post(":8080/api/stewards", json=
+    def create_airplane_type(self):
+        self.client.post(":8080/api/airplaneTypes", json=
         {
-            "firstName": "John",
-            "lastName": "Doe"
+            "name": "Práškovač 3000"
         })
-
+        return
     @task
-    def create_flight(self):
-        self.client.post(":8080/api/flights", json=
+    def create_airplane(self):
+        self.client.get(":8080/api/airplaneTypes")
+
+        self.client.post(":8080/api/airplanes", json=
         {
-            "departureTime": "2022-12-22T12:04:04.493908908+01:00",
-            "arrivalTime": "2022-12-22T12:04:04.493908908+01:00"
+            "name": "Prášek",
+            "capacity": 2,
+            "airplaneTypeId": 1
         })
-
-    @task
-    def assign_steward_flight(self):
-        response_steward = self.client.get(":8080/api/stewards/1")
-        response_flight = self.client.get(":8080/api/flights/1")
-
-        if response_steward.status_code == 200 and response_flight.status_code == 200:
-            self.client.post(":8080/api/stewards/1/flights/1")
-            self.client.delete(":8080/api/stewards/1/flights/1")
-
-    @task
-    def assign_airport_flight(self):
-        response_airport1 = self.client.get(":8080/api/airports/1")
-        response_airport2 = self.client.get(":8080/api/airports/2")
-        response_flight = self.client.get(":8080/api/flights/1")
-
-        if response_airport1.status_code == 200 and response_flight.status_code == 200 and response_airport2.status_code == 200:
-            self.client.post(":8080/api/airports/1/departingFlights/1")
-            self.client.post(":8080/api/airports/2/arrivingFlights/1")
-            self.client.delete(":8080/api/airports/1/departingFlights/1")
-            self.client.delete(":8080/api/airports/2/arrivingFlights/1")
+        self.client.get(":8080/api/airplanes")
 
 
 class BasicUser(HttpUser):
@@ -116,9 +38,3 @@ class BasicUser(HttpUser):
     @task
     def generate_airplane_report(self):
         self.client.get(":8085/api/reports/airplane/1")
-    @task
-    def generate_airport_report(self):
-        self.client.get(":8085/api/reports/airport/1")
-    @task
-    def generate_flight_report(self):
-        self.client.get(":8085/api/reports/flight/1")
-- 
GitLab