Skip to content

Commit

Permalink
Corriger les prélèvements sans date
Browse files Browse the repository at this point in the history
Ce commit corrige le cas où l'on créé un lieu et un prélèvement sans
date.

Fixes SEVES-Y
  • Loading branch information
Anto59290 committed Nov 14, 2024
1 parent 8c431ad commit 97c3bb4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions sv/tests/test_fichedetection_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,33 @@ def test_add_new_prelevement_non_officiel(
assert prelevement_from_db.laboratoire_confirmation_officielle is None


@pytest.mark.django_db
def test_add_new_prelevement_with_empty_date(
live_server,
page: Page,
fiche_detection: FicheDetection,
form_elements: FicheDetectionFormDomElements,
prelevement_form_elements: PrelevementFormDomElements,
choice_js_fill,
lieu_form_elements,
):
page.goto(f"{live_server.url}{get_fiche_detection_update_form_url(fiche_detection)}")
form_elements.add_lieu_btn.click()
lieu_form_elements.nom_input.fill("Test")
lieu_form_elements.save_btn.click()
form_elements.add_prelevement_btn.click()
prelevement_form_elements.lieu_input.select_option("Test")
prelevement_form_elements.structure_input.select_option("DSF")
page.get_by_test_id("prelevement-form-resultat-detecte").click()
prelevement_form_elements.save_btn.click()
form_elements.save_update_btn.click()
page.wait_for_timeout(600)

prelevement_from_db = Prelevement.objects.get()
assert prelevement_from_db.date_prelevement is None
assert prelevement_from_db.resultat == "detecte"


@pytest.mark.django_db
def test_add_new_prelevement_officiel(
live_server,
Expand Down
2 changes: 1 addition & 1 deletion sv/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ def update_prelevements(self, prelevements, lieux, fiche_detection):
prelevement.lieu_id = prel["lieu_pk"]
prelevement.structure_preleveur_id = prel["structurePreleveurId"]
prelevement.numero_echantillon = prel["numeroEchantillon"] if prel["numeroEchantillon"] else ""
prelevement.date_prelevement = prel["datePrelevement"]
prelevement.date_prelevement = prel["datePrelevement"] if prel["datePrelevement"] else None
prelevement.site_inspection_id = prel["siteInspectionId"]
prelevement.matrice_prelevee_id = prel["matricePreleveeId"]
prelevement.espece_echantillon_id = prel["especeEchantillonId"]
Expand Down

0 comments on commit 97c3bb4

Please sign in to comment.