Skip to content

Commit

Permalink
(PC-31217)[API]feat: ean validation feature flip activation
Browse files Browse the repository at this point in the history
  • Loading branch information
pcharlet-pass committed Sep 4, 2024
1 parent 584bf75 commit 462a6c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 2 additions & 1 deletion api/src/pcapi/core/offers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@ def create_draft_offer(
body.extra_data = _format_extra_data(body.subcategory_id, body.extra_data) or {}
validation.check_offer_extra_data(body.subcategory_id, body.extra_data, venue, is_from_private_api)

validation.check_product_for_venue_and_subcategory(product, body.subcategory_id, venue.venueTypeCode)
if feature.FeatureToggle.WIP_EAN_CREATION.is_active():
validation.check_product_for_venue_and_subcategory(product, body.subcategory_id, venue.venueTypeCode)

fields = {key: value for key, value in body.dict(by_alias=True).items() if key != "venueId"}
fields.update(_get_accessibility_compliance_fields(venue))
Expand Down
3 changes: 3 additions & 0 deletions api/tests/routes/pro/post_draft_offer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pcapi.core.offerers.factories as offerers_factories
import pcapi.core.offers.factories as offers_factories
from pcapi.core.offers.models import Offer
from pcapi.core.testing import override_features
import pcapi.core.users.factories as users_factories
from pcapi.routes.native.v1.serialization.offerers import VenueTypeCode

Expand Down Expand Up @@ -265,6 +266,7 @@ def test_fail_if_unknown_subcategory(self, client):
assert response.status_code == 400
assert response.json["subcategory"] == ["La sous-catégorie de cette offre est inconnue"]

@override_features(WIP_EAN_CREATION=True)
def test_fail_if_venue_is_record_store_offer_is_cd_or_vinyl_without_product(self, client):
venue = offerers_factories.VenueFactory(venueTypeCode=VenueTypeCode.RECORD_STORE)
offerer = venue.managingOfferer
Expand All @@ -281,6 +283,7 @@ def test_fail_if_venue_is_record_store_offer_is_cd_or_vinyl_without_product(self
assert response.status_code == 400
assert response.json["ean"] == ["EAN non reconnu. Assurez-vous qu'il n'y ait pas d'erreur de saisie."]

@override_features(WIP_EAN_CREATION=True)
def test_fail_if_venue_is_record_store_offer_is_cd_or_vinyl_with_unknown_product(self, client):
venue = offerers_factories.VenueFactory(venueTypeCode=VenueTypeCode.RECORD_STORE)
offerer = venue.managingOfferer
Expand Down

0 comments on commit 462a6c9

Please sign in to comment.