Skip to content

Commit 255eed0

Browse files
authored
Merge pull request #2 from Imed7223/bug/correction-points-display
Correction bug 2: Implémentation et tests de l'affichage des points
2 parents 13666dc + a96cfae commit 255eed0

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

server.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ def purchasePlaces():
5858
return render_template('welcome.html', club=club, competitions=competitions)
5959

6060

61-
# TODO: Add route for points display
61+
# FONCTIONNALITÉ 2: Tableau d'affichage des points
62+
@app.route('/pointsDisplay')
63+
def pointsDisplay():
64+
return render_template('points_display.html', clubs=clubs)
6265

6366

6467
@app.route('/logout')

templates/points_display.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<html lang="en">
2+
<head>
3+
<meta charset="UTF-8">
4+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
5+
<title>Clubs Points | GUDLFT</title>
6+
</head>
7+
<body>
8+
<h1>Clubs Points</h1>
9+
<a href="{{url_for('index')}}">Back to login</a>
10+
<table>
11+
<thead>
12+
<tr>
13+
<th>Club</th>
14+
<th>Points</th>
15+
</tr>
16+
</thead>
17+
<tbody>
18+
{% for club in clubs %}
19+
<tr>
20+
<td>{{ club['name'] }}</td>
21+
<td>{{ club['points'] }}</td>
22+
</tr>
23+
{% endfor %}
24+
</tbody>
25+
</table>
26+
</body>
27+
</html>

tests/unit/test_points_display.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import sys
2+
import os
3+
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
4+
import pytest
5+
from server import app, clubs
6+
7+
@pytest.fixture
8+
def client():
9+
app.config['TESTING'] = True
10+
with app.test_client() as client:
11+
yield client
12+
13+
def test_points_display_route(client):
14+
"""Test que la route /pointsDisplay renvoie le bon template avec les données"""
15+
response = client.get('/pointsDisplay')
16+
assert response.status_code == 200
17+
assert b"Clubs Points" in response.data
18+
19+
# Vérifier que tous les clubs sont affichés
20+
for club in clubs:
21+
assert club['name'].encode() in response.data
22+
assert club['points'].encode() in response.data
23+
24+
def test_points_display_content(client):
25+
"""Test le contenu spécifique du tableau des points"""
26+
response = client.get('/pointsDisplay')
27+
28+
# Vérifier le format du tableau
29+
assert b"<table>" in response.data
30+
assert b"<th>Club</th>" in response.data
31+
assert b"<th>Points</th>" in response.data
32+
33+
# Vérifier un club spécifique
34+
test_club = clubs[0]
35+
assert f"<td>{test_club['name']}</td>".encode() in response.data
36+
assert f"<td>{test_club['points']}</td>".encode() in response.data

0 commit comments

Comments
 (0)