Ejemplo n.º 1
0
def test_make_payment_message_email(app):
    xml = '<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"></Document>'
    csv = "some csv"
    checksum = b"\x16\x91\x0c\x11~Hs\xc5\x1a\xa3W1\x13\xbf!jq@\xea  <h&\xef\x1f\xaf\xfc\x7fO\xc8\x82"

    email = make_payment_message_email(xml, csv, checksum)

    assert email["FromName"] == "pass Culture Pro"
    assert email["Subject"] == "Virements XML pass Culture Pro - 2018-10-15"
    assert email["Attachments"] == [
        {
            "ContentType":
            "text/xml",
            "Filename":
            "message_banque_de_france_20181015.xml",
            "Content":
            "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48RG9j"
            "dW1lbnQgeG1sbnM9InVybjppc286c3RkOmlzbzoyMDAyMjp0ZWNoOnhz"
            "ZDpwYWluLjAwMS4wMDEuMDMiPjwvRG9jdW1lbnQ+",
        },
        {
            "ContentType": "text/csv",
            "Filename": "lieux_20181015.csv",
            "Content": "c29tZSBjc3Y=",
        },
    ]
    assert "message_banque_de_france_20181015.xml" in email["Html-part"]
    assert "16910c117e4873c51aa3573113bf216a7140ea20203c6826ef1faffc7f4fc882" in email[
        "Html-part"]
Ejemplo n.º 2
0
def test_make_payment_message_email_sends_a_xml_file_with_its_checksum_in_email_body(
        app):
    # Given
    xml = '<?xml version="1.0" encoding="UTF-8"?><Document xmlns="urn:iso:std:iso:20022:tech:xsd:pain.001.001.03"></Document>'
    checksum = b"\x16\x91\x0c\x11~Hs\xc5\x1a\xa3W1\x13\xbf!jq@\xea  <h&\xef\x1f\xaf\xfc\x7fO\xc8\x82"

    # When
    email = make_payment_message_email(xml, checksum)

    # Then
    assert email["FromName"] == "pass Culture Pro"
    assert email["Subject"] == "Virements XML pass Culture Pro - 2018-10-15"
    assert email["Attachments"] == [{
        "ContentType":
        "text/xml",
        "Filename":
        "message_banque_de_france_20181015.xml",
        "Content":
        "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48RG9j"
        "dW1lbnQgeG1sbnM9InVybjppc286c3RkOmlzbzoyMDAyMjp0ZWNoOnhz"
        "ZDpwYWluLjAwMS4wMDEuMDMiPjwvRG9jdW1lbnQ+",
    }]
    email_html = BeautifulSoup(email["Html-part"], "html.parser")
    assert "message_banque_de_france_20181015.xml" in email_html.find(
        "p", {
            "id": "file_name"
        }).find("strong").text
    assert ("16910c117e4873c51aa3573113bf216a7140ea20203c6826ef1faffc7f4fc882"
            in email_html.find("p", {
                "id": "checksum"
            }).find("strong").text)
Ejemplo n.º 3
0
def send_payment_message_email(xml_attachment: str, checksum: bytes,
                               recipients: List[str],
                               send_email: Callable[[dict], bool]) -> bool:
    email = make_payment_message_email(xml_attachment, checksum)
    email["Html-part"], email["To"] = compute_email_html_part_and_recipients(
        email["Html-part"], recipients)
    return send_email(data=email)
Ejemplo n.º 4
0
def send_payment_message_email(xml_attachment: str, checksum: bytes,
                               recipients: List[str]) -> bool:
    email = make_payment_message_email(xml_attachment, checksum)
    return mails.send(recipients=recipients, data=email)