Example #1
0
def register_extensions(flask_app):
    """
    Register Flask extensions.
    """
    Babel(flask_app)  # Babel is currently only used with Flask-Admin.
    CSRFProtect(flask_app)  # Enable CSRF protection globally.
    mandrill = Mandrill()
    mandrill.init_app(flask_app)
    flask_app.extensions[
        'mandrill'] = mandrill  # Provide easy access to the mandrill extension in Blueprints.
    login_manager.init_app(flask_app)
    init_social(flask_app, db_session)
Example #2
0
    def test_specify_key(self, mock_requests):
        mail = Mandrill()
        mail.send_email(key="ABCDEFG", from_email='from')

        data = {
            'async': False,
            'ip_pool': '',
            'key': "ABCDEFG",
            'message': {
                'from_email': 'from'
            }
        }

        mock_requests.post.assert_called_with(self.mail.messages_endpoint,
                                              data=json.dumps(data),
                                              headers=headers)
Example #3
0
 def test_fails_no_sender(self):
     mail = Mandrill()
     self.assertRaises(ValueError, mail.send_email, key='ABCDEFG')
Example #4
0
 def test_fails_no_key(self):
     mail = Mandrill()
     self.assertRaises(ValueError, mail.send_email)
Example #5
0
 def setUp(self):
     self.mail = Mandrill(app)