Sfoglia il codice sorgente

test: increased coverage

Mikael Koli 4 anni fa
parent
commit
e7ff4287fb
1 ha cambiato i file con 23 aggiunte e 1 eliminazioni
  1. 23 1
      redmail/test/email/test_attachments.py

+ 23 - 1
redmail/test/email/test_attachments.py

@@ -187,7 +187,6 @@ def test_dict_matplotlib_no_error():
     assert str(base64.b64encode(bytes_fig), 'ascii') == data.replace('\n', '')
 
 def test_dict_invalid():
-    fig, bytes_fig = get_mpl_fig()
 
     sender = EmailSender(host=None, port=1234)
     with pytest.raises(TypeError):
@@ -198,6 +197,18 @@ def test_dict_invalid():
             attachments={'myimg.png': sender}
         )
 
+def test_dict_invalid_key():
+    fig, bytes_fig = get_mpl_fig()
+
+    sender = EmailSender(host=None, port=1234)
+    with pytest.raises(TypeError):
+        msg = sender.get_message(
+            sender="me@gmail.com",
+            receivers="you@gmail.com",
+            subject="Some news",
+            attachments={sender: 'something'}
+        )
+
 def test_dict_multiple(tmpdir):
     file1 = tmpdir.join("file_1.txt")
     file1.write("Some content 1")
@@ -290,6 +301,17 @@ def test_list_multiple(tmpdir):
         assert filename == expected[0]
         assert to_encoded(expected[1]) == data.replace('\n', '')
 
+def test_list_invalid():
+
+    sender = EmailSender(host=None, port=1234)
+    with pytest.raises(TypeError):
+        msg = sender.get_message(
+            sender="me@gmail.com",
+            receivers="you@gmail.com",
+            subject="Some news",
+            attachments=[sender]
+        )
+
 def test_string_path(tmpdir):
     file = tmpdir.join("data.txt")
     file.write("Some content")