Skip to content

Commit

Permalink
Tests réussis pour le bug #2
Browse files Browse the repository at this point in the history
  • Loading branch information
CeeG33 committed Sep 11, 2023
1 parent cf3598d commit 0eed48d
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ bin
include/
Lib/
Scripts/
tests/
.Python
.envrc
__pycache__/
pyvenv.cfg
pyvenv.cfg
.pytest_cache/
70 changes: 54 additions & 16 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,58 @@ def client():
@pytest.fixture
def clubs():
clubs = [
{
"name":"Simply Lift",
"email":"john@simplylift.co",
"points":"13"
},
{
"name":"Iron Temple",
"email": "admin@irontemple.com",
"points":"4"
},
{ "name":"She Lifts",
"email": "kate@shelifts.co.uk",
"points":"12"
}
]
{
"name":"Simply Lift",
"email":"john@simplylift.co",
"points":"13"
},
{
"name":"Iron Temple",
"email": "admin@irontemple.com",
"points":"4"
},
{ "name":"She Lifts",
"email": "kate@shelifts.co.uk",
"points":"12"
}
]

return clubs
return clubs

@pytest.fixture
def single_club():
club = {
"name":"Simply Lift",
"email":"john@simplylift.co",
"points":"13"
}

return club

@pytest.fixture
def single_competition():
competition = {
"name": "Spring Festival",
"date": "2020-03-27 10:00:00",
"numberOfPlaces": "25"
}

return competition


@pytest.fixture
def competitions():
competitions = [
{
"name": "Spring Festival",
"date": "2020-03-27 10:00:00",
"numberOfPlaces": "25"
},
{
"name": "Fall Classic",
"date": "2020-10-22 13:30:00",
"numberOfPlaces": "13"
}
]

return competitions
41 changes: 39 additions & 2 deletions tests/unit_tests/test_server.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest
from server import app
from tests.conftest import client, clubs
from tests.conftest import client, clubs, single_club, single_competition, competitions


class TestShowSummary:
Expand All @@ -14,4 +14,41 @@ def test_login_with_invalid_email(self, client, clubs):
app.config["clubs"] = clubs
response = client.post("/showSummary", data={"email": "wrong@email.com"})

assert b"Email not found. Please try a valid email." in response.data
assert b"Email not found. Please try a valid email." in response.data


class TestPurchasePlaces:
def test_purchase_places_with_enough_points(self, client, single_club, single_competition) :
competition = single_competition["name"]
club = single_club["name"]
club_points = int(single_club["points"])
places_booked = 5

response = client.post("/purchasePlaces", data={"club": club, "competition": competition, "places": places_booked})

assert response.status_code == 200
assert "Great-booking complete!" in response.data.decode()
assert "Points available: 8" in response.data.decode()

def test_purchase_places_with_excessive_points(self, client, single_club, single_competition) :
competition = single_competition["name"]
club = single_club["name"]
club_points = int(single_club["points"])
places_booked = 20

response = client.post("/purchasePlaces", data={"club": club, "competition": competition, "places": places_booked})

assert "have enough points to book this quantity. Please try again." in response.data.decode()
assert "Points available: 8" in response.data.decode()

def test_purchase_places_with_negative_input(self, client, single_club, single_competition) :
competition = single_competition["name"]
club = single_club["name"]
club_points = int(single_club["points"])
places_booked = -2

response = client.post("/purchasePlaces", data={"club": club, "competition": competition, "places": places_booked})

assert "This is not a correct value. Please try again." in response.data.decode()
assert "Points available: 8" in response.data.decode()

0 comments on commit 0eed48d

Please sign in to comment.