-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(PC-31953)[API] feat: Handle manual edition on pro side
- Loading branch information
1 parent
022bee4
commit f7847aa
Showing
5 changed files
with
70 additions
and
15 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 |
---|---|---|
|
@@ -132,6 +132,49 @@ def test_patch_offer_with_address(self, get_address_mock, label, offer_has_oa, a | |
assert address.postalCode == "75102" | ||
assert address.latitude == Decimal("48.85660") | ||
assert address.longitude == Decimal("2.3522") | ||
assert address.isManualEdition is False | ||
|
||
def test_patch_offer_with_manual_address_edition(self, client): | ||
# Given | ||
user_offerer = offerers_factories.UserOffererFactory(user__email="[email protected]") | ||
venue = offerers_factories.VenueFactory(managingOfferer=user_offerer.offerer) | ||
offer = offers_factories.OfferFactory( | ||
subcategoryId=subcategories.ABO_MEDIATHEQUE.id, | ||
venue=venue, | ||
name="New name", | ||
description="description", | ||
) | ||
|
||
# When | ||
data = { | ||
"name": "New name", | ||
"externalTicketOfficeUrl": "http://example.net", | ||
"mentalDisabilityCompliant": True, | ||
"address": { | ||
"street": "42, Rue qui n’existe pas", | ||
"city": "Ville inconnue", | ||
"postalCode": "00000", | ||
"latitude": 1, | ||
"longitude": 1, | ||
"label": "label", | ||
"isManualEdition": True, | ||
}, | ||
} | ||
|
||
response = client.with_session_auth("[email protected]").patch(f"/offers/{offer.id}", json=data) | ||
|
||
assert response.status_code == 200 | ||
assert response.json["id"] == offer.id | ||
updated_offer = Offer.query.get(offer.id) | ||
address = updated_offer.offererAddress.address | ||
assert updated_offer.offererAddress.label == "label" | ||
assert address.street == "42, Rue qui n’existe pas" | ||
assert address.city == "Ville inconnue" | ||
assert address.postalCode == "00000" | ||
assert address.latitude == Decimal("1") | ||
assert address.longitude == Decimal("1") | ||
assert address.isManualEdition is True | ||
|
||
|
||
@pytest.mark.parametrize("label", ["", None, True]) | ||
@patch("pcapi.connectors.api_adresse.get_address") | ||
|
@@ -193,6 +236,7 @@ def test_patch_offer_with_address_twice(self, get_address_mock, label, client): | |
assert address.postalCode == "75102" | ||
assert address.latitude == Decimal("48.85660") | ||
assert address.longitude == Decimal("2.3522") | ||
assert address.isManualEdition is False | ||
|
||
def test_withdrawal_can_be_updated(self, client): | ||
offer = offers_factories.OfferFactory( | ||
|
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 |
---|---|---|
|
@@ -210,19 +210,17 @@ def test_create_event_offer_with_manual_offerer_address(self, oa_label, client): | |
"longitude": "2.308289", | ||
"postalCode": "75001", | ||
"street": "3 Rue de Valois", | ||
"isManualEdition": True | ||
}, | ||
} | ||
with patch("pcapi.connectors.api_adresse.get_address") as mocked_get_address: | ||
mocked_get_address.side_effect = api_adresse.NoResultException | ||
response = client.with_session_auth("[email protected]").post("/offers", json=data) | ||
response = client.with_session_auth("[email protected]").post("/offers", json=data) | ||
|
||
# Then | ||
assert response.status_code == 201 | ||
offer_id = response.json["id"] | ||
offer = Offer.query.get(offer_id) | ||
assert offer.offererAddress.address.isManualEdition | ||
assert offer.offererAddress.label == oa_label | ||
assert offer.offererAddress.address.inseeCode == "06029" | ||
assert not offer.offererAddress.address.banId | ||
|
||
def when_creating_new_thing_offer(self, client): | ||
|