@@ -74,3 +74,36 @@ def test_competition_places_are_decreased(client, monkeypatch):
74
74
# Vérifie que la compétition a bien été mise à jour
75
75
assert test_competition ["numberOfPlaces" ] == 7 # 10 - 3
76
76
77
+ def test_purchase_places_more_than_points (client , monkeypatch ):
78
+ # Simuler un club avec seulement 2 points
79
+ test_club = {"name" : "Test Club" , "email" : "test@club.com" , "points" : "2" }
80
+ test_competition = {"name" : "Test Competition" , "numberOfPlaces" : "10" , "date" : "2025-12-12 10:00:00" }
81
+
82
+ # Patch les données dans server.py
83
+ monkeypatch .setattr ("server.clubs" , [test_club ])
84
+ monkeypatch .setattr ("server.competitions" , [test_competition ])
85
+
86
+ # Envoyer un formulaire avec 5 places (plus que les 2 points disponibles)
87
+ response = client .post ("/purchasePlaces" , data = {
88
+ "competition" : "Test Competition" ,
89
+ "club" : "Test Club" ,
90
+ "places" : "5"
91
+ }, follow_redirects = True )
92
+
93
+ # Vérifier que le message d'erreur s'affiche
94
+ assert b"you can not book more than available points" in response .data
95
+
96
+ def test_purchase_places_success (client , monkeypatch ):
97
+ test_club = {"name" : "Test Club" , "email" : "test@club.com" , "points" : "10" }
98
+ test_competition = {"name" : "Test Competition" , "numberOfPlaces" : "15" , "date" : "2025-12-12 10:00:00" }
99
+
100
+ monkeypatch .setattr ("server.clubs" , [test_club ])
101
+ monkeypatch .setattr ("server.competitions" , [test_competition ])
102
+
103
+ response = client .post ("/purchasePlaces" , data = {
104
+ "competition" : "Test Competition" ,
105
+ "club" : "Test Club" ,
106
+ "places" : "3"
107
+ }, follow_redirects = True )
108
+
109
+ assert b"Great-booking complete!" in response .data
0 commit comments