82 lines
2.6 KiB
Python
Executable File
82 lines
2.6 KiB
Python
Executable File
import sys
|
|
from starlette.testclient import TestClient
|
|
from app.main import app
|
|
|
|
def test_endpoints():
|
|
client = TestClient(app)
|
|
|
|
# Test pages
|
|
res = client.get("/")
|
|
assert res.status_code == 200, f"Index failed: {res.status_code}"
|
|
assert "Die Kammern des Steins der Weisen" in res.text
|
|
assert "Zauberer-Cockpit" in res.text
|
|
|
|
res = client.get("/broom")
|
|
assert res.status_code == 200
|
|
assert "Der Besenflug" in res.text
|
|
|
|
res = client.get("/chess")
|
|
assert res.status_code == 200
|
|
assert "McGonagalls Zauberschach" in res.text
|
|
|
|
res = client.get("/bottles")
|
|
assert res.status_code == 200
|
|
assert "Snapes Flaschenrätsel" in res.text
|
|
|
|
res = client.get("/sliding")
|
|
assert res.status_code == 200
|
|
assert "Alchemie-Schieberätsel" in res.text
|
|
|
|
res = client.get("/finale")
|
|
assert res.status_code == 200
|
|
assert "ESCAPE GEMEISTERT" in res.text
|
|
|
|
# Test Inventory API
|
|
res = client.get("/api/inventory")
|
|
assert res.status_code == 200
|
|
inv_data = res.json()
|
|
assert "inventory" in inv_data
|
|
assert len(inv_data["inventory"]) >= 3
|
|
item_ids = [item["id"] for item in inv_data["inventory"]]
|
|
assert "wand" in item_ids
|
|
assert "broom" in item_ids
|
|
assert "snape_scroll" in item_ids
|
|
|
|
# Test House API
|
|
res = client.post("/api/player/house", json={"house": "slytherin"})
|
|
assert res.status_code == 200
|
|
assert res.json()["house"]["name"] == "Slytherin"
|
|
|
|
# Test API Broom complete (adds silver_key)
|
|
res = client.post("/api/broom/complete", json={"score": 500, "time_taken": 25})
|
|
assert res.status_code == 200
|
|
data = res.json()
|
|
assert data["success"] is True
|
|
assert "silver_key" in data["state"]["inventory"]
|
|
|
|
# Test API Chess complete (adds chess_knight)
|
|
res = client.post("/api/chess/complete")
|
|
assert res.status_code == 200
|
|
chess_data = res.json()
|
|
assert chess_data["success"] is True
|
|
assert chess_data["new_item"]["id"] == "chess_knight"
|
|
assert "chess_knight" in chess_data["state"]["inventory"]
|
|
|
|
# Test API Bottles drink: Ahead / Black fire (Bottle 3 - Dwarf, adds philosophers_stone)
|
|
res = client.post("/api/bottles/drink", json={"bottle": 3, "gate": "ahead"})
|
|
assert res.status_code == 200
|
|
drink_data = res.json()
|
|
assert drink_data["result"] == "success_ahead"
|
|
assert "new_item" in drink_data
|
|
assert drink_data["new_item"]["id"] == "philosophers_stone"
|
|
|
|
# Test API Reset
|
|
res = client.post("/api/reset")
|
|
assert res.status_code == 200
|
|
assert res.json()["success"] is True
|
|
|
|
print("ALL TESTS (INCLUDING CHESS & MOBILE FLIGHT) PASSED! ♟️🧹✨")
|
|
|
|
if __name__ == "__main__":
|
|
test_endpoints()
|