def test_file_defauld(io_loop): options.storage = 'json' options.fileStorageLocation = None with pytest.raises(StorageError): storage = get_storage_cls()(io_loop, 'key') options.fileStorageLocation = 'file.json' storage = get_storage_cls()(io_loop, 'key') assert isinstance(storage, FileStorage)
def __init__(self): staticPath = os.path.join(options.resourcesBasePath, "public") templatesPath = os.path.join(options.resourcesBasePath, "templates") mobilePath = options.mobileAppPath if mobilePath: handlers = [ (r'/m', tornado.web.RedirectHandler, { "url": "/m/index.html" }), (r'/m/', tornado.web.RedirectHandler, { "url": "/m/index.html" }), (r'/m/(.*)', ServeMobileFileHandler, { 'path': mobilePath }), ] else: handlers = [] handlers.extend([ (r"/", IndexHandler), (r"/login", IndexHandler), # M-PIN handlers (r"/{0}/(.*)".format(options.rpsPrefix), RPSRedirectHandler), (r"/mpinVerify", VerifyUserHandler), (r"/mpinAuthenticate", AuthenticateUserHandler), (r"/mpinActivate", mpinActivateHandler), (r"/mpinPermitUser", mpinPermitUserHandler), # Application handlers (r"/protected/(.*)", ProtectedHandler), (r"/protected", ProtectedHandler), (r"/about", AboutHandler), (r"/logout", LogoutHandler), (r"/logoutWait", LogoutWaitHandler), ]) if os.path.exists(os.path.join(templatesPath, "404.html")): handlers.extend([(r"/(.*)", NotFoundHandler)]) settings = { "template_path": templatesPath, "static_path": staticPath, "static_url_prefix": "/public/", "cookie_secret": options.cookieSecret, "xsrf_cookies": False } super(Application, self).__init__(handlers, **settings) storage_cls = get_storage_cls() self.storage = storage_cls(tornado.ioloop.IOLoop.instance(), 'key')
def __init__(self): staticPath = os.path.join(options.resourcesBasePath, "public") templatesPath = os.path.join(options.resourcesBasePath, "templates") mobilePath = options.mobileAppPath if mobilePath: handlers = [ (r'/m', tornado.web.RedirectHandler, {"url": "/m/index.html"}), (r'/m/', tornado.web.RedirectHandler, {"url": "/m/index.html"}), (r'/m/(.*)', ServeMobileFileHandler, {'path': mobilePath}), ] else: handlers = [] handlers.extend([ (r"/", IndexHandler), (r"/login", IndexHandler), # M-PIN handlers (r"/{0}/(.*)".format(options.rpsPrefix), RPSRedirectHandler), (r"/mpinVerify", VerifyUserHandler), (r"/mpinAuthenticate", AuthenticateUserHandler), (r"/mpinActivate", mpinActivateHandler), (r"/mpinPermitUser", mpinPermitUserHandler), # Application handlers (r"/protected/(.*)", ProtectedHandler), (r"/protected", ProtectedHandler), (r"/about", AboutHandler), (r"/logout", LogoutHandler), (r"/logoutWait", LogoutWaitHandler), ]) if os.path.exists(os.path.join(templatesPath, "404.html")): handlers.extend([(r"/(.*)", NotFoundHandler)]) settings = { "template_path": templatesPath, "static_path": staticPath, "static_url_prefix": "/public/", "cookie_secret": options.cookieSecret, "xsrf_cookies": False } super(Application, self).__init__(handlers, **settings) storage_cls = get_storage_cls() self.storage = storage_cls(tornado.ioloop.IOLoop.instance(), 'key')
def test_invalid_defauld(io_loop): options.storage = 'invalid' with pytest.raises(SystemExit): get_storage_cls()(io_loop, 'key')
def test_redis_defauld(io_loop): options.storage = 'redis' storage = get_storage_cls()(io_loop, 'key') assert isinstance(storage, RedisStorage)
def test_memory_defauld(io_loop): options.storage = 'memory' storage = get_storage_cls()(io_loop, 'key') assert isinstance(storage, MemoryStorage)
def test_defauld(io_loop): storage = get_storage_cls()(io_loop, 'key') assert isinstance(storage, MemoryStorage)