def should_return_linked_offerers_with_matching_keywords_in_venue_name(
            self, app):
        # Given
        user = create_user()
        offerer1 = create_offerer(name="Theatre")
        offerer2 = create_offerer(name="Cinema", siren="912345678")
        venue1 = create_venue(name="Les fleurs",
                              offerer=offerer1,
                              siret=None,
                              is_virtual=True)
        venue2 = create_venue(name="Les jardins du vide",
                              offerer=offerer2,
                              siret=None,
                              is_virtual=True)
        user_offerer1 = create_user_offerer(user=user, offerer=offerer1)
        user_offerer2 = create_user_offerer(user=user, offerer=offerer2)
        repository.save(user_offerer1, user_offerer2, venue1, venue2)

        # When
        paginated_offerers = PaginatedOfferersSQLRepository(
        ).with_status_and_keywords(
            user_id=user.id,
            user_is_admin=user.isAdmin,
            is_filtered_by_offerer_status=False,
            only_validated_offerers=None,
            pagination_limit=10,
            keywords="jardins",
            page=0,
        )

        # Then
        assert isinstance(paginated_offerers, PaginatedOfferers)
        assert paginated_offerers.total == 1
        assert len(paginated_offerers.offerers) == 1
    def should_filter_out_non_validated_offerers(self, app):
        # Given
        user = create_user()
        offerer1 = create_offerer(validation_token="RTYUIO")
        offerer2 = create_offerer(siren="987654310")
        user_offerer1 = create_user_offerer(user=user, offerer=offerer1)
        user_offerer2 = create_user_offerer(user=user, offerer=offerer2)
        repository.save(user_offerer1, user_offerer2)

        # When
        paginated_offerers = PaginatedOfferersSQLRepository(
        ).with_status_and_keywords(
            user_id=user.id,
            user_is_admin=user.isAdmin,
            is_filtered_by_offerer_status=True,
            only_validated_offerers=True,
            pagination_limit=10,
            keywords=None,
            page=0,
        )

        # Then
        assert isinstance(paginated_offerers, PaginatedOfferers)
        assert paginated_offerers.total == 1
        assert len(paginated_offerers.offerers) == 1
        assert paginated_offerers.offerers[0].id == offerer2.id
    def should_only_return_offerers_linked_to_user(self, app):
        # Given
        user = create_user()
        offerer1 = create_offerer()
        offerer2 = create_offerer(siren="912345678")
        user_offerer = create_user_offerer(user=user, offerer=offerer1)
        repository.save(user_offerer, offerer2)

        # When
        paginated_offerers = PaginatedOfferersSQLRepository(
        ).with_status_and_keywords(
            user_id=user.id,
            user_is_admin=user.isAdmin,
            is_filtered_by_offerer_status=False,
            only_validated_offerers=None,
            pagination_limit=10,
            keywords=None,
            page=0,
        )

        # Then
        assert isinstance(paginated_offerers, PaginatedOfferers)
        assert paginated_offerers.total == 1
        assert len(paginated_offerers.offerers) == 1
        assert paginated_offerers.offerers[0].userHasAccess == True
    def should_return_only_one_offerers_when_it_has_multiple_venues(self, app):
        # Given
        pro = users_factories.ProFactory()
        offerer1 = create_offerer(name="Theatre")
        venue1 = create_venue(name="Les fleurs", offerer=offerer1, siret=None, is_virtual=True)
        venue2 = create_venue(name="Les jardins du vide", offerer=offerer1, siret=None, is_virtual=True)
        user_offerer1 = create_user_offerer(user=pro, offerer=offerer1)
        repository.save(user_offerer1, venue1, venue2)

        # When
        paginated_offerers = PaginatedOfferersSQLRepository().with_status_and_keywords(
            user_id=pro.id,
            user_is_admin=pro.isAdmin,
            is_filtered_by_offerer_status=False,
            only_validated_offerers=None,
            pagination_limit=10,
            keywords=None,
            page=0,
        )

        # Then
        assert isinstance(paginated_offerers, PaginatedOfferers)
        assert paginated_offerers.total == 1
        assert len(paginated_offerers.offerers) == 1
    VenueWithBasicInformationSQLRepository, )
from pcapi.infrastructure.repository.venue.venue_with_offerer_name.venue_with_offerer_name_sql_repository import (
    VenueWithOffererNameSQLRepository, )
from pcapi.use_cases.get_bookings_for_beneficiary import GetBookingsForBeneficiary
from pcapi.use_cases.get_venue_labels import GetVenueLabels
from pcapi.use_cases.get_venues_by_pro_user import GetVenuesByProUser
from pcapi.use_cases.list_favorites_of_beneficiary import ListFavoritesOfBeneficiary
from pcapi.use_cases.list_offerers_for_pro_user import ListOfferersForProUser

beneficiary_bookings_repository = BeneficiaryBookingsSQLRepository()
favorite_repository = FavoriteSQLRepository()
venue_label_repository = VenueLabelSQLRepository()
venue_identifier_repository = VenueWithBasicInformationSQLRepository()
venue_with_offerer_informations_repository = VenueWithOffererNameSQLRepository(
)
paginated_offerers_repository = PaginatedOfferersSQLRepository()

api_libraires_stocks = StockProviderLibrairesRepository()
api_fnac_stocks = StockProviderFnacRepository()
api_titelive_stocks = StockProviderTiteLiveRepository()
api_praxiel_stocks = StockProviderPraxielRepository()

# Usecases
get_venue_labels = GetVenueLabels(
    venue_label_repository=venue_label_repository)

get_all_venues_by_pro_user = GetVenuesByProUser(
    venue_repository=venue_with_offerer_informations_repository)

list_favorites_of_beneficiary = ListFavoritesOfBeneficiary(
    favorite_repository=favorite_repository)
Exemple #6
0
 def setup_method(self):
     self.paginated_offerers_repository = PaginatedOfferersSQLRepository()
     self.paginated_offerers_repository.with_status_and_keywords = MagicMock(
     )
     self.list_offerers_for_pro_user = ListOfferersForProUser(
         paginated_offerers_repository=self.paginated_offerers_repository)