-
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 tests de performance sur les deux formulaires création/modif…
…ication d'une fiche zone délimitée pour valider le fix.
- Loading branch information
Showing
3 changed files
with
89 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
from django.urls import reverse | ||
|
||
from model_bakery import baker | ||
|
||
from sv.forms import RattachementChoices | ||
from sv.models import Etat, OrganismeNuisible, FicheDetection | ||
|
||
BASE_NUM_QUERIES = 7 | ||
|
||
|
||
def test_add_fiche_zone_delimitee_form_with_multiple_existing_fiche_detection( | ||
client, django_assert_num_queries, mocked_authentification_user | ||
): | ||
"""Vérifie que le nombre de requêtes SQL générées lors du chargement du formulaire de création d'une zone délimitée reste constant, | ||
quel que soit le nombre de fiches de détection affichées dans les champs hors zone infestée et zone infestée""" | ||
organisme_nuisible = baker.make(OrganismeNuisible) | ||
etat = Etat.objects.get(id=Etat.get_etat_initial()) | ||
detections = baker.make( | ||
FicheDetection, | ||
_fill_optional=True, | ||
etat=etat, | ||
createur=mocked_authentification_user.agent.structure, | ||
hors_zone_infestee=None, | ||
zone_infestee=None, | ||
organisme_nuisible=organisme_nuisible, | ||
_quantity=3, | ||
) | ||
url = f"{reverse('fiche-zone-delimitee-creation')}?fiche_detection_id={detections[0].pk}&rattachement={RattachementChoices.HORS_ZONE_INFESTEE}" | ||
client.get(url) | ||
|
||
with django_assert_num_queries(BASE_NUM_QUERIES): | ||
client.get(url) | ||
|
||
baker.make( | ||
FicheDetection, | ||
_fill_optional=True, | ||
etat=etat, | ||
createur=mocked_authentification_user.agent.structure, | ||
hors_zone_infestee=None, | ||
zone_infestee=None, | ||
organisme_nuisible=organisme_nuisible, | ||
_quantity=3, | ||
) | ||
with django_assert_num_queries(BASE_NUM_QUERIES): | ||
client.get(url) |
File renamed without changes.
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,44 @@ | ||
from model_bakery import baker | ||
|
||
from sv.models import Etat, OrganismeNuisible, FicheDetection | ||
|
||
BASE_NUM_QUERIES = 10 | ||
|
||
|
||
def test_update_fiche_zone_delimitee_form_with_multiple_existing_fiche_detection( | ||
client, django_assert_num_queries, mocked_authentification_user, fiche_zone_bakery | ||
): | ||
"""Vérifie que le nombre de requêtes SQL générées lors du chargement du formulaire de modification d'une zone délimitée reste constant, | ||
quel que soit le nombre de fiches de détection affichées dans les champs hors zone infestée et zone infestée""" | ||
organisme_nuisible = baker.make(OrganismeNuisible) | ||
etat = Etat.objects.get(id=Etat.get_etat_initial()) | ||
baker.make( | ||
FicheDetection, | ||
_fill_optional=True, | ||
etat=etat, | ||
createur=mocked_authentification_user.agent.structure, | ||
hors_zone_infestee=None, | ||
zone_infestee=None, | ||
organisme_nuisible=organisme_nuisible, | ||
_quantity=3, | ||
) | ||
fiche_zone_delimitee = fiche_zone_bakery() | ||
fiche_zone_delimitee.organisme_nuisible = organisme_nuisible | ||
fiche_zone_delimitee.save() | ||
client.get(fiche_zone_delimitee.get_update_url()) | ||
|
||
with django_assert_num_queries(BASE_NUM_QUERIES): | ||
client.get(fiche_zone_delimitee.get_update_url()) | ||
|
||
baker.make( | ||
FicheDetection, | ||
_fill_optional=True, | ||
etat=etat, | ||
createur=mocked_authentification_user.agent.structure, | ||
hors_zone_infestee=None, | ||
zone_infestee=None, | ||
organisme_nuisible=organisme_nuisible, | ||
_quantity=3, | ||
) | ||
with django_assert_num_queries(BASE_NUM_QUERIES): | ||
client.get(fiche_zone_delimitee.get_update_url()) |