diff --git a/Tests/Unit/test_email.py b/Tests/Unit/test_email.py new file mode 100644 index 0000000..f37739d --- /dev/null +++ b/Tests/Unit/test_email.py @@ -0,0 +1,27 @@ +import unittest + +import _email +import _log + +class TestEmail(unittest.TestCase): + def setUp(self): + pass + + def test_init(self): + email = _email.Email() + self.assertEqual(email.message, "") + + def test_send(self): + email = _email.Email() + log = _log.Log("Tests/Temp") + self.assertFalse(email.send("#####@gmail.com", "strong and complicated password", "#####@gmail.com", log)) + self.assertTrue(log.error_occurred) + + def test_append_message(self): + email = _email.Email() + email.append_message("test") + self.assertEqual(email.message, "test") + + +if __name__ == '__main__': + unittest.main() \ No newline at end of file diff --git a/_email.py b/_email.py index 6473253..4bd468c 100644 --- a/_email.py +++ b/_email.py @@ -10,10 +10,11 @@ from email.message import EmailMessage class Email: - def __init__(self): + def __init__(self): # test in Tests/Unit/test_email.test_init self.message = "" # initializes the email with an empty message - def send(self, sender, password, addressee, log): # sends the email + # sends the email + def send(self, sender, password, addressee, log): # test in Tests/Unit/test_email.test_send server_address = "smtp.gmail.com: 587" try: @@ -40,5 +41,5 @@ def send(self, sender, password, addressee, log): # sends the email log.report("error_email_send", detail=addressee) return False - def append_message(self, text): + def append_message(self, text): # test in Tests/Unit/test_email.test_append_message self.message += text