File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import pytest
2
+ from server import app
3
+
4
+ @pytest .fixture
5
+ def client ():
6
+ app .config ['TESTING' ] = True
7
+ with app .test_client () as client :
8
+ yield client
9
+
10
+ def test_competition_places_are_decreased (client , monkeypatch ):
11
+ # Club avec assez de points
12
+ test_club = {"name" : "Test Club" , "email" : "test@club.com" , "points" : "20" }
13
+ # Compétition avec 10 places
14
+ test_competition = {"name" : "Test Competition" , "numberOfPlaces" : "10" , "date" : "2025-12-12 10:00:00" }
15
+
16
+ # Patch les données directement dans server.py
17
+ monkeypatch .setattr ("server.clubs" , [test_club ])
18
+ monkeypatch .setattr ("server.competitions" , [test_competition ])
19
+
20
+ # POST de réservation de 3 places
21
+ response = client .post ("/purchasePlaces" , data = {
22
+ "competition" : "Test Competition" ,
23
+ "club" : "Test Club" ,
24
+ "places" : "3"
25
+ }, follow_redirects = True )
26
+
27
+ # Vérifie que la compétition a bien été mise à jour
28
+ assert test_competition ["numberOfPlaces" ] == 7 # 10 - 3
29
+
You can’t perform that action at this time.
0 commit comments