ajout d'un toggle pour permission d'upload des documents dans admin pannel
CI - Security, Lint & Tests / validate (push) Failing after 1m3s

ajout de compteur d'heure disponible
ajout du calendrier de dispo dans les profils publics
This commit is contained in:
cedrick2711
2026-08-26 22:33:24 -04:00
parent 820cccb25e
commit bfb25f4d16
16 changed files with 1966 additions and 74 deletions
+116
View File
@@ -0,0 +1,116 @@
"""Tests for the hours column in the user list and the read-only
availability grid on public profiles."""
from datetime import time
from app.extensions import db
from app.models import (
CoachAvailability,
PlayerDisponibility,
)
class TestHoursColumn:
"""The manage-users table shows available hours for players/coaches."""
def test_admin_sees_hours_header(self, app, client, as_role):
as_role('admin')
body = client.get('/users').get_data(as_text=True)
# Default locale is French, so _("Hours") renders as "Heures"
assert 'Heures' in body
def test_player_without_slots_shows_0(self, app, client, as_role, make_user):
as_role('admin')
make_user('player') # create a player but stay logged in as admin
body = client.get('/users').get_data(as_text=True)
assert '0.0' in body
def test_player_with_slots_shows_hours(self, app, client, as_role, make_user):
as_role('admin')
player_id = make_user('player')
with app.app_context():
db.session.add(
PlayerDisponibility(
player_id=player_id,
day_of_week=0,
start_time=time(17, 0),
end_time=time(19, 0),
)
)
db.session.add(
PlayerDisponibility(
player_id=player_id,
day_of_week=1,
start_time=time(18, 0),
end_time=time(20, 0),
)
)
db.session.commit()
body = client.get('/users').get_data(as_text=True)
# 2h + 2h = 4.0
assert '4.0' in body
def test_coach_without_slots_shows_0(self, app, client, as_role, make_user):
as_role('admin')
make_user('coach')
body = client.get('/users').get_data(as_text=True)
assert '0.0' in body
def test_admin_roles_show_dash(self, app, client, as_role, make_user):
as_role('admin')
make_user('manager')
make_user('scout')
body = client.get('/users').get_data(as_text=True)
# managers and scouts should show mdash
assert '\u2014' in body
class TestAvailabilityOnPublicProfile:
"""view_user renders a weekly availability grid for players/coaches."""
def test_player_without_availability_shows_no_grid(self, app, client, as_role):
as_role('admin')
player_id = as_role('player')
body = client.get(f'/users/{player_id}/view').get_data(as_text=True)
# Default locale is French
assert 'Disponibilit\u00e9s' not in body
def test_player_with_slots_shows_grid(self, app, client, as_role, make_user):
as_role('admin')
player_id = make_user('player')
with app.app_context():
db.session.add(
PlayerDisponibility(
player_id=player_id,
day_of_week=2,
start_time=time(18, 0),
end_time=time(18, 30),
)
)
db.session.commit()
body = client.get(f'/users/{player_id}/view').get_data(as_text=True)
assert 'Disponibilit\u00e9s' in body
assert '18:00' in body
def test_coach_with_slots_shows_grid(self, app, client, as_role, make_user):
as_role('admin')
coach_id = make_user('coach')
with app.app_context():
db.session.add(
CoachAvailability(
coach_id=coach_id,
day_of_week=3,
start_time=time(10, 0),
end_time=time(10, 30),
)
)
db.session.commit()
body = client.get(f'/users/{coach_id}/view').get_data(as_text=True)
assert 'Disponibilit\u00e9s' in body
assert '10:00' in body
def test_admin_profile_shows_no_grid(self, app, client, as_role):
admin_id = as_role('admin')
body = client.get(f'/users/{admin_id}/view').get_data(as_text=True)
assert 'Disponibilit\u00e9s' not in body