Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions server.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def purchasePlaces():
return render_template('welcome.html', club=club, competitions=competitions)

competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
club['points'] = club_points - placesRequired
flash('Great - booking complete!')
return render_template('welcome.html', club=club, competitions=competitions)

Expand Down
27 changes: 27 additions & 0 deletions tests/unit/test_booking_decrease_club_points.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import server

"""
Unit test file to verify that club points are correctly updated after booking.

Test 1: Club has 10 points, books 3 places, points should decrease by 3.
- status code 200
- success message "Great - booking complete!"
- club points decrease by 3

"""


def test_club_points_decrease_after_booking(client):
server.clubs = [{"name": "Club A", "points": "10"}]
server.competitions = [{"name": "Comp 1", "numberOfPlaces": "20"}]

response = client.post('/purchasePlaces', data={
'competition': 'Comp 1',
'club': 'Club A',
'places': '3'
})

assert response.status_code == 200
assert b"Great - booking complete!" in response.data
assert int(server.clubs[0]['points']) == 7