style: formater le depot avec ruff format
QUA-002, premiere moitie. **Ce commit ne fait que reformater** : aucun changement de comportement, aucune ligne de logique touchee. 72 fichiers, 4 restaient deja conformes. Il est isole exprès, pour que `git log -p` sur les commits voisins reste lisible. `quote-style = "preserve"` etait deja pose dans pyproject.toml, ce qui evite le brassage guillemets simples / doubles : le diff porte sur les retours a la ligne, l indentation des appels longs et les virgules finales, pas sur le style de chaine. Verification : 263 tests passent avant et apres, ruff check propre. L activation en CI arrive dans le commit suivant, separement, pour que ce diff-ci ne contienne rien d autre. Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
+66
-39
@@ -17,8 +17,17 @@ import pytest
|
||||
|
||||
from app.extensions import db
|
||||
from app.models import (
|
||||
Match, MatchParticipant, OrgTeam, PersonalNote, Team, TeamMatch,
|
||||
TeamMember, TeamNote, TeamPlayer, Tryout, TryoutRegistration,
|
||||
Match,
|
||||
MatchParticipant,
|
||||
OrgTeam,
|
||||
PersonalNote,
|
||||
Team,
|
||||
TeamMatch,
|
||||
TeamMember,
|
||||
TeamNote,
|
||||
TeamPlayer,
|
||||
Tryout,
|
||||
TryoutRegistration,
|
||||
)
|
||||
|
||||
|
||||
@@ -38,8 +47,13 @@ def world(app, make_user):
|
||||
db.session.add(org_team)
|
||||
db.session.flush()
|
||||
|
||||
tryout = Tryout(title='Spring', game='Valorant', date=date(2030, 4, 1),
|
||||
created_by=admin_id, target_org_team_id=org_team.id)
|
||||
tryout = Tryout(
|
||||
title='Spring',
|
||||
game='Valorant',
|
||||
date=date(2030, 4, 1),
|
||||
created_by=admin_id,
|
||||
target_org_team_id=org_team.id,
|
||||
)
|
||||
db.session.add(tryout)
|
||||
db.session.flush()
|
||||
|
||||
@@ -47,36 +61,57 @@ def world(app, make_user):
|
||||
db.session.add(team)
|
||||
db.session.flush()
|
||||
|
||||
match = Match(tryout_id=tryout.id, title='Scrim', date=date(2030, 4, 2),
|
||||
start_time=time(18, 0), match_type='player_scrim',
|
||||
created_by=admin_id)
|
||||
match = Match(
|
||||
tryout_id=tryout.id,
|
||||
title='Scrim',
|
||||
date=date(2030, 4, 2),
|
||||
start_time=time(18, 0),
|
||||
match_type='player_scrim',
|
||||
created_by=admin_id,
|
||||
)
|
||||
db.session.add(match)
|
||||
db.session.flush()
|
||||
|
||||
db.session.add_all([
|
||||
TryoutRegistration(tryout_id=tryout.id, player_id=player_id),
|
||||
TeamMember(team_id=team.id, player_id=player_id),
|
||||
MatchParticipant(match_id=match.id, player_id=player_id),
|
||||
TeamPlayer(player_id=player_id, org_team_id=org_team.id),
|
||||
TeamNote(org_team_id=org_team.id, coach_id=coach_id, content='Team note'),
|
||||
TeamMatch(org_team_id=org_team.id, title='Season match',
|
||||
date=date(2030, 4, 5), created_by=admin_id),
|
||||
# A note referencing all three contexts at once.
|
||||
PersonalNote(player_id=player_id, coach_id=coach_id,
|
||||
content='Watch the entries',
|
||||
match_id=match.id, team_id=team.id, tryout_id=tryout.id),
|
||||
])
|
||||
db.session.add_all(
|
||||
[
|
||||
TryoutRegistration(tryout_id=tryout.id, player_id=player_id),
|
||||
TeamMember(team_id=team.id, player_id=player_id),
|
||||
MatchParticipant(match_id=match.id, player_id=player_id),
|
||||
TeamPlayer(player_id=player_id, org_team_id=org_team.id),
|
||||
TeamNote(org_team_id=org_team.id, coach_id=coach_id, content='Team note'),
|
||||
TeamMatch(
|
||||
org_team_id=org_team.id,
|
||||
title='Season match',
|
||||
date=date(2030, 4, 5),
|
||||
created_by=admin_id,
|
||||
),
|
||||
# A note referencing all three contexts at once.
|
||||
PersonalNote(
|
||||
player_id=player_id,
|
||||
coach_id=coach_id,
|
||||
content='Watch the entries',
|
||||
match_id=match.id,
|
||||
team_id=team.id,
|
||||
tryout_id=tryout.id,
|
||||
),
|
||||
]
|
||||
)
|
||||
db.session.commit()
|
||||
|
||||
return {
|
||||
'admin_id': admin_id, 'coach_id': coach_id, 'player_id': player_id,
|
||||
'org_team_id': org_team.id, 'tryout_id': tryout.id,
|
||||
'team_id': team.id, 'match_id': match.id,
|
||||
'admin_id': admin_id,
|
||||
'coach_id': coach_id,
|
||||
'player_id': player_id,
|
||||
'org_team_id': org_team.id,
|
||||
'tryout_id': tryout.id,
|
||||
'team_id': team.id,
|
||||
'match_id': match.id,
|
||||
}
|
||||
|
||||
|
||||
def _login_admin(client, app, admin_id, login):
|
||||
from app.models import User
|
||||
|
||||
with app.app_context():
|
||||
username = db.session.get(User, admin_id).username
|
||||
login(username)
|
||||
@@ -89,8 +124,7 @@ class TestDeleteMatch:
|
||||
def test_a_populated_match_can_be_deleted(self, app, client, world, login):
|
||||
_login_admin(client, app, world['admin_id'], login)
|
||||
|
||||
response = client.post(f"/matches/{world['match_id']}/delete",
|
||||
follow_redirects=False)
|
||||
response = client.post(f"/matches/{world['match_id']}/delete", follow_redirects=False)
|
||||
|
||||
assert response.status_code < 500, 'deleting a used match raised'
|
||||
with app.app_context():
|
||||
@@ -102,8 +136,7 @@ class TestDeleteMatch:
|
||||
client.post(f"/matches/{world['match_id']}/delete", follow_redirects=True)
|
||||
|
||||
with app.app_context():
|
||||
assert MatchParticipant.query.filter_by(
|
||||
match_id=world['match_id']).count() == 0
|
||||
assert MatchParticipant.query.filter_by(match_id=world['match_id']).count() == 0
|
||||
|
||||
def test_notes_survive_but_lose_their_match_context(self, app, client, world, login):
|
||||
"""A coach's observation keeps its value once the match is gone;
|
||||
@@ -125,8 +158,7 @@ class TestDeleteTryout:
|
||||
def test_a_populated_tryout_can_be_deleted(self, app, client, world, login):
|
||||
_login_admin(client, app, world['admin_id'], login)
|
||||
|
||||
response = client.post(f"/tryouts/{world['tryout_id']}/delete",
|
||||
follow_redirects=False)
|
||||
response = client.post(f"/tryouts/{world['tryout_id']}/delete", follow_redirects=False)
|
||||
|
||||
assert response.status_code < 500
|
||||
with app.app_context():
|
||||
@@ -140,8 +172,7 @@ class TestDeleteTryout:
|
||||
with app.app_context():
|
||||
assert db.session.get(Match, world['match_id']) is None
|
||||
assert db.session.get(Team, world['team_id']) is None
|
||||
assert TryoutRegistration.query.filter_by(
|
||||
tryout_id=world['tryout_id']).count() == 0
|
||||
assert TryoutRegistration.query.filter_by(tryout_id=world['tryout_id']).count() == 0
|
||||
|
||||
def test_notes_survive_the_tryout(self, app, client, world, login):
|
||||
_login_admin(client, app, world['admin_id'], login)
|
||||
@@ -164,8 +195,7 @@ class TestDeleteTeam:
|
||||
def test_a_populated_team_can_be_deleted(self, app, client, world, login):
|
||||
_login_admin(client, app, world['admin_id'], login)
|
||||
|
||||
response = client.post(f"/teams/{world['org_team_id']}/delete",
|
||||
follow_redirects=False)
|
||||
response = client.post(f"/teams/{world['org_team_id']}/delete", follow_redirects=False)
|
||||
|
||||
assert response.status_code < 500
|
||||
with app.app_context():
|
||||
@@ -177,12 +207,9 @@ class TestDeleteTeam:
|
||||
client.post(f"/teams/{world['org_team_id']}/delete", follow_redirects=True)
|
||||
|
||||
with app.app_context():
|
||||
assert TeamNote.query.filter_by(
|
||||
org_team_id=world['org_team_id']).count() == 0
|
||||
assert TeamMatch.query.filter_by(
|
||||
org_team_id=world['org_team_id']).count() == 0
|
||||
assert TeamPlayer.query.filter_by(
|
||||
org_team_id=world['org_team_id']).count() == 0
|
||||
assert TeamNote.query.filter_by(org_team_id=world['org_team_id']).count() == 0
|
||||
assert TeamMatch.query.filter_by(org_team_id=world['org_team_id']).count() == 0
|
||||
assert TeamPlayer.query.filter_by(org_team_id=world['org_team_id']).count() == 0
|
||||
|
||||
def test_the_tryout_survives_and_is_detached(self, app, client, world, login):
|
||||
"""A tryout outlives the team it was aimed at."""
|
||||
|
||||
Reference in New Issue
Block a user