示例#1
0
 def test_collectionjson(self):
     yield self.collectionadd(
         'dummy',
         pjoin(APP_ROOT, 'tests/dummytest.dat'))
     tmp = tempfile.NamedTemporaryFile(suffix='.json')
     session = orm.make_session('sqlite:///' + self.db.name)()
     cdb = session.query(orm.Collection)\
         .first()
     collectionjson(cdb, tmp)
     tmp.flush()
     tmp.seek(0)
     json.loads(tmp.read().decode('utf-8'))
     tmp.close()
示例#2
0
def make_app(xsrf_cookies=False, database="sqlite:///db", autoreload=True, home="."):
    session = orm.make_session(database=database)()
    app = tornado.web.Application(
        [
            URLSpec(r"/", tornado.web.RedirectHandler, {"url": "/collection/list"}, name="root"),
            # JSX:
            URLSpec(r"/(?P<jsx>[^./]+\.jsx$)", JsxHandler, name="jsx"),
        ],
        template_path=os.path.join(os.path.dirname(__file__), "templates"),
        static_path=os.path.join(os.path.dirname(__file__), "static"),
        xsrf_cookies=xsrf_cookies,
        debug=True,
        autoreload=autoreload,
        session=session,
        home=home,
    )
    hcollection.install(app)
    hgame.install(app)
    himporter.install(app)
    _log().info(u"app created")
    return app