Compare commits
No commits in common. "691392988f7b0d9cf0b0fa56ab75f42b5b1725d2" and "f323cd8310d495c58e6f6cf737391e7e24728f8c" have entirely different histories.
691392988f
...
f323cd8310
@ -7,7 +7,7 @@
|
|||||||
{
|
{
|
||||||
"name":"Iron Temple",
|
"name":"Iron Temple",
|
||||||
"email": "admin@irontemple.com",
|
"email": "admin@irontemple.com",
|
||||||
"points":"4"
|
"points":"47"
|
||||||
},
|
},
|
||||||
{ "name":"She Lifts",
|
{ "name":"She Lifts",
|
||||||
"email": "kate@shelifts.co.uk",
|
"email": "kate@shelifts.co.uk",
|
||||||
|
@ -29,7 +29,7 @@ def showSummary():
|
|||||||
club = [club for club in clubs if club['email'] == request.form['email']]
|
club = [club for club in clubs if club['email'] == request.form['email']]
|
||||||
if club:
|
if club:
|
||||||
return render_template('welcome.html', club=club[0], competitions=competitions)
|
return render_template('welcome.html', club=club[0], competitions=competitions)
|
||||||
flash("Sorry, that email wasn't found")
|
flash("The email isn't found")
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@app.route('/book/<competition>/<club>')
|
@app.route('/book/<competition>/<club>')
|
||||||
@ -53,6 +53,7 @@ def purchasePlaces():
|
|||||||
else:
|
else:
|
||||||
places = {competition['name']: placesRequired}
|
places = {competition['name']: placesRequired}
|
||||||
points = int(club['points'])
|
points = int(club['points'])
|
||||||
|
print("booked", places)
|
||||||
if placesRequired <= 12:
|
if placesRequired <= 12:
|
||||||
if places[competition['name']] <= 12:
|
if places[competition['name']] <= 12:
|
||||||
if placesRequired <= points:
|
if placesRequired <= points:
|
||||||
|
@ -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,30 +0,0 @@
|
|||||||
import pytest
|
|
||||||
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
|
|
||||||
def client():
|
|
||||||
with app.test_client() as client:
|
|
||||||
yield client
|
|
||||||
|
|
||||||
@pytest.fixture
|
|
||||||
def connect(client):
|
|
||||||
response = client.post('/showSummary', data={"email": EMAIL1})
|
|
||||||
soup = BeautifulSoup(response.data, 'html.parser')
|
|
||||||
return soup
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
|||||||
from flask import session
|
|
||||||
from bs4 import BeautifulSoup
|
|
||||||
|
|
||||||
|
|
||||||
def test_should_status_code_ok(client):
|
|
||||||
response = client.get('/')
|
|
||||||
assert response.status_code == 200
|
|
||||||
|
|
||||||
|
|
||||||
def test_should_display_sorry_with_unknown_email(client):
|
|
||||||
email = "test@test.com"
|
|
||||||
response = client.post('/showSummary', data={"email": email})
|
|
||||||
print(session)
|
|
||||||
assert "_flashes" in session
|
|
||||||
assert session["_flashes"] == [("message", "Sorry, that email wasn't found")]
|
|
||||||
|
|
||||||
|
|
||||||
def test_shoul_display_page_on_known_email(client):
|
|
||||||
email = "admin@irontemple.com"
|
|
||||||
response = client.post('/showSummary', data={"email": email})
|
|
||||||
print(session)
|
|
||||||
soup = BeautifulSoup(response.data, 'html.parser')
|
|
||||||
assert soup.h2.text == "Welcome, "+email
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,28 +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)
|
|
||||||
club1.update({"places": points-1})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "Great-booking complete!" == soup.li.text
|
|
||||||
|
|
||||||
|
|
||||||
class TestPlaces:
|
|
||||||
|
|
||||||
def test_should_refuse_more_than_12(self, client, club1):
|
|
||||||
club1.update({"places": 13})
|
|
||||||
response = client.post('/purchasePlaces', data=club1)
|
|
||||||
soup = BeautifulSoup(response.data, "html.parser")
|
|
||||||
assert "You can't book more than 12 places" == soup.li.text
|
|
Loading…
x
Reference in New Issue
Block a user