Ejemplo n.º 1
0
 def test_router_add_route(self):
     router = Router()
     router.add_route("/", DumbHandler, "index")
     routes = router.get_routes()
     self.assertEqual(1, len(routes))
     self.assertEqual(2, len(routes[0]))
     self.assertEqual("/", routes[0][0])
     self.assertEqual(DumbHandler, routes[0][1])
Ejemplo n.º 2
0
def main():
    ioloop = IOLoop.instance()
    router = Router()
    register_handlers(router)
    app = Application(router.get_routes())
    app.listen(config.PORT, io_loop=ioloop)
    register_watchers(ioloop)
    ioloop.start()
Ejemplo n.º 3
0
 def test_router_add_route(self):
     router = Router()
     router.add_route("/", DumbHandler, "index")
     routes = router.get_routes()
     self.assertEqual(1, len(routes))
     self.assertEqual(2, len(routes[0]))
     self.assertEqual("/", routes[0][0])
     self.assertEqual(DumbHandler, routes[0][1])
Ejemplo n.º 4
0
def main():
    ioloop = IOLoop.instance()
    router = Router()
    register_handlers(router)
    app = Application(router.get_routes())
    app.listen(config.PORT, io_loop=ioloop)
    register_watchers(ioloop)
    ioloop.start()
Ejemplo n.º 5
0
class TestApplication(AsyncHTTPTestCase):

    def get_router(self):
        if not hasattr(self, "_router"):
            self._router = Router()
            self._router.add_route("/", FakeHandler, "index")
        return self._router

    def clear_router(self):
        delattr(self, "_router")

    def get_app(self):
        return Application(self.get_router().get_routes())

    def test_app(self):
        response = self.fetch("/")
        self.assertEqual(response.code, 200)
        self.assertEqual(response.body, "WORKS!")
Ejemplo n.º 6
0
 def get_app(self):
     router = Router()
     router.add_route("/", IndexHandler, "index")
     return Application(router.get_routes())
Ejemplo n.º 7
0
 def test_router_remove_route(self):
     router = Router()
     router.add_route("/", DumbHandler, "index")
     router.remove_route("index")
Ejemplo n.º 8
0
 def test_router_construction(self):
     # should just work
     router = Router()
     self.assertIsNotNone(router)
Ejemplo n.º 9
0
 def get_app(self):
     router = Router()
     router.add_route("/", IndexHandler, "index")
     return Application(router.get_routes())
Ejemplo n.º 10
0
 def test_router_remove_route(self):
     router = Router()
     router.add_route("/", DumbHandler, "index")
     router.remove_route("index")
Ejemplo n.º 11
0
 def get_router(self):
     if not hasattr(self, "_router"):
         self._router = Router()
         self._router.add_route("/", FakeHandler, "index")
     return self._router