Compare commits
1 Commits
f79c92e8c3
...
19034f63f3
| Author | SHA1 | Date | |
|---|---|---|---|
| 19034f63f3 |
14
server.py
14
server.py
@@ -28,7 +28,10 @@ def index():
|
|||||||
def showSummary():
|
def showSummary():
|
||||||
try:
|
try:
|
||||||
club = [club for club in clubs if club['email'] == request.form['email']][0]
|
club = [club for club in clubs if club['email'] == request.form['email']][0]
|
||||||
|
# if club:
|
||||||
return render_template('welcome.html', club=club, competitions=competitions)
|
return render_template('welcome.html', club=club, competitions=competitions)
|
||||||
|
# flash("Sorry, that email wasn't found")
|
||||||
|
# return redirect(url_for('index'))
|
||||||
except IndexError:
|
except IndexError:
|
||||||
flash("Sorry, that email wasn't found")
|
flash("Sorry, that email wasn't found")
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
@@ -49,18 +52,11 @@ def purchasePlaces():
|
|||||||
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
|
competition = [c for c in competitions if c['name'] == request.form['competition']][0]
|
||||||
club = [c for c in clubs if c['name'] == request.form['club']][0]
|
club = [c for c in clubs if c['name'] == request.form['club']][0]
|
||||||
placesRequired = int(request.form['places'])
|
placesRequired = int(request.form['places'])
|
||||||
points = int(club['points'])
|
competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired
|
||||||
if placesRequired <= points:
|
flash('Great-booking complete!')
|
||||||
competition['numberOfPlaces'] = int(competition['numberOfPlaces']) - placesRequired
|
|
||||||
if competition['numberOfPlaces'] < 0:
|
|
||||||
competition['numberOfPlaces'] = 0
|
|
||||||
flash("Great-booking complete!")
|
|
||||||
else:
|
|
||||||
flash("You don't have enough points")
|
|
||||||
return render_template('welcome.html', club=club, competitions=competitions)
|
return render_template('welcome.html', club=club, competitions=competitions)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: Add route for points display
|
# TODO: Add route for points display
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
{% endif%}
|
{% endif%}
|
||||||
<b id="points">Points available: </b><span>{{club['points']}}</span>
|
Points available: {{club['points']}}
|
||||||
<h3>Competitions:</h3>
|
<h3>Competitions:</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{% for comp in competitions%}
|
{% for comp in competitions%}
|
||||||
|
|||||||
@@ -1,29 +1,7 @@
|
|||||||
import pytest
|
import pytest
|
||||||
from server import app
|
from server import app
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
|
|
||||||
EMAIL1 = "admin@irontemple.com"
|
|
||||||
EMAIL2 = "john@simplylift.co"
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def club1():
|
|
||||||
data = {"competition": "Spring Festival", "club": "Iron Temple"}
|
|
||||||
return data
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def club2():
|
|
||||||
data = {"competition": "Fall Classic", "club": "Iron Temple"}
|
|
||||||
return data
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def client():
|
def client():
|
||||||
with app.test_client() as client:
|
with app.test_client() as client:
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def connect(client):
|
|
||||||
response = client.post('/showSummary', data={"email": EMAIL1})
|
|
||||||
soup = BeautifulSoup(response.data, 'html.parser')
|
|
||||||
return soup
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
from bs4 import BeautifulSoup
|
|
||||||
from flask import session
|
|
||||||
|
|
||||||
|
|
||||||
class TestPoints:
|
|
||||||
|
|
||||||
def test_should_nok_when_too_much_points(self, client, connect, club1):
|
|
||||||
points = int(connect.span.text)
|
|
||||||
club1.update({"places": points+1})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "You don't have enough points" == soup.li.text
|
|
||||||
|
|
||||||
def test_should_ok_when_enough_points(self, client, connect, club1):
|
|
||||||
points = int(connect.span.text)
|
|
||||||
data = club1.update({"places": points-1})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "Great-booking complete!" == soup.li.text
|
|
||||||
Reference in New Issue
Block a user