def test_GmailEmailMsg_should_raise_SMTPAuthenticationError(): """GmailEmailMsg should raise SMTPAuthenticationError because of wrong password""" injector = inject.Injector() injector.bind( "gmailAccount", to="*****@*****.**" ) injector.bind( "gmailPassword", to="this is another test password wrong" ) inject.register( injector ) gmail = GmailEmailMsg() temp = GmailEmailTemplate() assert_raises( SMTPAuthenticationError, gmail.sendMessage, "*****@*****.**", "test message", temp.generate( "welcome_email.html", { "userName": "******", "domain": "test.bitpostage.net", "userToken": "1234567890" } ) )
def test_GmailEmailMsg_should_not_raise_any_exceptions_on_sending_email(): """GmailEmailMsg should send the email fine without raising any exceptions""" injector = inject.Injector() injector.bind( "gmailAccount", to="*****@*****.**" ) injector.bind( "gmailPassword", to="this is another test password" ) inject.register( injector ) gmail = GmailEmailMsg() temp = GmailEmailTemplate() assert_raises( Exception, closure, gmail.sendMessage, "*****@*****.**", "test message", temp.generate( "welcome_email.html", { "userName": "******", "domain": "test.bitpostage.net", "userToken": "1234567890" } ) ) assert_raises( Exception, closure, gmail.sendMessage, "*****@*****.**", "completion email", temp.generate( "completion_email.html", { "userName": "******", "domain": "test.bitpostage.net", } ) )