first try with fixture for login

This commit is contained in:
yann 2025-07-02 11:36:51 +02:00
parent d3e9eda937
commit 90cae5ffc9
3 changed files with 45 additions and 0 deletions

17
tests/conftest.py Normal file
View File

@ -0,0 +1,17 @@
import pytest
from server import app
EMAIL1 = "admin@irontemple.com"
EMAIL2 = "john@simplylift.co"
@pytest.fixture
def client():
with app.test_client() as client:
yield client
@pytest.fixture
def connect(client):
response = client.post('/showSummary', data={"email": EMAIL})
soup = BeautifulSoup(response.data, 'html.parser')

23
tests/test_connection.py Normal file
View File

@ -0,0 +1,23 @@
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})
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})
soup = BeautifulSoup(response.data, 'html.parser')
assert soup.h2.text == "Welcome, "+email

5
tests/test_purchase.py Normal file
View File

@ -0,0 +1,5 @@
from bs4 import BeautifulSoup
def test_should_not_when_try_more_points_than_available(connect):
print(response.data)