import pymongo.mongo_client import mock import motor from bson import ObjectId from motor_blog import application, cache from motor_blog.options import define_options import tornado.web from tornado import httputil from tornado.options import options as tornado_options from tornado.testing import AsyncHTTPTestCase # Patch Tornado with the Jade template loader from tornado import template from pyjade.ext.tornado import patch_tornado patch_tornado() sample_html = """ <h1>bar</h1> <p>baz quux, fizzle, fazzle. hi! </p> """ define_options(tornado_options) class MotorBlogTest(AsyncHTTPTestCase): def setUp(self): self.database_name = 'test_motorblog' sync_client = pymongo.mongo_client.MongoClient()
#!/usr/bin/env python import logging import tornado.ioloop import tornado.web import os.path import json import uuid from tornado import template from pyjade.ext.tornado import patch_tornado patch_tornado() from tornadio2 import SocketConnection, TornadioRouter, SocketServer, event from threading import Thread class Client(SocketConnection): CONNECTIONS = set() def on_open(self, info): print 'Client connected' self.CONNECTIONS.add(self) def on_message(self, msg): print 'Got', msg def on_close(self): print 'Client disconnected' self.CONNECTIONS.remove(self)
from tornado.web import Application, RequestHandler, \ StaticFileHandler, asynchronous from tornado import web, websocket, ioloop from tornado.httpserver import HTTPServer from tornado.gen import engine import os, json, mimetypes import sys, signal from os import makedirs import time from requests.adapters import HTTPAdapter from requests_futures.sessions import FuturesSession from pyjade.ext.tornado import patch_tornado patch_tornado() #Allows pyjade to work with Tornado from marcopolo.bindings.marco import Marco, MarcoTimeOutException from marcopolo.bindings.polo import Polo, PoloInternalException, PoloException from marcodeployer import utils, conf import logging class NotCheckingHostnameHTTPAdapter(HTTPAdapter): """ A middleware that avoids the verification of the SSL Hostname field. Since the name of the client cannot be verified, it is simply not checked Generously provided by Juan Luis Boya