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
4 changes: 3 additions & 1 deletion server.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ def showSummary():

return render_template('welcome.html',
club=club[0],
competitions=competitions)
competitions=competitions,
clubs=clubs)



@app.route('/book/<competition>/<club>')
Expand Down
14 changes: 13 additions & 1 deletion templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,22 @@ <h3>Competitions:</h3>
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
{%endif%}
</li>
<hr />

{% endfor %}
</ul>


<h3>Clubs:</h3>
<ul>
{% for listed_club in clubs%}
<li>
{{listed_club['name']}}<br />
Points: {{listed_club['points']}}
</li>
{% endfor %}
</ul>
{%endwith%}
<hr/>

</body>
</html>
27 changes: 25 additions & 2 deletions test/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def test_show_summary_with_unknown_email(client):




def test_purchase_places_with_valid_number_of_places(client):
response = client.post("/purchasePlaces", data={
"competition": "Spring Festival",
Expand All @@ -41,6 +42,7 @@ def test_purchase_places_with_too_many_places(client):




def test_book_less_or_12_places(client, booking_test_data):

club_test, competition_test = booking_test_data
Expand Down Expand Up @@ -82,14 +84,17 @@ def test_book_valid_competition(client, booking_test_data):
assert response.status_code == 200
assert b"How many places?" in response.data


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





def test_club_points_are_deducted_after_booking(client, booking_test_data):
club_test, competition_test = booking_test_data

Expand All @@ -104,4 +109,22 @@ def test_club_points_are_deducted_after_booking(client, booking_test_data):

assert response.status_code == 200
assert b"Great-booking complete!" in response.data
assert club_test["points"] == points_before - places_required
assert club_test["points"] == points_before - places_required





def test_display_list_of_club_and_their_current_point(client, booking_test_data):
club_test, competition_test = booking_test_data

points_club = int(club_test["points"])
name_club = club_test["name"]

response = client.post('/showSummary',data=
{"email": "admin@irontemple.com"})

assert response.status_code == 200
assert name_club.encode() in response.data
assert str(points_club).encode() in response.data