예제 #1
0
    def test_register_swagger_ui_rule__no_path(self):
        mock_self = Mock()
        mock_self._app.config = {'OPENAPI_SWAGGER_UI_PATH': None}
        mock_blueprint = Mock()

        DocBlueprintMixin._register_swagger_ui_rule(mock_self, mock_blueprint)
        assert isinstance(mock_self._swagger_ui_rule, Mock)
        assert isinstance(mock_self._swagger_ui_supported_submit_methods, Mock)
        mock_blueprint.add_url_rule.assert_not_called()
예제 #2
0
    def test_register_swagger_ui_rule(self, swagger_ui_url, swagger_ui_version, expected_result_url):
        mock_self = Mock()
        mock_self.decorators_for_autodoc = [self.some_dec]
        mock_self._app.config = {'OPENAPI_SWAGGER_UI_PATH': '/swagger_ui',
                                 'OPENAPI_SWAGGER_UI_URL': swagger_ui_url,
                                 'OPENAPI_SWAGGER_UI_VERSION': swagger_ui_version}
        mock_blueprint = Mock()

        DocBlueprintMixin._register_swagger_ui_rule(mock_self, mock_blueprint)
        mock_self._swagger_ui_url = expected_result_url
        mock_self._swagger_ui_supported_submit_methods = ["get", "put", "post", "delete",
                                                          "options", "head", "patch", "trace"]
        mock_blueprint.add_url_rule.assert_called_once_with('/swagger_ui', endpoint='openapi_swagger_ui',
                                                            view_func=self.some_dec(mock_self._openapi_swagger_ui))