From e63477955192176af287d47cebb3063db70dff79 Mon Sep 17 00:00:00 2001 From: Coureau Date: Fri, 26 Jun 2026 12:18:11 +0400 Subject: [PATCH] =?UTF-8?q?#6=20:=20D=C3=A9duction=20=20des=20points=20du?= =?UTF-8?q?=20cub=20lors=20d'une=20r=C3=A9servation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 1 + tests/integration/test_purchase.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/integration/test_purchase.py diff --git a/server.py b/server.py index 2406bbfc5..a58f8b437 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,7 @@ def purchasePlaces(): club = [c for c in clubs if c['name'] == request.form['club']][0] placesRequired = int(request.form['places']) competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = int(club['points']) - placesRequired flash('Great-booking complete!') return render_template('welcome.html', club=club, competitions=competitions) diff --git a/tests/integration/test_purchase.py b/tests/integration/test_purchase.py new file mode 100644 index 000000000..39748596c --- /dev/null +++ b/tests/integration/test_purchase.py @@ -0,0 +1,25 @@ +import server + + +def test_purchase_deducts_points_from_club(client): + """Bug #6 : les points utilises doivent etre deduits du solde du club.""" + # On choisit un club et une competition connus + club = next(c for c in server.clubs if c['name'] == "Simply Lift") + competition = next( + c for c in server.competitions if c['name'] == "Spring Festival" + ) + + points_avant = int(club['points']) + places_reservees = 3 + + client.post( + "/purchasePlaces", + data={ + "competition": competition['name'], + "club": club['name'], + "places": str(places_reservees), + }, + ) + + points_apres = int(club['points']) + assert points_apres == points_avant - places_reservees \ No newline at end of file