Better bracket logic
This commit is contained in:
@@ -33,7 +33,7 @@ async def test_list_tournaments(
|
||||
assert data[0]["name"] == "Test Tournament"
|
||||
|
||||
|
||||
async def test_get_tournament_detail_and_bracket(
|
||||
async def test_delete_tournament(
|
||||
client: AsyncClient, auth_headers, valid_tournament_payload
|
||||
):
|
||||
create_res = await client.post(
|
||||
@@ -41,25 +41,41 @@ async def test_get_tournament_detail_and_bracket(
|
||||
)
|
||||
t_id = create_res.json()["id"]
|
||||
|
||||
# 1. Test Light Detail Endpoint
|
||||
del_res = await client.delete(f"/tournaments/{t_id}", headers=auth_headers)
|
||||
assert del_res.status_code == 200
|
||||
|
||||
get_res = await client.get(f"/tournaments/{t_id}")
|
||||
assert get_res.status_code == 404
|
||||
|
||||
|
||||
async def test_get_tournament_detail(
|
||||
client: AsyncClient, auth_headers, valid_tournament_payload
|
||||
):
|
||||
create_res = await client.post(
|
||||
"/tournaments", json=valid_tournament_payload, headers=auth_headers
|
||||
)
|
||||
t_id = create_res.json()["id"]
|
||||
|
||||
# 1. Test Detail Endpoint
|
||||
response = await client.get(f"/tournaments/{t_id}")
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
|
||||
# Should HAVE metadata
|
||||
assert len(data["teams"]) == 4
|
||||
# Should NOT have heavy bracket data
|
||||
|
||||
# Should HAVE matches (since we merged nodes into matches and put them in Detail)
|
||||
assert "matches" in data
|
||||
assert len(data["matches"]) > 0
|
||||
|
||||
# Check structure of a match
|
||||
first_match = data["matches"][0]
|
||||
assert "id" in first_match
|
||||
assert "winner_next_match_id" in first_match
|
||||
|
||||
# Ensure no old "nodes" key
|
||||
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(
|
||||
client: AsyncClient, auth_headers, valid_tournament_payload
|
||||
@@ -77,19 +93,6 @@ async def test_update_settings(
|
||||
assert response.status_code == 200
|
||||
data = response.json()
|
||||
assert data["name"] == "Updated Name"
|
||||
assert data["code"] == "9999"
|
||||
|
||||
|
||||
async def test_delete_tournament(
|
||||
client: AsyncClient, auth_headers, valid_tournament_payload
|
||||
):
|
||||
create_res = await client.post(
|
||||
"/tournaments", json=valid_tournament_payload, headers=auth_headers
|
||||
)
|
||||
t_id = create_res.json()["id"]
|
||||
|
||||
del_res = await client.delete(f"/tournaments/{t_id}", headers=auth_headers)
|
||||
assert del_res.status_code == 200
|
||||
|
||||
get_res = await client.get(f"/tournaments/{t_id}")
|
||||
assert get_res.status_code == 404
|
||||
# The response model is TournamentUpdateResponse which inherits TournamentDetail
|
||||
# So it should also have matches
|
||||
assert "matches" in data
|
||||
|
||||
Reference in New Issue
Block a user