added 3 login tests

This commit is contained in:
2025-06-30 14:02:22 +02:00
parent a50d1946ce
commit 1009ebfc1e
7 changed files with 127 additions and 8 deletions

0
tests/__init__.py Normal file
View File

7
tests/conftest.py Normal file
View File

@@ -0,0 +1,7 @@
import pytest
from server import app
@pytest.fixture
def client():
with app.test_client() as client:
yield client

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})
data = response.data.decode()
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, admin@irontemple.com"