Parcourir la source

test: increased test coverage

Mikael Koli il y a 4 ans
Parent
commit
992b47e447
2 fichiers modifiés avec 18 ajouts et 1 suppressions
  1. 8 0
      redmail/test/log/test_handler_multi.py
  2. 10 1
      redmail/test/test_deprecated.py

+ 8 - 0
redmail/test/log/test_handler_multi.py

@@ -14,6 +14,14 @@ def test_default_body():
     # By default, this should be body if text/html/html_template/text_template not specified
     assert hdlr.email.text == MultiEmailHandler.default_text
 
+def test_sender_with_login():
+    hdlr = MultiEmailHandler(host="localhost", port=0, username="myuser", password="1234", receivers=["me@example.com"], subject="Some logging")
+    # By default, this should be body if text/html/html_template/text_template not specified
+    sender = hdlr.email
+    assert sender.username == "myuser"
+    assert sender.password == "1234"
+    assert sender.receivers == ["me@example.com"]
+    assert sender.subject == "Some logging"
 
 @pytest.mark.parametrize("kwargs,exp_headers,exp_payload",
     [

+ 10 - 1
redmail/test/email/test_deprecated.py → redmail/test/test_deprecated.py

@@ -1,9 +1,11 @@
 
 import pytest
-from redmail import EmailSender
+from redmail import EmailSender, MultiEmailHandler
 
 def test_user_name():
     "user_name has been deprecated. Testing backward compatibility."
+
+    # Test EmailSender
     with pytest.warns(FutureWarning):
         email = EmailSender(host="localhost", port=0, user_name="testing", password="1234")
 
@@ -17,3 +19,10 @@ def test_user_name():
     assert email.username == "another"
     with pytest.warns(FutureWarning):
         assert email.user_name == "another"
+
+    # Testing in handler
+    with pytest.warns(FutureWarning):
+        hdlr = MultiEmailHandler(host="localhost", port=0, user_name="testing", password="1234", subject="A log", receivers=["me@example.com"])
+    sender = hdlr.email
+    assert sender.username == "testing"
+    assert sender.password == "1234"