fixed urls within testcases
Some checks failed
CI / Frontend Build (push) Failing after 3m12s
CI Simple / Test and Build (push) Has been cancelled
CI / Backend Tests (push) Successful in 3m31s
CI / Docker Build Test (push) Has been skipped
CI / Backend Build (push) Successful in 3m31s

This commit is contained in:
Jan Felix Wiebe 2025-07-11 15:44:01 +02:00
parent e20ab64793
commit 91373146e8
2 changed files with 23 additions and 16 deletions

5
backend/drink_stats.json Normal file
View file

@ -0,0 +1,5 @@
{
"Tschunk|Club Mate": 83,
"Virgin Tschunk|Flora Mate": 14,
"Tschunk Hannover-Mische|Club Mate": 12
}

View file

@ -42,7 +42,7 @@ class TestTschunkOrderAPI:
def test_drinks_endpoint(self, client):
"""Test des Drinks-Endpunkts"""
response = client.get("/drinks")
response = client.get("/api/drinks")
assert response.status_code == 200
data = response.json()
@ -66,7 +66,7 @@ class TestTschunkOrderAPI:
def test_create_order_success(self, client, sample_order):
"""Test erfolgreiche Bestellerstellung"""
response = client.post("/orders", json=sample_order)
response = client.post("/api/orders", json=sample_order)
assert response.status_code == 201
order = response.json()
@ -91,7 +91,7 @@ class TestTschunkOrderAPI:
def test_create_order_empty_drinks(self, client):
"""Test Bestellerstellung ohne Getränke"""
response = client.post("/orders", json={"drinks": []})
response = client.post("/api/orders", json={"drinks": []})
assert response.status_code == 400
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
def test_get_all_orders(self, client, sample_order):
"""Test Abrufen aller Bestellungen"""
# 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
# Hole alle Bestellungen
response = client.get("/orders")
response = client.get("/api/orders")
assert response.status_code == 200
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
orders.append(response.json())
time.sleep(0.1) # Kurze Pause zwischen Bestellungen
# Hole alle Bestellungen
response = client.get("/orders")
response = client.get("/api/orders")
assert response.status_code == 200
all_orders = response.json()
@ -165,24 +165,24 @@ class TestTschunkOrderAPI:
def test_delete_order_success(self, client, sample_order):
"""Test erfolgreiche Bestelllöschung"""
# 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
order_id = create_response.json()["id"]
# 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 f"Bestellung {order_id} wurde erfolgreich gelöscht" in response.json()["message"]
# Prüfe, dass die Bestellung wirklich gelöscht wurde
get_response = client.get("/orders")
get_response = client.get("/api/orders")
orders = get_response.json()
order_ids = [order["id"] for order in orders]
assert order_id not in order_ids
def test_delete_order_not_found(self, client):
"""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 "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
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):
"""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
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: