Exemplo n.º 1
0
 def test_can_handle_comments_in_mjml(self):
     mjml = ('<mjml>'
             '  <mj-body>'
             '    <!-- empty -->'
             '  </mj-body>'
             '</mjml>')
     mjml_to_html(StringIO(mjml))
Exemplo n.º 2
0
Arquivo: email.py Projeto: hill/UEM2
def build_email_templates():
    for template_filename in os.listdir(SRC_TEMPATE_LOC):
        logging.info(f"Building email template {template_filename}...")
        template_name = template_filename.split(".")[0]
        with (SRC_TEMPATE_LOC / template_filename).open("rb") as fp:
            html_output = mjml_to_html(fp)
        with (BUILD_TEMPLATE_LOC / (template_name + ".html")).open("w+") as fp:
            fp.write(html_output["html"])
    def test_ensure_same_html(self, test_id):
        mjml_filename = f'{test_id}.mjml'
        html_filename = f'{test_id}-expected.html'
        with (TESTDATA_DIR / html_filename).open('rb') as html_fp:
            expected_html = html_fp.read()

        with (TESTDATA_DIR / mjml_filename).open('rb') as mjml_fp:
            result = mjml_to_html(mjml_fp)

        assert not result.errors
        actual_html = result.html
        assert_same_html(expected_html, actual_html, verbose=True)