Added seperate bracket/node logic

This commit is contained in:
2026-02-12 16:03:10 +01:00 Verified
parent 7cbb7faca8
commit bb68e326cd
13 changed files with 540 additions and 530 deletions
+17 -9
View File
@@ -2,7 +2,6 @@
import pytest
from httpx import AsyncClient
# Mark all tests in this file as async
pytestmark = pytest.mark.anyio
@@ -15,15 +14,14 @@ async def test_create_tournament(
assert response.status_code == 200
data = response.json()
assert data["name"] == "Test Tournament"
assert data["team_count"] == 4
assert data["court_count"] == 2
assert len(data["teams"]) == 4
assert len(data["courts"]) == 2
assert "id" in data
async def test_list_tournaments(
client: AsyncClient, auth_headers, valid_tournament_payload
):
# Create one first
await client.post(
"/tournaments", json=valid_tournament_payload, headers=auth_headers
)
@@ -35,7 +33,7 @@ async def test_list_tournaments(
assert data[0]["name"] == "Test Tournament"
async def test_get_tournament_detail(
async def test_get_tournament_detail_and_bracket(
client: AsyncClient, auth_headers, valid_tournament_payload
):
create_res = await client.post(
@@ -43,12 +41,24 @@ async def test_get_tournament_detail(
)
t_id = create_res.json()["id"]
# 1. Test Light Detail Endpoint
response = await client.get(f"/tournaments/{t_id}")
assert response.status_code == 200
data = response.json()
# Check deeply nested fields
assert len(data["matches"]) > 0 # Logic should have generated matches
# Should HAVE metadata
assert len(data["teams"]) == 4
# Should NOT have heavy bracket data
assert "nodes" not in data
# 2. Test New Bracket Endpoint
bracket_res = await client.get(f"/tournaments/{t_id}/bracket")
assert bracket_res.status_code == 200
nodes = bracket_res.json()
assert len(nodes) > 0
first_node = nodes[0]
assert "display_number" in first_node
async def test_update_settings(
@@ -64,7 +74,6 @@ async def test_update_settings(
f"/tournaments/{t_id}", json=update_payload, headers=auth_headers
)
# This will now succeed because we updated the response_model!
assert response.status_code == 200
data = response.json()
assert data["name"] == "Updated Name"
@@ -82,6 +91,5 @@ async def test_delete_tournament(
del_res = await client.delete(f"/tournaments/{t_id}", headers=auth_headers)
assert del_res.status_code == 200
# Verify it's gone
get_res = await client.get(f"/tournaments/{t_id}")
assert get_res.status_code == 404