fixed urls within testcases
This commit is contained in:
parent
e20ab64793
commit
91373146e8
2 changed files with 23 additions and 16 deletions
5
backend/drink_stats.json
Normal file
5
backend/drink_stats.json
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{
|
||||||
|
"Tschunk|Club Mate": 83,
|
||||||
|
"Virgin Tschunk|Flora Mate": 14,
|
||||||
|
"Tschunk Hannover-Mische|Club Mate": 12
|
||||||
|
}
|
|
@ -42,7 +42,7 @@ class TestTschunkOrderAPI:
|
||||||
|
|
||||||
def test_drinks_endpoint(self, client):
|
def test_drinks_endpoint(self, client):
|
||||||
"""Test des Drinks-Endpunkts"""
|
"""Test des Drinks-Endpunkts"""
|
||||||
response = client.get("/drinks")
|
response = client.get("/api/drinks")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
@ -66,7 +66,7 @@ class TestTschunkOrderAPI:
|
||||||
|
|
||||||
def test_create_order_success(self, client, sample_order):
|
def test_create_order_success(self, client, sample_order):
|
||||||
"""Test erfolgreiche Bestellerstellung"""
|
"""Test erfolgreiche Bestellerstellung"""
|
||||||
response = client.post("/orders", json=sample_order)
|
response = client.post("/api/orders", json=sample_order)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
|
||||||
order = response.json()
|
order = response.json()
|
||||||
|
@ -91,7 +91,7 @@ class TestTschunkOrderAPI:
|
||||||
|
|
||||||
def test_create_order_empty_drinks(self, client):
|
def test_create_order_empty_drinks(self, client):
|
||||||
"""Test Bestellerstellung ohne Getränke"""
|
"""Test Bestellerstellung ohne Getränke"""
|
||||||
response = client.post("/orders", json={"drinks": []})
|
response = client.post("/api/orders", json={"drinks": []})
|
||||||
assert response.status_code == 400
|
assert response.status_code == 400
|
||||||
assert "Mindestens ein Getränk muss bestellt werden" in response.json()["detail"]
|
assert "Mindestens ein Getränk muss bestellt werden" in response.json()["detail"]
|
||||||
|
|
||||||
|
@ -105,17 +105,17 @@ class TestTschunkOrderAPI:
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
response = client.post("/orders", json=invalid_order)
|
response = client.post("/api/orders", json=invalid_order)
|
||||||
assert response.status_code == 422 # Validation Error
|
assert response.status_code == 422 # Validation Error
|
||||||
|
|
||||||
def test_get_all_orders(self, client, sample_order):
|
def test_get_all_orders(self, client, sample_order):
|
||||||
"""Test Abrufen aller Bestellungen"""
|
"""Test Abrufen aller Bestellungen"""
|
||||||
# Erstelle zuerst eine Bestellung
|
# Erstelle zuerst eine Bestellung
|
||||||
create_response = client.post("/orders", json=sample_order)
|
create_response = client.post("/api/orders", json=sample_order)
|
||||||
assert create_response.status_code == 201
|
assert create_response.status_code == 201
|
||||||
|
|
||||||
# Hole alle Bestellungen
|
# Hole alle Bestellungen
|
||||||
response = client.get("/orders")
|
response = client.get("/api/orders")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
orders = response.json()
|
orders = response.json()
|
||||||
|
@ -143,13 +143,13 @@ class TestTschunkOrderAPI:
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
response = client.post("/orders", json=order_data)
|
response = client.post("/api/orders", json=order_data)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
orders.append(response.json())
|
orders.append(response.json())
|
||||||
time.sleep(0.1) # Kurze Pause zwischen Bestellungen
|
time.sleep(0.1) # Kurze Pause zwischen Bestellungen
|
||||||
|
|
||||||
# Hole alle Bestellungen
|
# Hole alle Bestellungen
|
||||||
response = client.get("/orders")
|
response = client.get("/api/orders")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
all_orders = response.json()
|
all_orders = response.json()
|
||||||
|
@ -165,24 +165,24 @@ class TestTschunkOrderAPI:
|
||||||
def test_delete_order_success(self, client, sample_order):
|
def test_delete_order_success(self, client, sample_order):
|
||||||
"""Test erfolgreiche Bestelllöschung"""
|
"""Test erfolgreiche Bestelllöschung"""
|
||||||
# Erstelle zuerst eine Bestellung
|
# Erstelle zuerst eine Bestellung
|
||||||
create_response = client.post("/orders", json=sample_order)
|
create_response = client.post("/api/orders", json=sample_order)
|
||||||
assert create_response.status_code == 201
|
assert create_response.status_code == 201
|
||||||
order_id = create_response.json()["id"]
|
order_id = create_response.json()["id"]
|
||||||
|
|
||||||
# Lösche die Bestellung
|
# Lösche die Bestellung
|
||||||
response = client.delete(f"/orders/{order_id}")
|
response = client.delete(f"/api/orders/{order_id}")
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
assert f"Bestellung {order_id} wurde erfolgreich gelöscht" in response.json()["message"]
|
assert f"Bestellung {order_id} wurde erfolgreich gelöscht" in response.json()["message"]
|
||||||
|
|
||||||
# Prüfe, dass die Bestellung wirklich gelöscht wurde
|
# Prüfe, dass die Bestellung wirklich gelöscht wurde
|
||||||
get_response = client.get("/orders")
|
get_response = client.get("/api/orders")
|
||||||
orders = get_response.json()
|
orders = get_response.json()
|
||||||
order_ids = [order["id"] for order in orders]
|
order_ids = [order["id"] for order in orders]
|
||||||
assert order_id not in order_ids
|
assert order_id not in order_ids
|
||||||
|
|
||||||
def test_delete_order_not_found(self, client):
|
def test_delete_order_not_found(self, client):
|
||||||
"""Test Löschung einer nicht existierenden Bestellung"""
|
"""Test Löschung einer nicht existierenden Bestellung"""
|
||||||
response = client.delete("/orders/non-existent-id")
|
response = client.delete("/api/orders/non-existent-id")
|
||||||
assert response.status_code == 404
|
assert response.status_code == 404
|
||||||
assert "Bestellung nicht gefunden" in response.json()["detail"]
|
assert "Bestellung nicht gefunden" in response.json()["detail"]
|
||||||
|
|
||||||
|
@ -198,11 +198,12 @@ class TestTschunkOrderAPI:
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
response = client.post("/orders", json=order_without_quantity)
|
response = client.post("/api/orders", json=order_without_quantity)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
|
||||||
order = response.json()
|
order = response.json()
|
||||||
assert order["drinks"][0]["quantity"] == 1
|
first_drink = order["drinks"][0]
|
||||||
|
assert first_drink["quantity"] == 1 # Default-Wert
|
||||||
|
|
||||||
def test_order_with_notes(self, client):
|
def test_order_with_notes(self, client):
|
||||||
"""Test Bestellung mit Anmerkungen"""
|
"""Test Bestellung mit Anmerkungen"""
|
||||||
|
@ -217,11 +218,12 @@ class TestTschunkOrderAPI:
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
response = client.post("/orders", json=order_with_notes)
|
response = client.post("/api/orders", json=order_with_notes)
|
||||||
assert response.status_code == 201
|
assert response.status_code == 201
|
||||||
|
|
||||||
order = response.json()
|
order = response.json()
|
||||||
assert order["drinks"][0]["notes"] == "Bitte extra kalt servieren"
|
first_drink = order["drinks"][0]
|
||||||
|
assert first_drink["notes"] == "Bitte extra kalt servieren"
|
||||||
|
|
||||||
|
|
||||||
class TestWebSocket:
|
class TestWebSocket:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue