-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ajout de paramètres de limitation #67
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fbda022
Limitation du nombre d'animations par utilisateur - cf #53
amandine-sahl b0c1c00
Limitation du nombre de participants à une animation - cf #51
amandine-sahl 2faac00
Black
amandine-sahl 804301b
Changelog
amandine-sahl b863905
Controle du nombre de participants lors d'update
amandine-sahl 640aa3e
Correction orthographe
amandine-sahl bd85cc1
Paramètres conftest
amandine-sahl 580855e
Rename param
amandine-sahl bbdacf7
Changelog
amandine-sahl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class EventIsFull(Exception): | ||
pass | ||
|
||
|
||
class NotBookable(Exception): | ||
pass | ||
|
||
|
||
class UserEventNbExceded(Exception): | ||
pass | ||
|
||
|
||
class UserEventNbExcededAdmin(Exception): | ||
pass | ||
|
||
|
||
class UserEventNbExcededUser(Exception): | ||
pass | ||
|
||
|
||
class ParticipantNbExceded(Exception): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
from sqlalchemy import select | ||
from core.models import GTEvents, TReservations | ||
from core.models import TTokens | ||
from core.routes import EventIsFull | ||
from core.exceptions import EventIsFull | ||
from core.env import db | ||
|
||
from .utils import login | ||
|
@@ -41,6 +41,21 @@ | |
"num_departement": "48", | ||
"confirmed": True, | ||
} | ||
TEST_RESERVATION_1_PERSONNE = { | ||
"nom": "BLAIR", | ||
"prenom": "Eric", | ||
"commentaire": "saisie test", | ||
"tel": "00 00 00 00 00 ", | ||
"email": "[email protected]", | ||
"nb_adultes": 1, | ||
"nb_moins_6_ans": 0, | ||
"nb_6_8_ans": 0, | ||
"nb_9_12_ans": 0, | ||
"nb_plus_12_ans": 0, | ||
"num_departement": "48", | ||
"confirmed": True, | ||
} | ||
|
||
TEST_BILAN = { | ||
"commentaire": "test bilan", | ||
"nb_6_8_ans": 1, | ||
|
@@ -242,6 +257,37 @@ def test_post_export_and_cancel_one_reservation(self, events): | |
assert resa.cancelled == True | ||
assert resa.cancel_by == "admin" | ||
|
||
def test_post_limit_nb_animations(self, events): | ||
login(self.client) | ||
# Create reservation | ||
event = db.session.scalars( | ||
select(GTEvents) | ||
.where(GTEvents.name == "Pytest bookable") | ||
.order_by(GTEvents.id.desc()) | ||
).first() | ||
|
||
data_resa = TEST_RESERVATION_1_PERSONNE | ||
data_resa["id_event"] = event.id | ||
|
||
nb_limit_per_user = current_app.config["NB_ANIM_MAX_PER_USER"] | ||
|
||
# Création du nombre de reservation spécifié dans NB_ANIM_MAX_PER_USER | ||
for loop in range(nb_limit_per_user): | ||
resp = post_json( | ||
self.client, url_for("app_routes.post_reservations"), data_resa | ||
) | ||
assert resp == 200 | ||
|
||
# Ajout de 1 reservation ce qui doit retourner une erreur | ||
resp = post_json( | ||
self.client, url_for("app_routes.post_reservations"), data_resa | ||
) | ||
assert resp.status_code == 422 | ||
assert ( | ||
json_of_response(resp)["error"] | ||
== "La limite du nombre de réservation pour cet utilisateur est atteinte" | ||
) | ||
|
||
# def test_post_one_bilan(self): | ||
# # POST | ||
# event = GTEvents.query.limit(1).one() | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça ce n'est pas plutôt variable d'une animation à l'autre ?
C'est le nombre de places totales à chaque animation.
A moins que cela concerne le nombre de personne qu'un même utilisateur peut inscrire lui-même ?
Si c'est le cas, renommer et clarifier le paramètre ?