Example #1
0
def start_instance(settings):
    settings = ObjectDict(settings)
    print >>stderr, "starting server on http://{}:{}".format(
            settings.httpd_address,
            settings.httpd_port,
            )
    http_server = HTTPServer( Application(routes, **settings) )
    http_server.listen(
        settings.httpd_port,
        address=settings.httpd_address
        )
    mogo_connect(settings.dbname, host=settings.dbhost, port=settings.dbport)

    try: IOLoop.instance().start()
    except KeyboardInterrupt: pass
Example #2
0
from tornado.httputil import url_concat
from tornado.testing import AsyncHTTPTestCase
from tornado.util import ObjectDict
from tornado.web import Application, RequestHandler, URLSpec
from tornroutes import route

from .mpatch import CapturePatch, Patch
from ..base import BaseHandler
from ... import settings
from ...models import User


# setup our database for tests
from mogo import connect as mogo_connect
mogo_connect('bastille_test')

settings = ObjectDict(settings)
# fake our foursquare push gorp
settings.fs_push_secret = 'yourmomma'

# i hate having a global var to capture the state of a monkey patched method but
# as long as tests are run serially, this should work well.
_render_state = {}
def patch_render(handler, template_name, **kwargs):
    global _render_state
    assert(not kwargs.has_key('template_name'))
    assert(not kwargs.has_key('current_user'))
    assert(not kwargs.has_key('final_request_uri'))
    assert(not kwargs.has_key('html_body'))
    kwargs['html_body'] = handler.render_string(template_name, **kwargs)
Example #3
0
from os.path import dirname

from tornado.httputil import url_concat
from tornado.testing import AsyncHTTPTestCase
from tornado.util import ObjectDict
from tornado.web import Application, RequestHandler, URLSpec
from tornroutes import route

from .mpatch import CapturePatch, Patch
from ..base import BaseHandler
from ... import settings
from ...models import User

# setup our database for tests
from mogo import connect as mogo_connect
mogo_connect('bastille_test')

settings = ObjectDict(settings)
# fake our foursquare push gorp
settings.fs_push_secret = 'yourmomma'

# i hate having a global var to capture the state of a monkey patched method but
# as long as tests are run serially, this should work well.
_render_state = {}


def patch_render(handler, template_name, **kwargs):
    global _render_state
    assert (not kwargs.has_key('template_name'))
    assert (not kwargs.has_key('current_user'))
    assert (not kwargs.has_key('final_request_uri'))