Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(PC-33722)[API] fix: rm current_user as a parameter inside public route #15665

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions api/src/pcapi/routes/public/individual_offers/v1/events.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import copy

from flask_login import current_user
import sqlalchemy as sqla

from pcapi import repository
Expand Down Expand Up @@ -595,7 +594,7 @@ def delete_event_stock(event_id: int, stock_id: int) -> None:
if not stock_to_delete:
raise api_errors.ApiErrors({"stock_id": ["No stock could be found"]}, status_code=404)
try:
offers_api.delete_stock(stock_to_delete, current_user)
offers_api.delete_stock(stock_to_delete)
except offers_exceptions.OfferEditionBaseException as error:
raise api_errors.ApiErrors(error.errors, status_code=400)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

import pytest

from pcapi.core.bookings import factories as bookings_factories
from pcapi.core.bookings import models as bookings_models
from pcapi.core.offers import factories as offers_factories
from pcapi.core.offers import models as offers_models
from pcapi.core.offers.models import WithdrawalTypeEnum
Expand Down Expand Up @@ -79,6 +81,23 @@ def test_delete_unbooked_date_with_ticket(self, client):
assert response.json is None
assert stock.isSoftDeleted is True

def test_stock_is_deleted_and_its_bookings_are_cancelled(self, client):
plain_api_key, venue_provider = self.setup_active_venue_provider()
event, stock = self.setup_base_resource(venue=venue_provider.venue, provider=venue_provider.provider)
bookings = bookings_factories.BookingFactory.create_batch(2, stock=stock)

response = client.with_explicit_token(plain_api_key).delete(
self.endpoint_url.format(event_id=event.id, stock_id=stock.id),
)

assert response.status_code == 204
assert response.json is None
assert stock.isSoftDeleted is True

for booking in bookings:
db.session.refresh(booking)
assert booking.status == bookings_models.BookingStatus.CANCELLED

def test_should_raise_400_if_event_stock_beginning_date_was_more_than_two_days_ago(self, client):
plain_api_key, venue_provider = self.setup_active_venue_provider()
event, stock = self.setup_base_resource(venue=venue_provider.venue, provider=venue_provider.provider)
Expand Down
Loading