Coverage for manila/tests/api/test_wsgi.py: 100%
20 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright 2010 United States Government as represented by the
2# Administrator of the National Aeronautics and Space Administration.
3# Copyright 2010 OpenStack LLC.
4# All Rights Reserved.
5#
6# Licensed under the Apache License, Version 2.0 (the "License"); you may
7# not use this file except in compliance with the License. You may obtain
8# a copy of the License at
9#
10# http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15# License for the specific language governing permissions and limitations
16# under the License.
18"""
19Test WSGI basics and provide some helper functions for other WSGI tests.
20"""
22from oslo_service import wsgi
23import routes
24import webob
26from manila import test
27from manila.wsgi import common as common_wsgi
30class Test(test.TestCase):
32 def test_router(self):
34 class Application(common_wsgi.Application):
35 """Test application to call from router."""
37 def __call__(self, environ, start_response):
38 start_response("200", [])
39 return ['Router result']
41 class Router(wsgi.Router):
42 """Test router."""
44 def __init__(self):
45 mapper = routes.Mapper()
46 mapper.connect("/test", controller=Application())
47 super(Router, self).__init__(mapper)
49 result = webob.Request.blank('/test').get_response(Router())
50 self.assertEqual("Router result", result.body)
51 result = webob.Request.blank('/bad').get_response(Router())
52 self.assertNotEqual(result.body, "Router result")