-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-31217)[API]feat: changes after review, merged validation over pro…
…duct and ean code, commit will be merged with previous one after review
- Loading branch information
1 parent
03d3553
commit 5f2d29a
Showing
5 changed files
with
24 additions
and
46 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 |
---|---|---|
|
@@ -89,7 +89,6 @@ def when_trying_to_patch_forbidden_attributes(self, client): | |
assert key in response.json | ||
|
||
def when_trying_to_patch_ean(self, client): | ||
# Given | ||
user_offerer = offerers_factories.UserOffererFactory(user__email="[email protected]") | ||
venue = offerers_factories.VenueFactory( | ||
managingOfferer=user_offerer.offerer, venueTypeCode=VenueTypeCode.RECORD_STORE | ||
|
@@ -101,16 +100,13 @@ def when_trying_to_patch_ean(self, client): | |
description="description", | ||
) | ||
|
||
# When | ||
data = {"extraData": {"ean": "1234567891234"}} | ||
response = client.with_session_auth("[email protected]").patch(f"offers/draft/{offer.id}", json=data) | ||
|
||
# Then | ||
assert response.status_code == 400 | ||
assert response.json["ean"] == ["Vous ne pouvez pas changer cette information"] | ||
|
||
def when_trying_to_patch_product(self, client): | ||
# Given | ||
user_offerer = offerers_factories.UserOffererFactory(user__email="[email protected]") | ||
venue = offerers_factories.VenueFactory( | ||
managingOfferer=user_offerer.offerer, venueTypeCode=VenueTypeCode.RECORD_STORE | ||
|
@@ -123,11 +119,9 @@ def when_trying_to_patch_product(self, client): | |
) | ||
product = offers_factories.ProductFactory(subcategoryId=subcategories.LIVRE_PAPIER.id) | ||
|
||
# When | ||
data = {"product_id": product.id} | ||
response = client.with_session_auth("[email protected]").patch(f"offers/draft/{offer.id}", json=data) | ||
|
||
# Then | ||
assert response.status_code == 400 | ||
assert response.json["product_id"] == ["Vous ne pouvez pas changer cette information"] | ||
|
||
|
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 |
---|---|---|
|
@@ -19,7 +19,7 @@ def test_created_offer_should_be_inactive(self, client): | |
"name": "Celeste", | ||
"subcategoryId": subcategories.LIVRE_PAPIER.id, | ||
"venueId": venue.id, | ||
"extraData": {"ean": "9782123456803", "gtl_id": "07000000"}, | ||
"extraData": {"gtl_id": "07000000"}, | ||
} | ||
response = client.with_session_auth("[email protected]").post("/offers/draft", json=data) | ||
|
||
|
@@ -33,14 +33,16 @@ def test_created_offer_should_be_inactive(self, client): | |
assert response_dict["name"] == "Celeste" | ||
assert response_dict["id"] == offer.id | ||
assert response_dict["productId"] == None | ||
assert response_dict["extraData"] == {"ean": "9782123456803", "gtl_id": "07000000"} | ||
assert response_dict["extraData"] == {"gtl_id": "07000000"} | ||
assert not offer.product | ||
|
||
def test_created_offer_from_product_should_return_product_id(self, client): | ||
venue = offerers_factories.VenueFactory() | ||
offerer = venue.managingOfferer | ||
offerers_factories.UserOffererFactory(offerer=offerer, user__email="[email protected]") | ||
product = offers_factories.ProductFactory(subcategoryId=subcategories.LIVRE_PAPIER.id) | ||
product = offers_factories.ProductFactory( | ||
subcategoryId=subcategories.LIVRE_PAPIER.id, extraData=dict({"ean": "9782123456803"}) | ||
) | ||
|
||
data = { | ||
"name": "Celeste", | ||
|
@@ -309,7 +311,7 @@ def test_fail_if_product_does_not_exists(self, client): | |
response = client.with_session_auth("[email protected]").post("/offers/draft", json=data) | ||
|
||
assert response.status_code == 400 | ||
assert response.json["productId"] == ["This product does not exists."] | ||
assert response.json["ean"] == ["EAN non reconnu. Assurez-vous qu'il n'y ait pas d'erreur de saisie."] | ||
|
||
@pytest.mark.parametrize("subcategory_id", ["OEUVRE_ART", "BON_ACHAT_INSTRUMENT"]) | ||
def test_fail_if_inactive_subcategory(self, client, subcategory_id): | ||
|