From 75316cd40509c577bb15f2d797b6ab14e8875b84 Mon Sep 17 00:00:00 2001 From: elof-dev Date: Thu, 23 Oct 2025 07:16:24 +0700 Subject: [PATCH] Fixes #7: update server.py and index.html to display board + tests - Updated index.html to include a simple grey table listing all clubs and their points - Modified server.py to pass the clubs data to the index template - Added test_display_clubs_points.py to verify that: - the page loads successfully - each club name and its points appear correctly in the HTML --- server.py | 2 +- templates/index.html | 17 +++++++++++++++ .../test_board_with_clubs_and_their_points.py | 21 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/unit/test_board_with_clubs_and_their_points.py diff --git a/server.py b/server.py index d5cce5c41..e53d984e2 100644 --- a/server.py +++ b/server.py @@ -23,7 +23,7 @@ def loadCompetitions(): @app.route('/') def index(): - return render_template('index.html') + return render_template('index.html', clubs=clubs) @app.route('/showSummary',methods=['POST']) def showSummary(): diff --git a/templates/index.html b/templates/index.html index ae4e91eb1..3be9546c9 100644 --- a/templates/index.html +++ b/templates/index.html @@ -21,5 +21,22 @@

Welcome to the GUDLFT Registration Portal!

+

Clubs Points Summary

+ + + + + + + + + {% for club in clubs %} + + + + + {% endfor %} + +
ClubPoints
{{ club['name'] }}{{ club['points'] }}
\ No newline at end of file diff --git a/tests/unit/test_board_with_clubs_and_their_points.py b/tests/unit/test_board_with_clubs_and_their_points.py new file mode 100644 index 000000000..eb832fae4 --- /dev/null +++ b/tests/unit/test_board_with_clubs_and_their_points.py @@ -0,0 +1,21 @@ +import server + +""" +Unit test file to check if the index page displays the clubs and their points correctly +Test 1: The page loads successfully (status code 200) +Test 2: Each club name and its points appear in the HTML +""" + +def test_index_page_loads(client): + response = client.get('/') + assert response.status_code == 200 + assert b"Clubs Points Summary" in response.data + + +def test_index_page_displays_clubs_points(client): + response = client.get('/') + data = response.data.decode() + + for club in server.clubs: + assert club["name"] in data + assert club["points"] in data