Skip to content

Commit

Permalink
Added basic unit tests for _email
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Fernandes Vieira committed Jan 5, 2019
1 parent c510e92 commit 3cce278
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
27 changes: 27 additions & 0 deletions Tests/Unit/test_email.py
Original file line number Diff line number Diff line change
@@ -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()
7 changes: 4 additions & 3 deletions _email.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit 3cce278

Please sign in to comment.