From f1259727b692582d89901bd70a7bea2ba081046d Mon Sep 17 00:00:00 2001 From: Pierre Charlet <178303187+pcharlet-pass@users.noreply.github.com> Date: Thu, 6 Feb 2025 15:51:19 +0100 Subject: [PATCH] (PC-34441)[API] fix: fix patch draft offer with empty ean --- api/src/pcapi/core/offers/api.py | 2 +- api/tests/routes/pro/patch_draft_offer_test.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/src/pcapi/core/offers/api.py b/api/src/pcapi/core/offers/api.py index e8675d7e2db..436dc951caa 100644 --- a/api/src/pcapi/core/offers/api.py +++ b/api/src/pcapi/core/offers/api.py @@ -267,7 +267,7 @@ def update_draft_offer(offer: models.Offer, body: offers_schemas.PatchDraftOffer offer.subcategoryId, formatted_extra_data, offer.venue, is_from_private_api=True, offer=offer ) # TODO: (pcharlet, 2025-02-04): Delete next line when body schemas contains specific EAN field outside extraData - updates.update({"ean": updates["extraData"].get("ean", None)}) + updates.update({"ean": formatted_extra_data.get("ean", None)}) for key, value in updates.items(): setattr(offer, key, value) diff --git a/api/tests/routes/pro/patch_draft_offer_test.py b/api/tests/routes/pro/patch_draft_offer_test.py index 5f398de67f7..522e6fdea17 100644 --- a/api/tests/routes/pro/patch_draft_offer_test.py +++ b/api/tests/routes/pro/patch_draft_offer_test.py @@ -154,6 +154,7 @@ def test_patch_draft_offer_with_empty_extra_data(self, client): "speaker": "", "stageDirector": "", "visa": "", + "ean": "", }, } response = client.with_session_auth("user@example.com").patch(f"/offers/draft/{offer.id}", json=data) @@ -170,6 +171,7 @@ def test_patch_draft_offer_with_empty_extra_data(self, client): "speaker": "", "stageDirector": "", "visa": "", + "ean": "", } @pytest.mark.features(WIP_EAN_CREATION=False)