Skip to content

Display when competition is full #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 16, 2024
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
3 changes: 2 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ <h1>Welcome to the GUDLFT Registration Portal!</h1>
<input type="email" name="email" id=""/>
<button type="submit">Enter</button>
</form>

{% with messages = get_flashed_messages()%}
{% if messages %}
{% for message in messages %}
{{message}}
{% endfor %}
{% endif %}
{% endwith %}

</body>
</html>
24 changes: 13 additions & 11 deletions templates/welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,32 @@
<body>
<h2>Welcome, {{club['email']}} </h2><a href="{{url_for('logout')}}">Logout</a>

{% with messages = get_flashed_messages()%}
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul>
{% for message in messages %}
<li>{{message}}</li>
{% endfor %}
</ul>
{% endif%}
Points available: {{club['points']}}
Points available: {{ club['points'] }}
<h3>Competitions:</h3>
<ul>
{% for comp in competitions%}
{% for comp in competitions %}
<li>
{{comp['name']}}<br />
Date: {{comp['date']}}</br>
Number of Places: {{comp['numberOfPlaces']}}
{%if comp['numberOfPlaces']|int >0%}
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
{%endif%}
<p>{{ comp['name'] }}</p>
<p>Date: {{ comp['date'] }}</p>
<p>Number of Places: {{ comp['numberOfPlaces'] }}</p>
{% if comp['numberOfPlaces']|int >0 %}
<a href="{{ url_for('book',competition=comp['name'],club=club['name']) }}">Book Places</a>
{% else %}
<span>- Competition complete</span>
{% endif %}
</li>
<hr />
<hr>
{% endfor %}
</ul>
{%endwith%}
{% endwith %}

</body>
</html>
12 changes: 10 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import copy
import pytest
import json

from server import app
from server import app, competitions


@pytest.fixture
Expand All @@ -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'}
]
22 changes: 21 additions & 1 deletion tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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