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)
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')
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')
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)