Example #1
0
 def test_router_with_invalid_path(self):
     router = Router("root handler", "not found handler")
     with self.assertRaises(Exception) as context:
         router.add_handler("home/about",
                            "about handler")  # URL doesn't have a leading /
         self.assertTrue('URL is invalid as it does not start with /' in
                         context.exception)
Example #2
0
 def test_router_with_url_not_found(self):
     router = Router("root handler", "not found handler")
     router.add_handler("/home/about/me", "me handler")
     router.add_handler("/home/cooking/recipe", "recipe handler")
     router.add_handler("/home/contact/email", "email handler")
     router.add_handler("/home/contact/facebook", "facebook handler")
     self.assertEqual(router.lookup("/home/cooking"), "not found handler")