diff --git a/api/src/pcapi/core/external/attributes/api.py b/api/src/pcapi/core/external/attributes/api.py index 85f4bef36b2..4ed741d6d08 100644 --- a/api/src/pcapi/core/external/attributes/api.py +++ b/api/src/pcapi/core/external/attributes/api.py @@ -289,13 +289,8 @@ def get_pro_attributes(email: str) -> models.ProAttributes: .all() ) - is_eac_meg = False - - venue_with_collective_offer = any(venue.adageId for venue in venues) - - if venue_with_collective_offer: - venue_ids = {venue.id for venue in venues} - is_eac_meg = has_collective_offers_for_program_and_venue_ids("marseille_en_grand", venue_ids) + venue_ids = {venue.id for venue in venues} + is_eac_meg = has_collective_offers_for_program_and_venue_ids("marseille_en_grand", venue_ids) if venues: diff --git a/api/tests/core/bookings/test_api.py b/api/tests/core/bookings/test_api.py index 0aa7bfe2937..73b17357f19 100644 --- a/api/tests/core/bookings/test_api.py +++ b/api/tests/core/bookings/test_api.py @@ -182,7 +182,7 @@ def test_create_booking(self, mocked_async_index_offer_ids, app): # 1 - SELECT from offer that I don't get # 1 - SELECT bookings for the venue ??? # 1 - SELECT feature - with assert_num_queries(35): + with assert_num_queries(36): booking = api.book_offer(beneficiary=beneficiary, stock_id=stock_id, quantity=1) # One request should have been sent to Batch to trigger the event diff --git a/api/tests/core/external/external_pro_test.py b/api/tests/core/external/external_pro_test.py index bc534afeea7..4299e9e3dba 100644 --- a/api/tests/core/external/external_pro_test.py +++ b/api/tests/core/external/external_pro_test.py @@ -24,7 +24,8 @@ # 1 query on venue table with joinedload # 2 extra SQL queries: select exists on offer and booking tables # 1 extra query to check if the venue has any related collective offer with 'marseille en grand' -EXPECTED_PRO_ATTR_NUM_QUERIES = 5 +# 1 check if the venue is concerned with marseille_en_grand +EXPECTED_PRO_ATTR_NUM_QUERIES = 6 def _build_params(subs, virt, perman, draft, accep, offer, book, attach, colloff, tploff, megoff): @@ -239,8 +240,6 @@ def test_update_external_pro_user_attributes( ) num_queries = EXPECTED_PRO_ATTR_NUM_QUERIES - if create_collective_offer or create_collective_offer_meg: - num_queries += 1 with assert_num_queries(num_queries): attributes = get_pro_attributes(email) @@ -357,7 +356,7 @@ def test_update_external_pro_booking_email_attributes(): venueTypeCode=VenueTypeCode.MUSEUM, ) - with assert_num_queries(4): + with assert_num_queries(5): attributes = get_pro_attributes(email) assert attributes.is_pro is True @@ -403,7 +402,7 @@ def test_update_external_pro_booking_email_attributes_for_permanent_venue_with_b _bannerUrl="https://example.net/banner.jpg", ) - with assert_num_queries(4): + with assert_num_queries(5): attributes = get_pro_attributes(email) assert attributes.isPermanent is True assert attributes.has_banner_url is True @@ -424,7 +423,7 @@ def test_update_external_pro_booking_email_attributes_for_non_permanent_venue_wi _bannerUrl="https://example.net/banner.jpg", ) - with assert_num_queries(4): + with assert_num_queries(5): attributes = get_pro_attributes(email) assert attributes.isPermanent is False assert attributes.has_banner_url is True @@ -444,7 +443,7 @@ def test_update_external_pro_booking_email_attributes_for_non_permanent_venue_wi venueTypeCode=VenueTypeCode.MUSEUM, ) - with assert_num_queries(4): + with assert_num_queries(5): attributes = get_pro_attributes(email) assert attributes.isPermanent is False assert attributes.has_banner_url is True @@ -452,7 +451,8 @@ def test_update_external_pro_booking_email_attributes_for_non_permanent_venue_wi def test_update_external_pro_removed_email_attributes(): # only 2 queries: user and venue - nothing found - with assert_num_queries(2): + # one query for marseille_en_grand + with assert_num_queries(3): attributes = get_pro_attributes("removed@example.net") assert attributes.is_pro is True diff --git a/api/tests/routes/native/v1/bookings_test.py b/api/tests/routes/native/v1/bookings_test.py index 095a7ba0238..9c9799b803f 100644 --- a/api/tests/routes/native/v1/bookings_test.py +++ b/api/tests/routes/native/v1/bookings_test.py @@ -988,7 +988,7 @@ def test_cancel_booking(self, client): booking = booking_factories.BookingFactory(user=user) client = client.with_token(self.identifier) - with assert_num_queries(24): + with assert_num_queries(25): response = client.post(f"/native/v1/bookings/{booking.id}/cancel") assert response.status_code == 204 @@ -1003,7 +1003,7 @@ def test_cancel_booking_trigger_recredit_event(self, client): booking = booking_factories.BookingFactory(user=user) client = client.with_token(self.identifier) - with assert_num_queries(24): + with assert_num_queries(25): response = client.post(f"/native/v1/bookings/{booking.id}/cancel") assert response.status_code == 204