Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_works(self):
mailable = MailManager(self.container).driver('smtp').mailable(ForgotPasswordMailable())
self.assertEqual(mailable.to_address, 'idmann509@gmail.com')
self.assertEqual(mailable.from_address, 'admin@test.com')
self.assertEqual(mailable.message_subject, 'Forgot Password')
self.assertEqual(mailable.message_body, 'testing email')
self.assertEqual(mailable.message_reply_to, 'customer@email.com')
self.assertTrue(True)
def test_terminal_mail_renders_template(self):
self.assertIn('MasoniteTesting', MailManager(self.app).driver('terminal').to(
'idmann509@gmail.com').template('mail/welcome', {'to': 'MasoniteTesting'}).message_body)
def test_mail_sends_with_queue_and_without_queue(self):
if env('RUN_MAIL'):
self.assertEqual(MailManager(self.app).driver('smtp').to('idmann509@gmail.com').send('test queue'), None)
self.assertEqual(MailManager(self.app).driver('smtp').queue().to('idmann509@gmail.com').send('test queue'), None)
def test_terminal_driver_output(self):
user = UserMock
user.email = 'test@email.com'
with captured_output() as (_, err):
MailManager(self.app).driver('terminal').to(user).reply_to('reply-to@email.com').send('Masonite')
# This can go inside or outside the `with` block
error = err.getvalue().strip()
self.assertIn('test@email.com', error)
self.assertIn('reply-to@email.com', error)
def test_mail_sends_with_queue_and_without_queue(self):
if env('RUN_MAIL'):
self.assertEqual(MailManager(self.app).driver('mailgun').to('idmann509@gmail.com').send('test queue'), None)
self.assertEqual(MailManager(self.app).driver('mailgun').queue().to('idmann509@gmail.com').send('test queue'), None)
def test_log_mail_renders_template(self):
self.assertIn('MasoniteTesting', MailManager(self.app).driver('log').to(
'idmann509@gmail.com').template('mail/welcome', {'to': 'MasoniteTesting'}).message_body)
def test_log_driver(self):
user = UserMock
user.email = 'test@email.com'
self.assertEqual(MailManager(self.app).driver('log').to(user).to_address, 'test@email.com')
def test_mailgun_driver(self):
user = UserMock
user.email = 'test@email.com'
self.assertEqual(MailManager(self.app).driver('mailgun').to(user).to_address, 'test@email.com')
self.assertEqual(MailManager(self.app).driver('mailgun').reply_to('reply_to@email.com').message_reply_to , 'reply_to@email.com')
def test_smtp_driver(self):
user = UserMock
user.email = 'test@email.com'
self.assertEqual(MailManager(self.app).driver('smtp').to(user).to_address, 'test@email.com')
self.assertEqual(MailManager(self.app).driver('smtp').reply_to('reply_to@email.com').message_reply_to , 'reply_to@email.com')
def test_redis_driver():
container = TestSuite().create_container().container
container.bind('Container', container)
container.bind('Test', 'Test')
container.bind('Mail', MailManager(container))
container.bind('QueueConfig', queue)
container.bind('QueueRedisDriver', QueueRedisDriver)
container.bind('QueueAsyncDriver', QueueAsyncDriver)
container.bind('QueueManager', QueueManager(container))
container.bind('MailConfig', mail)
container.bind('MailSmtpDriver', MailManager(container).driver('smtp'))
manager = container.make('QueueManager').driver('async')