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
+ app .secret_key = "test"
8
+ with app .test_client () as client :
9
+ yield client
10
+
11
+ def test_booking_more_than_12_places (client , monkeypatch ):
12
+ test_club = {"name" : "Test Club" , "email" : "test@club.com" , "points" : "50" }
13
+ test_competition = {"name" : "Test Competition" , "numberOfPlaces" : "25" , "date" : "2025-12-12 10:00:00" }
14
+
15
+ monkeypatch .setattr ("server.clubs" , [test_club ])
16
+ monkeypatch .setattr ("server.competitions" , [test_competition ])
17
+
18
+ response = client .post ("/purchasePlaces" , data = {
19
+ "competition" : "Test Competition" ,
20
+ "club" : "Test Club" ,
21
+ "places" : "13" # > 12 → doit déclencher le bloc
22
+ }, follow_redirects = True )
23
+
24
+ # Vérifie que le message flash est bien là
25
+ assert b"you can not book more than 12 places" in response .data
26
+
27
+ # Vérifie que les données n'ont pas été modifiées
28
+ assert test_competition ["numberOfPlaces" ] == "25"
29
+ assert test_club ["points" ] == "50"
You can’t perform that action at this time.
0 commit comments