test_deprecated.py 939 B

12345678910111213141516171819202122232425262728
  1. import pytest
  2. from redmail import EmailSender, MultiEmailHandler
  3. def test_user_name():
  4. "user_name has been deprecated. Testing backward compatibility."
  5. # Test EmailSender
  6. with pytest.warns(FutureWarning):
  7. email = EmailSender(host="localhost", port=0, user_name="testing", password="1234")
  8. assert email.username == "testing"
  9. with pytest.warns(FutureWarning):
  10. assert email.user_name == "testing"
  11. with pytest.warns(FutureWarning):
  12. email.user_name = "another"
  13. assert email.username == "another"
  14. with pytest.warns(FutureWarning):
  15. assert email.user_name == "another"
  16. # Testing in handler
  17. with pytest.warns(FutureWarning):
  18. hdlr = MultiEmailHandler(host="localhost", port=0, user_name="testing", password="1234", subject="A log", receivers=["me@example.com"])
  19. sender = hdlr.email
  20. assert sender.username == "testing"
  21. assert sender.password == "1234"