コード例 #1
0
def send_offer_creation_notification_to_administration(
        offer: Offer, author: User, send_email: Callable[[dict],
                                                         bool]) -> bool:
    email = make_offer_creation_notification_email(offer, author)
    email["Html-part"], email["To"] = compute_email_html_part_and_recipients(
        email["Html-part"], email["To"])
    return send_email(data=email)
コード例 #2
0
    def test_when_physical_offer_returns_subject_with_departement_information_and_dictionary_with_given_content(
        self, app
    ):
        # Given
        venue_type = create_venue_type(label="Custom Label")
        repository.save(venue_type)

        author = create_user(email="*****@*****.**", first_name="John", last_name="Doe", phone_number="0102030405")
        offerer = create_offerer(name="Cinéma de Montreuil")
        physical_venue = create_venue(offerer, venue_type_id=venue_type.id)
        physical_offer = create_offer_with_thing_product(
            venue=physical_venue, thing_type=ThingType.AUDIOVISUEL, thing_name="Le vent se lève", idx=1
        )
        repository.save(author, physical_offer)

        # When

        email = make_offer_creation_notification_email(physical_offer, author)

        # Then
        assert email["FromName"] == "pass Culture"
        assert email["Subject"] == "[Création d’offre - 93] Le vent se lève"

        parsed_email = BeautifulSoup(email["Html-part"], "html.parser")

        offer_html = str(parsed_email.find("p", {"id": "offer"}))
        assert 'Une nouvelle offre : "Le vent se lève"' in offer_html

        offerer_html = str(parsed_email.find("p", {"id": "offerer"}))
        assert "Vient d'être créée par : Cinéma de Montreuil" in offerer_html

        webapp_offer_link = str(parsed_email.find("p", {"id": "webapp_offer_link"}))
        assert (
            f"Lien vers l'offre dans la Webapp :"
            f" http://localhost:3000/offre/details/{humanize(physical_offer.id)}" in webapp_offer_link
        )

        pro_offer_link = str(parsed_email.find("p", {"id": "pro_offer_link"}))
        assert (
            f"Lien vers l'offre dans le portail PRO :"
            f" http://localhost:3001/offres/{humanize(physical_offer.id)}" in pro_offer_link
        )

        offer_is_duo = str(parsed_email.find("p", {"id": "offer_is_duo"}))
        assert "Offre duo : False" in offer_is_duo

        venue_details = str(parsed_email.find("p", {"id": "venue_details"}))
        assert f"Lien vers le lieu : http://localhost:3001/lieux/{humanize(physical_offer.venue.id)}" in venue_details
        assert "Catégorie du lieu : Custom Label" in venue_details
        assert "Adresse du lieu : Montreuil 93100" in venue_details

        pro_user_information = str(parsed_email.find("p", {"id": "pro_user_information"}))
        assert "Nom : Doe" in pro_user_information
        assert "Prénom : John" in pro_user_information
        assert "Téléphone : 0102030405" in pro_user_information
        assert "Email : [email protected]" in pro_user_information
コード例 #3
0
    def test_with_physical_offer(self):
        author = users_factories.ProFactory()
        offer = offers_factories.ThingOfferFactory(
            author=author,
            product__name="Le vent se lève",
            venue__city="Montreuil",
            venue__postalCode="93100",
            venue__managingOfferer__name="Cinéma de Montreuil",
        )
        offerer = offer.venue.managingOfferer

        # When
        email = make_offer_creation_notification_email(offer)

        # Then
        assert email["FromName"] == "pass Culture"
        assert email["Subject"] == "[Création d’offre - 93] Le vent se lève"

        parsed_email = BeautifulSoup(email["Html-part"], "html.parser")

        offer_html = str(parsed_email.find("p", {"id": "offer"}))
        assert 'Une nouvelle offre : "Le vent se lève"' in offer_html

        offerer_html = str(parsed_email.find("p", {"id": "offerer"}))
        assert "Vient d'être créée par : Cinéma de Montreuil" in offerer_html

        webapp_offer_link = str(
            parsed_email.find("p", {"id": "webapp_offer_link"}))
        assert (f"Lien vers l'offre dans la Webapp :"
                f" {settings.WEBAPP_URL}/offre/details/{humanize(offer.id)}"
                in webapp_offer_link)

        pro_offer_link = str(parsed_email.find("p", {"id": "pro_offer_link"}))
        assert (f"Lien vers l'offre dans le portail PRO :"
                f" http://localhost:3001/offres/{humanize(offer.id)}/edition"
                in pro_offer_link)

        offer_is_duo = str(parsed_email.find("p", {"id": "offer_is_duo"}))
        assert "Offre duo : False" in offer_is_duo

        venue_details = str(parsed_email.find("p", {"id": "venue_details"}))
        assert (
            f"Lien vers le lieu : http://localhost:3001/structures/{humanize(offerer.id)}/lieux/{humanize(offer.venue.id)}"
            in venue_details)
        assert "Adresse du lieu : Montreuil 93100" in venue_details

        pro_user_information = str(
            parsed_email.find("p", {"id": "pro_user_information"}))
        assert f"Nom : {author.lastName}" in pro_user_information
        assert f"Prénom : {author.firstName}" in pro_user_information
コード例 #4
0
    def test_with_virtual_offer(self):
        # Given
        author = users_factories.ProFactory()
        offer = offers_factories.EventOfferFactory(
            author=author,
            product=offers_factories.DigitalProductFactory(
                name="Les lièvres pas malins"),
            venue=offers_factories.VirtualVenueFactory(),
        )

        # When
        email = make_offer_creation_notification_email(offer)

        # Then
        assert email[
            "Subject"] == "[Création d’offre - numérique] Les lièvres pas malins"
コード例 #5
0
    def test_when_virtual_offer_returns_subject_with_virtual_information_and_dictionary_with_given_content(self, app):
        # Given
        author = create_user()
        offerer = create_offerer(name="Cinéma de Montreuil")
        virtual_venue = create_venue(offerer, siret=None, is_virtual=True)
        virtual_offer = create_offer_with_thing_product(
            venue=virtual_venue,
            thing_type=ThingType.JEUX_VIDEO,
            is_digital=True,
            thing_name="Les lapins crétins",
            idx=2,
        )
        repository.save(author, virtual_offer)

        # When
        email = make_offer_creation_notification_email(virtual_offer, author)

        # Then
        assert email["FromName"] == "pass Culture"
        assert email["Subject"] == "[Création d’offre - numérique] Les lapins crétins"
コード例 #6
0
def send_offer_creation_notification_to_administration(offer: Offer,
                                                       author: User) -> bool:
    email = make_offer_creation_notification_email(offer, author)
    return mails.send(recipients=[settings.ADMINISTRATION_EMAIL_ADDRESS],
                      data=email)