Ejemplo n.º 1
0
    def test_vh_host(self):
        from zope.traversing.namespace import vh

        request = TestRequest(['folder1'], ['folder1_1', '++'])
        ob = object()
        result = vh(ob, request).traverse('http:www.fubarco.com:80', ())

        self.assertEqual(request._app_server, 'http://www.fubarco.com:80')
Ejemplo n.º 2
0
    def test_unicode_vh_host(self):
        from zope.traversing.namespace import vh

        request = TestRequest(['folder1'], ['folder1_1', '++'])
        ob = object()

        result = vh(ob, request).traverse(u'http:www.fubarco.com:80', ())
        assert(isinstance(request._app_server, str))
Ejemplo n.º 3
0
    def test_unicode_vh_host(self):
        from zope.traversing.namespace import vh

        request = TestRequest(['folder1'], ['folder1_1', '++'])
        ob = object()

        result = vh(ob, request).traverse(u'http:www.fubarco.com:80', ())
        self.assertTrue(isinstance(request._app_server, str), repr(request._app_server))
Ejemplo n.º 4
0
    def test_vh_noPlusPlus(self):
        from zope.traversing.namespace import vh

        # GET /folder1/folder2/++vh++http:host:80/folder1_1
        request = TestRequest(['folder1', 'folder2'], ['folder1_1'])
        ob = object()
        handler = vh(ob, request)
        self.assertRaises(ValueError, handler.traverse, 'http:host:80', ())
Ejemplo n.º 5
0
    def test_vh_host(self):
        from zope.traversing.namespace import vh

        request = TestRequest(['folder1'], ['folder1_1', '++'])
        ob = object()
        result = vh(ob, request).traverse('http:www.fubarco.com:80', ())

        self.assertEqual(request._app_server, 'http://www.fubarco.com:80')
Ejemplo n.º 6
0
    def test_vh_noPlusPlus(self):
        from zope.traversing.namespace import vh

        # GET /folder1/folder2/++vh++http:host:80/folder1_1
        request = TestRequest(['folder1', 'folder2'], ['folder1_1'])
        ob = object()
        handler = vh(ob, request)
        self.assertRaises(ValueError, handler.traverse, 'http:host:80', ())
Ejemplo n.º 7
0
    def test_vh(self):
        from zope.traversing.namespace import vh

        # GET /folder1/++vh++/x/y/z/++/folder1_1

        request = TestRequest(['folder1'], ['folder1_1', '++', 'z', 'y', 'x'])
        ob = object()
        result = vh(ob, request).traverse('', ())

        self.assertEqual(result, ob)
        self.assertEqual(request._traversal_stack, ['folder1_1'])
        self.assertEqual(request._traversed_names, [])
        self.assertEqual(request._app_names, ['x', 'y', 'z'])
        self.assertEqual(request._app_server, 'http://server')
Ejemplo n.º 8
0
    def test_vh(self):
        from zope.traversing.namespace import vh

        # GET /folder1/++vh++/x/y/z/++/folder1_1

        request = TestRequest(['folder1'], ['folder1_1', '++', 'z', 'y', 'x'])
        ob = object()
        result = vh(ob, request).traverse('', ())

        self.assertEqual(result, ob)
        self.assertEqual(request._traversal_stack, ['folder1_1'])
        self.assertEqual(request._traversed_names, [])
        self.assertEqual(request._app_names, ['x', 'y', 'z'])
        self.assertEqual(request._app_server, 'http://server')
Ejemplo n.º 9
0
 def test_invalid_vh(self):
     with self.assertRaisesRegex(ValueError,
                                 'Vhost directive should have the form'):
         namespace.vh(None, None).traverse(u'invalid name', ())