Skip to content

Commit

Permalink
Code style according PEP8
Browse files Browse the repository at this point in the history
  • Loading branch information
aciristov committed Oct 9, 2017
1 parent 1e03b78 commit 7b2d68e
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions ckanext/requestdata/tests/test_emailer.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from ckanext.requestdata.emailer import send_email
from ckanext.requestdata import emailer


class ActionBase(unittest.TestCase):
@classmethod
def setup_class(self):
Expand All @@ -25,21 +26,18 @@ def teardown_class(self):
if plugins.plugin_loaded('requestdata'):
plugins.unload('requestdata')


class TestEmailer(ActionBase):

def test_send_email(self):
#send_email("test_content", "some@some.com", "Subject_Test")
#Mock 'smtplib.SMTP' class
with patch("smtplib.SMTP") as mock_smtp:
to_address = "aleksandar.ristov@keitaro.com"
subject = "testSubject"
content = "testContent"
send_email(content, to_address, subject)

#Instanca od mocked SMTP object
instance = mock_smtp.return_value

#dali mock e povikana
self.assertTrue(instance.sendmail.called)

def test_send_email_no_to_address(self):
Expand All @@ -50,6 +48,6 @@ def test_send_email_no_to_address(self):
try:
send_email(content, to_address, subject)
assert False
except:
except Exception:
instance = mock_smtp.return_value
self.assertFalse(instance.sendmail.called)

0 comments on commit 7b2d68e

Please sign in to comment.