def test_mailgun_api_successful(self): from_email = "Joe User <*****@*****.**>" to_email = "Jane Sender <*****@*****.**>" subject = "Message Subject" text_message = "This is plain text message." html_message = "<html>This is <b>HTML!</b></html>" def handle(handler): assert handler.get_argument("from") == from_email assert handler.get_argument("to") == to_email assert handler.get_argument("subject") == subject assert handler.get_argument("text") == text_message assert handler.get_argument("html") == html_message return handler.finish({"message": "Queued.", "id": "AWESOME ID"}) self._handle_message = handle base_url = "http://localhost:{0}/v2/account".format(self.get_http_port()) api_key = "API_KEY" client = MailGunClient(base_url, api_key, ioloop=self.io_loop) yield client.send( from_email=from_email, to_email=to_email, subject=subject, text_message=text_message, html_message=html_message, ) self.assertTrue(True, "We didn't fail. Good job.")
def test_mailgun_api_successful(self): from_email = "Joe User <*****@*****.**>" to_email = "Jane Sender <*****@*****.**>" subject = "Message Subject" text_message = "This is plain text message." html_message = "<html>This is <b>HTML!</b></html>" def handle(handler): assert handler.get_argument("from") == from_email assert handler.get_argument("to") == to_email assert handler.get_argument("subject") == subject assert handler.get_argument("text") == text_message assert handler.get_argument("html") == html_message return handler.finish({"message": "Queued.", "id": "AWESOME ID"}) self._handle_message = handle base_url = "http://localhost:{0}/v2/account".format( self.get_http_port()) api_key = "API_KEY" client = MailGunClient(base_url, api_key, ioloop=self.io_loop) yield client.send(from_email=from_email, to_email=to_email, subject=subject, text_message=text_message, html_message=html_message) self.assertTrue(True, "We didn't fail. Good job.")
def test_mailgun_api_send_with_failure(self): base_url = "http://*****:*****@user.com", to_email="*****@*****.**", subject="Subject", text_message="Text", html_message="HTML")
def test_mailgun_api_send_with_failure(self): base_url = "http://*****:*****@user.com", to_email="*****@*****.**", subject="Subject", text_message="Text", html_message="HTML", )
def main(): tornado.log.enable_pretty_logging() logging.getLogger().setLevel(config.LOG_LEVEL) logging.info("Listening on: {0}".format(config.PORT)) sockets = bind_sockets(config.PORT) tornado.process.fork_processes(config.PROCESSES) ioloop = IOLoop.current() protocol = config.DB_URI.split("://")[0] connection = CONNECTIONS[protocol].from_uri(config.DB_URI) store = connection.get_store() queue = get_rax_queue(ioloop) mailgun = MailGunClient( config.MAILGUN_API_URL, config.MAILGUN_API_KEY, ioloop) application = Application(store=store, mailgun=mailgun, queue=queue) server = HTTPServer(application, xheaders=True) server.add_sockets(sockets) ioloop.start()