import email from backend.routers.emails import classify_mail def _m(raw): return email.message_from_string(raw) def test_classify(): pdf = "Content-Type: multipart/mixed; boundary=b\n\n--b\nContent-Type: text/plain\n\nhi\n--b\nContent-Type: application/pdf\nContent-Disposition: attachment; filename=r.pdf\n\nx\n--b--\n" assert classify_mail(_m(pdf)) == ("attachment", None) link = "Content-Type: text/plain\n\nIhre Rechnung: https://pay.stripe.com/invoice/abc/pdf" assert classify_mail(_m(link))[0] == "link" portal = "Content-Type: text/plain\n\nIhre Rechnung ist verfügbar. Bitte in Ihrem Konto herunterladen." assert classify_mail(_m(portal)) == ("portal", None) assert classify_mail(_m("Content-Type: text/plain\n\nHallo"))[0] == "ignore"