added ok and nok on points
This commit is contained in:
@@ -5,13 +5,21 @@ 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})
|
||||
|
||||
@@ -10,6 +10,7 @@ def test_should_status_code_ok(client):
|
||||
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")]
|
||||
|
||||
@@ -17,6 +18,7 @@ def test_should_display_sorry_with_unknown_email(client):
|
||||
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
|
||||
|
||||
|
||||
@@ -2,10 +2,18 @@ from bs4 import BeautifulSoup
|
||||
from flask import session
|
||||
|
||||
|
||||
def test_should_not_when_try_more_points_than_available(client):
|
||||
data = {"competition": "Spring Festival", "club": "Iron Temple", "places": "6"}
|
||||
response = client.post('/purchasePlaces', data=data)
|
||||
soup = BeautifulSoup(response.data, "html.parser")
|
||||
print(soup.li.text)
|
||||
assert "You don't have enough points" == soup.li.text
|
||||
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