-
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-31051)[BO] feat: add ff WIP_DISABLE_NOTIFICATION_CANCEL_BOOKING
- Loading branch information
1 parent
411490d
commit 62c335f
Showing
6 changed files
with
78 additions
and
2 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
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 |
---|---|---|
|
@@ -888,6 +888,7 @@ def test_delete_stock_basics(self, mocked_async_index_offer_ids): | |
reason=search.IndexationReason.STOCK_DELETION, | ||
) | ||
|
||
@override_features(WIP_DISABLE_NOTIFICATION_CANCEL_BOOKING=False) | ||
def test_delete_stock_cancel_bookings_and_send_emails(self): | ||
offerer_email = "[email protected]" | ||
stock = factories.EventStockFactory( | ||
|
@@ -948,6 +949,33 @@ def test_delete_stock_cancel_bookings_and_send_emails(self): | |
"can_be_asynchronously_retried": False, | ||
} | ||
|
||
@override_features(WIP_DISABLE_NOTIFICATION_CANCEL_BOOKING=True) | ||
@mock.patch("pcapi.workers.push_notification_job.send_cancel_booking_notification.delay") | ||
def test_delete_stock_cancel_bookings_and_send_emails_with_ff_disable_notification_cancel_booking( | ||
self, mocked_cancel_booking_notification | ||
): | ||
offerer_email = "[email protected]" | ||
stock = factories.EventStockFactory( | ||
offer__bookingEmail=offerer_email, | ||
offer__venue__pricing_point="self", | ||
) | ||
bookings_factories.BookingFactory(stock=stock) | ||
bookings_factories.CancelledBookingFactory(stock=stock) | ||
bookings_factories.UsedBookingFactory(stock=stock) | ||
event4 = finance_factories.UsedBookingFinanceEventFactory(booking__stock=stock) | ||
booking4 = event4.booking | ||
finance_factories.PricingFactory( | ||
event=event4, | ||
booking=booking4, | ||
status=finance_models.PricingStatus.PROCESSED, | ||
) | ||
|
||
api.delete_stock(stock) | ||
|
||
# cancellation can trigger more than one request to Batch | ||
assert len(push_testing.requests) >= 1 | ||
assert not mocked_cancel_booking_notification.called | ||
|
||
def test_can_delete_if_stock_from_provider(self): | ||
provider = providers_factories.APIProviderFactory() | ||
offer = factories.OfferFactory(lastProvider=provider, idAtProvider="1") | ||
|
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 |
---|---|---|
@@ -1,15 +1,19 @@ | ||
from unittest import mock | ||
|
||
from pcapi.core.bookings import factories as bookings_factory | ||
from pcapi.core.bookings.factories import BookingFactory | ||
import pcapi.core.offerers.factories as offerers_factories | ||
import pcapi.core.offers.factories as offers_factories | ||
from pcapi.core.offers.models import OfferValidationStatus | ||
from pcapi.core.testing import override_features | ||
from pcapi.core.token import SecureToken | ||
from pcapi.core.token.serialization import ConnectAsInternalModel | ||
import pcapi.core.users.factories as users_factories | ||
from pcapi.notifications.push import testing as push_testing | ||
|
||
|
||
class Returns200Test: | ||
@override_features(WIP_DISABLE_NOTIFICATION_CANCEL_BOOKING=False) | ||
def when_current_user_has_rights_on_offer(self, client, db_session): | ||
# given | ||
offer = offers_factories.OfferFactory() | ||
|
@@ -38,6 +42,30 @@ def when_current_user_has_rights_on_offer(self, client, db_session): | |
"can_be_asynchronously_retried": False, | ||
} | ||
|
||
@override_features(WIP_DISABLE_NOTIFICATION_CANCEL_BOOKING=True) | ||
@mock.patch("pcapi.workers.push_notification_job.send_cancel_booking_notification.delay") | ||
def when_current_user_has_rights_on_offer_with_disabled_notification_cancel_booking( | ||
self, mocked_cancel_booking_notification, client | ||
): | ||
# given | ||
offer = offers_factories.OfferFactory() | ||
user_offerer = offerers_factories.UserOffererFactory( | ||
user__email="[email protected]", | ||
offerer=offer.venue.managingOfferer, | ||
) | ||
stock = offers_factories.StockFactory(offer=offer) | ||
BookingFactory(stock=stock) | ||
|
||
# when | ||
response = client.with_session_auth("[email protected]").delete(f"/stocks/{stock.id}") | ||
|
||
# then | ||
assert response.status_code == 200 | ||
assert response.json == {"id": stock.id} | ||
assert stock.isSoftDeleted | ||
assert stock.bookings[0].cancellationUser == user_offerer.user | ||
assert not mocked_cancel_booking_notification.called | ||
|
||
def when_current_user_is_connect_as(self, client, db_session): | ||
# given | ||
offer = offers_factories.OfferFactory() | ||
|