From 623fd1f7030ce0fdfaa535d6f57c3775cc710126 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Amorin?= Date: Tue, 5 May 2026 08:56:35 +0200 Subject: [PATCH] Fix issue #6: deduct club points after booking --- server.py | 1 + test/test_server.py | 21 ++++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index e9a484b3c..f8f1ec351 100644 --- a/server.py +++ b/server.py @@ -81,6 +81,7 @@ def purchasePlaces(): else: flash('Great-booking complete!') competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = int(club['points'])-placesRequired return render_template('welcome.html', club=club, competitions=competitions) diff --git a/test/test_server.py b/test/test_server.py index 655c50e1d..5a096aa7a 100644 --- a/test/test_server.py +++ b/test/test_server.py @@ -68,6 +68,9 @@ def test_book_more_than_12_places(client): assert b"You are not authorized to book more than 12 places per competition!" in response.data + + + def test_book_valid_competition(client, booking_test_data): club_test, competition_test = booking_test_data @@ -85,4 +88,20 @@ def test_book_in_past_competition(client): response = client.get('/book/Spring%20Festival/Iron%20Temple', follow_redirects=True) assert response.status_code == 200 - assert b"You cannot book places for a past competition" in response.data \ No newline at end of file + assert b"You cannot book places for a past competition" in response.data + +def test_club_points_are_deducted_after_booking(client, booking_test_data): + club_test, competition_test = booking_test_data + + points_before = int(club_test["points"]) + places_required = 12 + + response = client.post("/purchasePlaces", data={ + "competition": "Test Competition", + "club": "Test Club", + "places": str(places_required), + }, follow_redirects=True) + + assert response.status_code == 200 + assert b"Great-booking complete!" in response.data + assert club_test["points"] == points_before - places_required \ No newline at end of file