Просмотр исходного кода

test: add test for missing css_inline

Mikael Koli 2 лет назад
Родитель
Сommit
aa4ac9a02a
1 измененных файлов с 25 добавлено и 1 удалено
  1. 25 1
      redmail/test/email/test_inline_media.py

+ 25 - 1
redmail/test/email/test_inline_media.py

@@ -300,4 +300,28 @@ def test_embed_tables_pandas_missing():
                 body_tables={"my_table": [{"col1": 1, "col2": "a"}, {"col1": 2, "col2": "b"}]}
             )
     finally:
-        body.pd = pd_mdl
+        body.pd = pd_mdl
+
+def test_styled_tables_dependency_missing():
+    pd = pytest.importorskip("pandas")
+
+    sender = EmailSender(host=None, port=1234)
+
+    from redmail.email import body
+    mdl = body.css_inline # This may be already None if env does not have Pandas
+    try:
+        # src uses this to reference Pandas (if missing --> None)
+        body.css_inline = None
+        style = pd.DataFrame(
+            {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}
+        ).style.set_caption("A caption")
+        with pytest.raises(ImportError):
+            msg = sender.get_message(
+                sender="me@gmail.com",
+                receivers="you@gmail.com",
+                subject="Some news",
+                html='The table {{my_table}}',
+                body_tables={"my_table": style}
+            )
+    finally:
+        body.css_inline = mdl