Beispiel #1
0
    def test_resource_receives_api_version_request_invalid(self):
        invalid_version = "2.5.3"

        class Controller(object):
            def index(self, req):
                return 'success'

        app = fakes.TestRouterV21(Controller())
        req = webob.Request.blank('/tests')
        req.headers = self._make_microversion_header(invalid_version)
        response = req.get_response(app)
        self.assertEqual(400, response.status_int)
Beispiel #2
0
    def test_resource_receives_api_version_request_default(self):
        class Controller(object):
            def index(self, req):
                if req.api_version_request != \
                  api_version.APIVersionRequest(
                      api_version.DEFAULT_API_VERSION):
                    raise webob.exc.HTTPInternalServerError()
                return 'success'

        app = fakes.TestRouterV21(Controller())
        req = webob.Request.blank('/tests')
        response = req.get_response(app)
        self.assertEqual(b'success', response.body)
        self.assertEqual(response.status_int, 200)
Beispiel #3
0
    def test_resource_receives_api_version_request(self, mock_maxver):
        version = "2.5"
        mock_maxver.return_value = api_version.APIVersionRequest(version)

        class Controller(object):
            def index(self, req):
                if req.api_version_request != \
                  api_version.APIVersionRequest(version):
                    raise webob.exc.HTTPInternalServerError()
                return 'success'

        app = fakes.TestRouterV21(Controller())
        req = webob.Request.blank('/tests')
        req.headers = self._make_microversion_header(version)
        response = req.get_response(app)
        self.assertEqual(b'success', response.body)
        self.assertEqual(response.status_int, 200)