From 7b2b22d15d2899123e094a1a3757db9461d2775e Mon Sep 17 00:00:00 2001 From: "jean-baptiste.guerin" Date: Thu, 6 Feb 2025 17:15:00 +0100 Subject: [PATCH] feat: test login --- pytest.ini | 3 +++ tests/test_show_summary.py | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 pytest.ini create mode 100644 tests/test_show_summary.py diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..c24fe5bb9 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +filterwarnings = + ignore::DeprecationWarning diff --git a/tests/test_show_summary.py b/tests/test_show_summary.py new file mode 100644 index 000000000..a82510519 --- /dev/null +++ b/tests/test_show_summary.py @@ -0,0 +1,16 @@ +import pytest + +def test_welcome_page_when_loading_accepted(client, setup_data): + """TEST: The welcome page should load when credentials are correct""" + response = client.post('/show_summary', data={'email': 'clubA@example.com'}) + + assert response.status_code == 200 + assert b"Welcome" in response.data + assert b"Competition 1" in response.data + +def test_error_when_wrong_credentials(client, setup_data): + """TEST: Wrong credentials should redirect to index with an error message""" + response = client.post('/show_summary', data={'email': 'fake@example.com'}, follow_redirects=True) + + assert response.status_code == 200 + assert b"Wrong credentials, please retry" in response.data