From 788ae04ebb4fc6576973c173c7e86452c69cf3b3 Mon Sep 17 00:00:00 2001 From: Coureau Date: Mon, 15 Jun 2026 08:27:44 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Configuration=20de=20l'environnement=20de?= =?UTF-8?q?=20tests=20et=20mise=20=C3=A0=20jour=20des=20d=C3=A9pendances?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 - pytest.ini | 2 ++ requirements.txt | 15 +++++++++------ tests/__init__.py | 0 tests/conftest.py | 11 +++++++++++ tests/functional/__init__.py | 0 tests/integration/__init__.py | 0 tests/unit/__init__.py | 0 8 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 pytest.ini create mode 100644 tests/__init__.py create mode 100644 tests/conftest.py create mode 100644 tests/functional/__init__.py create mode 100644 tests/integration/__init__.py create mode 100644 tests/unit/__init__.py diff --git a/.gitignore b/.gitignore index 2cba99d87..950060a15 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,5 @@ bin include lib .Python -tests/ .envrc __pycache__ \ No newline at end of file diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 000000000..de19c9f0b --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +testpaths = tests \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 139affa05..8f10818fd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,9 @@ -click==7.1.2 -Flask==1.1.2 -itsdangerous==1.1.0 -Jinja2==2.11.2 -MarkupSafe==1.1.1 -Werkzeug==1.0.1 +click==8.1.7 +Flask==3.0.3 +itsdangerous==2.2.0 +Jinja2==3.1.4 +MarkupSafe==2.1.5 +Werkzeug==3.0.4 +pytest==8.3.3 +pytest-cov==5.0.0 +locust==2.31.6 \ No newline at end of file diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..570ed6d5b --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,11 @@ +import pytest + +import server + + +@pytest.fixture +def client(): + server.app.config['TESTING'] = True + with server.app.test_client() as client: + yield client + diff --git a/tests/functional/__init__.py b/tests/functional/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 000000000..e69de29bb From c96a4032b3f4f784040897744f04df9d6953b887 Mon Sep 17 00:00:00 2001 From: Coureau Date: Tue, 16 Jun 2026 07:03:42 +0200 Subject: [PATCH 2/4] #1 : Gestion de l'email inconnu sans crash de l'application --- server.py | 8 ++++++-- templates/index.html | 9 +++++++++ tests/integration/test_login.py | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/integration/test_login.py diff --git a/server.py b/server.py index 4084baeac..2406bbfc5 100644 --- a/server.py +++ b/server.py @@ -26,8 +26,12 @@ def index(): @app.route('/showSummary',methods=['POST']) def showSummary(): - club = [club for club in clubs if club['email'] == request.form['email']][0] - return render_template('welcome.html',club=club,competitions=competitions) + matching_clubs = [c for c in clubs if c['email'] == request.form['email']] + if not matching_clubs: + flash("Sorry, that email was not found.") + return redirect(url_for('index')) + club = matching_clubs[0] + return render_template('welcome.html', club=club, competitions=competitions) @app.route('/book//') diff --git a/templates/index.html b/templates/index.html index 926526b7d..ecfe61c61 100644 --- a/templates/index.html +++ b/templates/index.html @@ -5,6 +5,15 @@ GUDLFT Registration + {% with messages = get_flashed_messages() %} + {% if messages %} +
    + {% for message in messages %} +
  • {{ message }}
  • + {% endfor %} +
+ {% endif %} + {% endwith %}

Welcome to the GUDLFT Registration Portal!

Please enter your secretary email to continue:
diff --git a/tests/integration/test_login.py b/tests/integration/test_login.py new file mode 100644 index 000000000..c7cc014af --- /dev/null +++ b/tests/integration/test_login.py @@ -0,0 +1,19 @@ +def test_login_with_valid_email_shows_summary(client): + """Happy path : un email connu doit afficher la page de résumé.""" + response = client.post( + "/showSummary", + data={"email": "john@simplylift.co"}, + ) + assert response.status_code == 200 + assert b"john@simplylift.co" in response.data + + +def test_login_with_unknown_email_does_not_crash(client): + """Sad path (bug #1) : un email inconnu ne doit pas faire planter l'appli.""" + response = client.post( + "/showSummary", + data={"email": "inconnu@test.com"}, + follow_redirects=True, + ) + assert response.status_code == 200 + assert b"Sorry, that email was not found." in response.data \ No newline at end of file From ae2939655ad07a3448c6e5c64580e67bdb41f9b3 Mon Sep 17 00:00:00 2001 From: Coureau Date: Wed, 24 Jun 2026 09:43:26 +0400 Subject: [PATCH 3/4] Ignorer les fichiers .DS_Store de macOS --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 04a508e6f6048834346c5f1769770f2ff01806e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHLyGjE=6uo02t_eaKAz-uO517KrW(_MA7J@PZnPF^o|@7E?}H@}hH>zFF|IYk+&(>@&}^;MVR8B@>u%kBB|j?|;;!fwo; zo=xxx7mLyiv%#By`qZRWl9&8+hRJ`mar)?NOa7sCOdaF15_(t-pML;FbyJ6!KU;}s zO#X0l^^;%MnY`&)lTU29%r{F%c%p~6LIPYLe0*qf<4f<4&N6je-xM$B)O9gpJyX-< zOj94xGV7aGn$QpFT6jp#ntB%7gTb4+E{u9p$LNeCe~tP7YGBXiaPkUmZym4>SO>lw z;OB#j#^`B`6v{^jI{69!%wkvuj^!Q=ba?>iX^a$N1R+!@P?ZY(iXl`v#$BD~X^a%A zauSjm>u6@7-%x~P$G9ugNq7ovZym4>Bpt}8j|JZU*T=vACyVSS>wtCOUpXMMe#I~2 zl=R-3Iyv5JU9=h+2j@i!WeGaH9m@mWiur#98JKhV0O)Cq6k-Hne+Wn$Y-b(#Q3pN% DK3B}k From e63477955192176af287d47cebb3063db70dff79 Mon Sep 17 00:00:00 2001 From: Coureau Date: Fri, 26 Jun 2026 12:18:11 +0400 Subject: [PATCH 4/4] =?UTF-8?q?#6=20:=20D=C3=A9duction=20=20des=20points?= =?UTF-8?q?=20du=20cub=20lors=20d'une=20r=C3=A9servation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server.py | 1 + tests/integration/test_purchase.py | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 tests/integration/test_purchase.py diff --git a/server.py b/server.py index 2406bbfc5..a58f8b437 100644 --- a/server.py +++ b/server.py @@ -51,6 +51,7 @@ def purchasePlaces(): club = [c for c in clubs if c['name'] == request.form['club']][0] placesRequired = int(request.form['places']) competition['numberOfPlaces'] = int(competition['numberOfPlaces'])-placesRequired + club['points'] = int(club['points']) - placesRequired flash('Great-booking complete!') return render_template('welcome.html', club=club, competitions=competitions) diff --git a/tests/integration/test_purchase.py b/tests/integration/test_purchase.py new file mode 100644 index 000000000..39748596c --- /dev/null +++ b/tests/integration/test_purchase.py @@ -0,0 +1,25 @@ +import server + + +def test_purchase_deducts_points_from_club(client): + """Bug #6 : les points utilises doivent etre deduits du solde du club.""" + # On choisit un club et une competition connus + club = next(c for c in server.clubs if c['name'] == "Simply Lift") + competition = next( + c for c in server.competitions if c['name'] == "Spring Festival" + ) + + points_avant = int(club['points']) + places_reservees = 3 + + client.post( + "/purchasePlaces", + data={ + "competition": competition['name'], + "club": club['name'], + "places": str(places_reservees), + }, + ) + + points_apres = int(club['points']) + assert points_apres == points_avant - places_reservees \ No newline at end of file