示例#1
0
    def test_non_existant_service(self):
        context = element.node.NodeContext(
            element.node.Node('myid', {'type': 'mytype'})
        )

        handler = tests.get_default_handler()

        self.assertRaises(ioc.exceptions.UnknownService, self.handler.execute, handler, context)
示例#2
0
    def test_execute_absolute_scheme(self):

        context = element.node.NodeContext(
            element.node.Node(None, {'type': 'mytype', 'redirect': 'http://github.com'})
        )

        handler = tests.get_default_handler()

        self.handler.execute(handler, context)

        self.assertEquals(handler.get_status(), 302)
        self.assertEquals(handler.get_header('Location'), 'http://github.com')
示例#3
0
    def test_execute_absolute(self):

        context = element.node.NodeContext(
            element.node.Node(None, {'type': 'mytype', 'redirect': '/to', 'path': '/'})
        )

        handler = tests.get_default_handler()

        self.handler.execute(handler, context)

        self.assertEquals(handler.get_status(), 302)
        self.assertEquals(handler.get_header('Location'), '/baseurl/to')
示例#4
0
    def test_return_tuple(self):
        context = element.node.NodeContext(
            element.node.Node('myid', {'type': 'mytype', 'serviceId': 'fake', 'method': 'foo'})
        )

        class Fake(element.node.NodeHandler):
            def foo(self, request_context, context, **kwargs):
                return 200, "hello", {}

        handler = tests.get_default_handler()

        self.handler.container.add('fake', Fake())

        self.handler.execute(handler, context)

        self.assertEquals(handler.get_status(), 200)