コード例 #1
0
class TestRoot(TestBase):

    def setUp(self):
        TestBase.setUp(self)
        self.controller = Root()

    def test_index(self):
        try:
            self.controller.index()
        except HTTPRedirect as redirect:
            self.assertEqual(redirect.status, 303)
            self.assertTrue(redirect.urls[0].endswith('/docs/index.html'))
コード例 #2
0
ファイル: routes.py プロジェクト: roadlit/bamboo
def connect_routes(dispatcher):
    """This function takes the dispatcher and attaches the routes.

    :param dispatcher: The CherryPy dispatcher.
    """
    # controller instances map
    controllers = {
        'root': Root(),
        'calculations': Calculations(),
        'datasets': Datasets(),
        'version': Version(),
    }

    # map them into args to dispatcher
    dictify = lambda x: dict(zip(['name', 'conditions', 'route', 'controller', 'action'], x))
    route_case = {
        'conditions': lambda v: dict(method=v),
        'controller': lambda v: controllers[v],
    }
    kwarg_map = lambda d: {
        k: route_case.get(k, lambda v: v)(v) for k, v in d.iteritems()
    }

    routes = [kwarg_map(dictify(route)) for route in ROUTES + options()]

    # attach them
    for route in routes:
        dispatcher.connect(**route)
コード例 #3
0
 def setUp(self):
     TestBase.setUp(self)
     self.controller = Root()