diff --git a/templates/index.html b/templates/index.html index ab38b4445..2cd56a3d5 100644 --- a/templates/index.html +++ b/templates/index.html @@ -14,7 +14,7 @@

Welcome to the GUDLFT Registration Portal!

- + {% with messages = get_flashed_messages()%} {% if messages %} {% for message in messages %} @@ -22,5 +22,6 @@

Welcome to the GUDLFT Registration Portal!

{% endfor %} {% endif %} {% endwith %} + \ No newline at end of file diff --git a/templates/welcome.html b/templates/welcome.html index ff6b261a2..4405feda4 100644 --- a/templates/welcome.html +++ b/templates/welcome.html @@ -7,7 +7,7 @@

Welcome, {{club['email']}}

Logout - {% with messages = get_flashed_messages()%} + {% with messages = get_flashed_messages() %} {% if messages %} {% endif%} - Points available: {{club['points']}} + Points available: {{ club['points'] }}

Competitions:

- {%endwith%} + {% endwith %} \ No newline at end of file diff --git a/tests/conftest.py b/tests/conftest.py index 802b1df5c..5a3c904e9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,8 +1,7 @@ -import copy import pytest import json -from server import app +from server import app, competitions @pytest.fixture @@ -22,3 +21,12 @@ def test_clubs(): def test_competitions(): with open('competitions.json') as comps: return json.load(comps)['competitions'] + + +@pytest.fixture +def test_competition_full(): + competitions[:] = [ + {'name': 'Spring Festival', + 'date': '2020-03-27 10:00:00', + 'numberOfPlaces': '0'} + ] diff --git a/tests/test_server.py b/tests/test_server.py index 2bf6ef990..c66074ba0 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -52,7 +52,6 @@ def test_has_sufficient_points(client): def test_update_points_after_purchase(client, test_clubs, test_competitions, mocker): - mocker.patch('server.loadClubs', return_value=test_clubs) mocker.patch('server.loadCompetitions', return_value=test_competitions) mock_save_club = mocker.patch('server.saveClub') @@ -87,3 +86,24 @@ def test_wrong_login(client): }) assert response.status_code == 200 assert b'Wrong email-please try again' in response.data + + +def test_display_book_available(client): + test_club = loadClubs()[0] + test_competitions = loadCompetitions() + + response = client.post('/showSummary', data={'email': test_club['email']}) + + assert response.status_code == 200 + assert b'Number of Places: 25' in response.data + + +def test_display_book_non_available(client, test_competition_full): + + test_club = loadClubs()[0] + + response = client.post('/showSummary', data={'email': test_club['email']}) + + assert response.status_code == 200 + assert b'Spring Festival' in response.data + assert b'- Competition complete' in response.data