test_email ========== .. py:module:: test_email .. autoapi-nested-parse:: Test file for emails.py. Functions --------- .. autoapisummary:: test_email._write_template test_email.templates_dir test_email.locmem_email_backend test_email.test_mailtemplate_helpers test_email.test_render_bodies_prefers_txt_when_present test_email.test_render_bodies_falls_back_if_txt_missing test_email.test_send_email_builds_multipart_and_uses_locmem test_email.test_send_bulk_sends_multiple test_email.test_emailpayload_post_init_normalizes_types Module Contents --------------- .. py:function:: _write_template(tpldir, relpath, content) Helper to create a template file with given relative path and content. .. py:function:: templates_dir(settings, tmp_path) Provide a clean temporary template directory and point Django to it. .. py:function:: locmem_email_backend(settings) Force Django to use locmem email backend for tests. .. py:function:: test_mailtemplate_helpers() Ensure MailTemplate.txt() and .html() return correct paths. .. py:function:: test_render_bodies_prefers_txt_when_present(templates_dir) Verify that _render_bodies prefers .txt when both txt and html exist. .. py:function:: test_render_bodies_falls_back_if_txt_missing(templates_dir) Verify that _render_bodies falls back to HTML and strip_tags when txt missing. .. py:function:: test_send_email_builds_multipart_and_uses_locmem(templates_dir) Ensure send_email renders templates and sends a multipart email. .. py:function:: test_send_bulk_sends_multiple(templates_dir) Ensure send_bulk sends all payloads and accumulates sent count. .. py:function:: test_emailpayload_post_init_normalizes_types(templates_dir) Verify that EmailPayload.__post_init__ normalizes lists to tuples and dicts to MappingProxyType.