Пример #1
0
    def test_it_contains_a_count_of_payments_by_status_in_html_part(self, app):
        # When
        email = make_payments_report_email(self.not_processable_csv, self.error_csv, self.grouped_payments)

        # Then
        email_html = BeautifulSoup(email["Html-part"], "html.parser")
        assert email_html.find("ul").text == "\nERROR : 2\nSENT : 1\nPENDING : 3\n"
Пример #2
0
    def test_it_contains_the_two_csv_files_as_attachment(self, app):
        # When
        email = make_payments_report_email(self.not_processable_csv,
                                           self.error_csv,
                                           self.grouped_payments)

        # Then
        assert email["Attachments"] == [
            {
                "ContentType":
                "text/csv",
                "Filename":
                "paiements_non_traitables_2018-10-15.csv",
                "Content":
                "ImhlYWRlciBBIiwiaGVhZGVyIEIiLCJoZWFkZXIgQyIsImhlYWRlciBE"
                "IgoicGFydCBBIiwicGFydCBCIiwicGFydCBDIiwicGFydCBEIgo=",
            },
            {
                "ContentType":
                "text/csv",
                "Filename":
                "paiements_en_erreur_2018-10-15.csv",
                "Content":
                "ImhlYWRlciAxIiwiaGVhZGVyIDIiLCJoZWFkZXIgMyIsImhlYWRlciA0"
                "IgoicGFydCAxIiwicGFydCAyIiwicGFydCAzIiwicGFydCA0Igo=",
            },
        ]
Пример #3
0
    def test_it_contains_the_total_count_of_payments(self, app):
        # When
        email = make_payments_report_email(self.not_processable_csv, self.error_csv, self.grouped_payments)

        # Then
        email_html = BeautifulSoup(email["Html-part"], "html.parser")
        assert email_html.find("p", {"id": "total"}).text == "Nombre total de paiements : 6"
Пример #4
0
    def test_it_contains_from_and_subject_info(self, app):
        # When
        email = make_payments_report_email(self.not_processable_csv, self.error_csv, self.grouped_payments)

        # Then
        assert email["FromEmail"] == "*****@*****.**"
        assert email["FromName"] == "pass Culture Pro"
        assert email["Subject"] == "Récapitulatif des paiements pass Culture Pro - 2018-10-15"
Пример #5
0
def send_payments_report_emails(
    not_processable_payments_csv: str,
    error_payments_csv: str,
    grouped_payments: Dict,
    recipients: List[str],
) -> bool:
    email = make_payments_report_email(not_processable_payments_csv,
                                       error_payments_csv, grouped_payments)
    return mails.send(recipients=recipients, data=email)
Пример #6
0
def send_payments_report_emails(
    not_processable_payments_csv: str,
    n_payments_by_status: dict,
    recipients: list[str],
) -> bool:
    email = make_payments_report_email(
        not_processable_payments_csv,
        n_payments_by_status,
    )
    return mails.send(recipients=recipients, data=email)
Пример #7
0
def test_make_payments_report_email(app):
    n_payments_by_status = {"NOT_PROCESSABLE": 1, "UNDER_REVIEW": 2}
    email = make_payments_report_email("csv1", n_payments_by_status)

    assert email["FromName"] == "pass Culture Pro"
    assert email[
        "Subject"] == "Récapitulatif des paiements pass Culture Pro - 2018-10-15"
    assert "NOT_PROCESSABLE : 1" in email["Html-part"]
    assert "UNDER_REVIEW : 2" in email["Html-part"]
    assert "Nombre total de paiements : 3" in email["Html-part"]
    assert len(email["Attachments"]) == 1
Пример #8
0
def send_payments_report_emails(
    not_processable_payments_csv: str,
    error_payments_csv: str,
    grouped_payments: Dict,
    recipients: List[str],
    send_email: Callable[[dict], bool],
) -> bool:
    email = make_payments_report_email(not_processable_payments_csv,
                                       error_payments_csv, grouped_payments)
    email["Html-part"], email["To"] = compute_email_html_part_and_recipients(
        email["Html-part"], recipients)
    return send_email(data=email)