-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajout de paramètres de limitation (#67)
* Limitation du nombre d'animations par utilisateur - cf #53 * Limitation du nombre de participants à une animation - cf #51 * Controle du nombre de participants lors d'update
- Loading branch information
1 parent
5f317ba
commit cbf5c7a
Showing
9 changed files
with
295 additions
and
20 deletions.
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.