#!/usr/bin/env python

from app import *
import os
import unittest


class AppKitUnitTest(unittest.TestCase):
    def setUp(self):
        app = App(__file__)

        @app.route('^/$')
        def home():
            return 'hi'

        self.app = app

    def test_init_gtk(self):
        try:
            Gtk.init('')
        except:
            raise Exception('Can\'t init Gtk')

    def test___init__(self):
        self.assertIsInstance(self.app.window, Gtk.Window)
        self.assertIsInstance(self.app.webkit_web_view, WebKit.WebView)
        self.assertIsInstance(self.app.webkit_main_frame, WebKit.WebFrame)
        self.assertTrue(os.path.isdir(self.app.app_path))

    def test_route(self):
        self.assertEqual(self.app.url_pattern.keys()[0], '^/$')
        self.assertTrue(hasattr(self.app.url_pattern['^/$'], '__call__'))

    def test__url_map_to_function(self):
        self.assertEqual(self.app._url_map_to_function('/'), 'hi')


if __name__ == '__main__':
    unittest.main()

@@ -224,16 +224,277 @@
 n 'hi'%0A%0A
+        @app.route('/sum/(.+)/(.+)/')%0A        def sum(arg1, arg2):%0A            return int(arg1) + int(arg2)%0A%0A        @app.route('/greeting/(?P%3Cgreeting%3E.+)/(?P%3Cname%3E.+)/')%0A        def greeting(*args, **kw):%0A            print kw%5B'greeting'%5D + ' ' + kw%5B'name'%5D%0A%0A%0A
         
@@ -1207,16 +1207,152 @@
 , 'hi')%0A
+        self.assertEqual(self.app._url_map_to_function('/sum/1/2/'), 3)%0A        self.app._url_map_to_function('/greeting/Hello/Gnome/')%0A
 %0A%0Aif __n

Add routing test