changeset 4907:c37069a99cec routing

routing: Add self-test to router.py
author anatoly techtonik <techtonik@gmail.com>
date Tue, 15 Jul 2014 13:47:28 +0300
parents b860ede03056
children 92757447dcf0
files roundup/web/router.py
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/web/router.py	Tue Jul 15 13:42:57 2014 +0300
+++ b/roundup/web/router.py	Tue Jul 15 13:47:28 2014 +0300
@@ -50,3 +50,21 @@
             if match:
                 return handler, match.groups()
         return (None, ())
+
+
+
+# [ ] len(urlmap) should be even to avoid errors
+#     (find a way to explain this to users)
+
+if __name__ == '__main__':
+
+    import unittest
+    class test_Router(unittest.TestCase):
+        def test_example_routes(self):
+            router = Router(EXAMPLE_URLMAP)
+            self.assertEquals(router.get_handler(''), (None, ()))
+            handler, params = router.get_handler('/')
+            self.assertEquals(handler, ExampleHandler)
+            self.assertEquals(params, tuple())
+
+    unittest.main()

Roundup Issue Tracker: http://roundup-tracker.org/