Skip to content
Snippets Groups Projects
Commit bdf23410 authored by Ján Macháček's avatar Ján Macháček
Browse files

scenario - adding report

parent 49c2ee29
No related branches found
No related tags found
No related merge requests found
......@@ -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")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment