コード例 #1
0
    def test_terminal_driver(self):
        user = UserMock
        user.email = '*****@*****.**'

        self.assertEqual(
            MailManager(self.app).driver('terminal').to(user).to_address,
            '*****@*****.**')
コード例 #2
0
        def test_mail_renders_template(self):

            assert 'MasoniteTesting' in MailManager(
                self.app).driver('mailgun').to('*****@*****.**').template(
                    'mail/welcome', {
                        'to': 'MasoniteTesting'
                    }).message_body
コード例 #3
0
    def test_send_mail_with_from(self):
        self.app.bind('MailSmtpDriver', MailDriver)

        assert MailManager(
            self.app).driver('smtp').to('*****@*****.**').send_from(
                '*****@*****.**'
            ).from_address == '*****@*****.**'
コード例 #4
0
def test_send_mail():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)

    assert MailManager(app).driver('smtp').to('*****@*****.**')
コード例 #5
0
    def test_terminal_driver_output(self, capsys):
        user = UserMock
        user.email = '*****@*****.**'

        MailManager(self.app).driver('terminal').to(user).send('Masonite')

        captured = capsys.readouterr()
        assert '*****@*****.**' in captured.err
コード例 #6
0
    def test_terminal_mail_renders_template(self):

        self.assertIn(
            'MasoniteTesting',
            MailManager(self.app).driver('terminal').to(
                '*****@*****.**').template('mail/welcome', {
                    'to': 'MasoniteTesting'
                }).message_body)
コード例 #7
0
def test_mail_renders_template():
    app = App()

    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)

    assert 'MasoniteTesting' in MailManager(app).driver('smtp').to(
        '*****@*****.**').template('mail/welcome', {'to': 'MasoniteTesting'}).message_body
コード例 #8
0
def test_send_mail_with_from():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)

    assert MailManager(app).driver('smtp').to('*****@*****.**').send_from(
        '*****@*****.**').from_address == '*****@*****.**'
コード例 #9
0
def test_send_mail_with_subject():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)

    assert MailManager(app).driver('smtp').to('').subject(
        'test').message_subject == 'test'
コード例 #10
0
def test_throws_drivernotfound_exception():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)

    with pytest.raises(DriverNotFound,
                       message="Should raise DriverNotFound error"):
        mailManager = MailManager(app)
コード例 #11
0
    def test_terminal_driver_output(self):
        user = UserMock
        user.email = '*****@*****.**'
        with captured_output() as (_, err):
            MailManager(self.app).driver('terminal').to(user).send('Masonite')

        # This can go inside or outside the `with` block
        error = err.getvalue().strip()
        self.assertIn('*****@*****.**', error)
コード例 #12
0
def test_manager_sets_driver():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', object)
    app.bind('MailMailtrapDriver', object)

    mailManager = MailManager(app).driver('mailtrap')
コード例 #13
0
def test_manager_sets_driver_throws_driver_not_found_exception():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', object)

    with pytest.raises(DriverNotFound,
                       message="Should raise DriverNotFound error"):
        mailManager = MailManager(app).driver('mailtrap')
コード例 #14
0
def test_creates_driver_with_initilization_container():
    app = App()

    app.bind('Test', object)
    app.bind('MailSmtpDriver', object)
    app.bind('MailConfig', mail)

    mailManager = MailManager(app)

    assert mailManager.manage_driver == object
コード例 #15
0
def test_send_mail_with_callable():
    app = App()

    app.bind('Test', object)
    app.bind('MailConfig', mail)
    app.bind('MailSmtpDriver', MailDriver)
    user = User
    setattr(user, 'email', '*****@*****.**')

    assert MailManager(app).driver('smtp').to(User)
コード例 #16
0
    def test_log_driver_output(self):
        user = UserMock
        user.email = '*****@*****.**'

        MailManager(self.app).driver('log').to(user).send('Masonite')

        filepath = '{0}/{1}'.format('bootstrap/mail', 'mail.log')
        self.logfile = open(filepath, 'r')
        file_string = self.logfile.read()

        assert '*****@*****.**' in file_string
コード例 #17
0
    def test_mailgun_driver():
        app = App()

        app.bind('Test', object)
        app.bind('MailConfig', mail)
        app.bind('MailSmtpDriver', MailDriver)
        app.bind('MailMailgunDriver', Mailgun)
        user = User
        user.email = '*****@*****.**'

        assert MailManager(app).driver('mailgun').to(
            user).to_address == '*****@*****.**'
コード例 #18
0
    def setup_method(self):
        self.app = App()
        self.app.bind('Container', self.app)
        self.app.bind('ViewClass', View(self.app))
        # self.app.make('ViewClass').add_environment('notifications/snippets')
        self.app.bind('View', View(self.app).render)
        self.app.bind('MailConfig', MockMailConfig)
        self.app.bind('MailTerminalDriver', MailTerminalDriver)
        self.app.bind('MailMailgunDriver', MailMailgunDriver)
        self.app.bind('MailManager', MailManager(self.app))
        self.app.bind(
            'Mail',
            self.app.make('MailManager').driver(MockMailConfig.DRIVER))

        # Setup and test Queueing
        self.app.bind('QueueAsyncDriver', QueueAsyncDriver)
        self.app.bind('QueueConfig', queue)
        self.app.bind('Container', self.app)
        self.app.bind('QueueManager', QueueManager(self.app))
        self.app.swap(Queue, self.app.make('QueueManager').driver('async'))

        self.notification = WelcomeNotification
        self.notify = Notify(self.app)
コード例 #19
0
 def test_mail_sends_with_queue_and_without_queue(self):
     if env('RUN_MAIL'):
         assert MailManager(self.app).driver('mailgun').to('*****@*****.**').send('test queue') == None
         assert MailManager(self.app).driver('mailgun').queue().to('*****@*****.**').send('test queue') == None
コード例 #20
0
    def test_log_driver(self):
        user = UserMock
        user.email = '*****@*****.**'

        assert MailManager(
            self.app).driver('log').to(user).to_address == '*****@*****.**'
コード例 #21
0
    def test_does_not_create_driver_with_initilization_container(self):

        mailManager = MailManager(self.app)

        assert mailManager.manage_driver == None
コード例 #22
0
    def test_send_mail_with_subject(self):
        self.app.bind('MailSmtpDriver', MailDriver)

        assert MailManager(self.app).driver('smtp').to('').subject('test').message_subject == 'test'
コード例 #23
0
 def test_send_mail(self):
     self.app.bind('MailSmtpDriver', MailDriver)
     assert MailManager(self.app).driver('smtp').to('*****@*****.**')
コード例 #24
0
    def test_drivers_are_resolvable_by_container(self):
        self.app.bind('MailSmtpDriver', MailDriver)

        assert isinstance(MailManager(self.app).driver('smtp'), MailDriver)
コード例 #25
0
 def test_manager_sets_driver_throws_driver_not_found_exception(self):
     with pytest.raises(DriverNotFound, message="Should raise DriverNotFound error"):
         mailManager = MailManager(self.app).driver('mailtrap')
コード例 #26
0
    def test_manager_sets_driver(self):
        self.app.bind('MailMailtrapDriver', Mailgun)

        mailManager = MailManager(self.app).driver('mailtrap')
コード例 #27
0
 def test_mail_manager_loads_container(self):
     mailManager = MailManager()
     assert mailManager.load_container(self.app) 
コード例 #28
0
 def test_send_mail_with_callable(self):
     self.app.bind('MailSmtpDriver', MailDriver)
     user = User
     user.email = '*****@*****.**'
     assert MailManager(self.app).driver('smtp').to(User)
コード例 #29
0
    def test_does_not_raise_drivernotfound_exception(self):

        mailManager = MailManager(self.app)
コード例 #30
0
    def test_creates_driver(self):
        mailManager = MailManager()

        assert mailManager.load_container(self.app).manage_driver == object