fix(audit): moderniser les accès ORM
CI - Security, Lint & Tests / validate (push) Failing after 19m37s

This commit is contained in:
GGThed
2026-08-17 15:02:29 -04:00
parent 105a72700f
commit d7a8907953
16 changed files with 179 additions and 86 deletions
+72
View File
@@ -269,6 +269,78 @@ class TestRegisteredPlayersForMatchForm:
assert counter.total == 1
class TestEvaluationLists:
"""Evaluation pages must not issue one lookup per player or evaluator."""
def test_players_to_evaluate_has_a_fixed_query_budget(
self, app, client, as_role, make_user, count_queries
):
coach_id = as_role('coach')
admin_id = make_user('admin')
player_ids = [make_user('player') for _ in range(12)]
with app.app_context():
tryout = Tryout(
title='Evaluation budget',
game='Valorant',
date=date(2030, 3, 1),
created_by=admin_id,
coach_id=coach_id,
)
db.session.add(tryout)
db.session.flush()
for player_id in player_ids:
db.session.add(TryoutRegistration(tryout_id=tryout.id, player_id=player_id))
db.session.commit()
tryout_id = tryout.id
counter = count_queries()
try:
response = client.get(f'/evaluations/{tryout_id}/players')
finally:
counter.stop()
assert response.status_code == 200
assert 1 <= counter.total <= 10, f'{counter.total} SELECTs for 12 players'
def test_scout_top_players_are_loaded_with_the_aggregate(
self, app, client, as_role, make_user, count_queries
):
as_role('scout')
evaluator_id = make_user('coach')
admin_id = make_user('admin')
player_ids = [make_user('player') for _ in range(12)]
with app.app_context():
tryout = Tryout(
title='Scout budget',
game='Valorant',
date=date(2030, 3, 1),
created_by=admin_id,
)
db.session.add(tryout)
db.session.flush()
for score, player_id in enumerate(player_ids, start=1):
db.session.add(
Evaluation(
player_id=player_id,
evaluator_id=evaluator_id,
tryout_id=tryout.id,
overall_score=score,
)
)
db.session.commit()
counter = count_queries()
try:
response = client.get('/dashboard')
finally:
counter.stop()
assert response.status_code == 200
assert 1 <= counter.total <= 6, f'{counter.total} SELECTs for the scout dashboard'
class TestViewTryout:
"""PERF-001 — the most-visited page in the application ran one query
per registration, one per player evaluated, one per team, and one per