forked from OpenClassrooms-Student-Center/Python_Testing
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix and test bug OpenClassrooms-Student-Center#2
- Loading branch information
Showing
4 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import pytest | ||
|
||
import server | ||
|
||
@pytest.fixture | ||
def client(): | ||
with server.app.test_client() as client: | ||
yield client | ||
|
||
@pytest.fixture | ||
def club(): | ||
one_club = server.clubs[0] | ||
one_club["points"] = 4 | ||
return one_club['name'] | ||
|
||
@pytest.fixture | ||
def competition(): | ||
return server.competitions[0]['name'] | ||
|
||
class TestPurchase: | ||
def test_purchase_too_many_places(self, client, club, competition): | ||
"""Checks response when authenticated user request""" | ||
response = client.post( | ||
"/purchasePlaces", | ||
data={'places':8, 'club':club, 'competition':competition}, | ||
follow_redirects=True | ||
) | ||
assert response.status_code == 200 | ||
data = response.data.decode() | ||
assert data.find("You did not have enought points") != -1 | ||
assert data.find("Great-booking complete!") != -1 | ||
|
||
def test_purchase_legal_number_places(self, client, club, competition): | ||
"""Checks response when authenticated user request""" | ||
response = client.post( | ||
"/purchasePlaces", | ||
data={'places':4, 'club':club, 'competition':competition}, | ||
follow_redirects=True | ||
) | ||
assert response.status_code == 200 | ||
data = response.data.decode() | ||
assert data.find("Great-booking complete!") != -1 | ||
assert data.find("You did not have enought points") == -1 |