Skip to content

Commit

Permalink
refactor: Rename _get_response_schema to get_response_schema
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed May 8, 2020
1 parent 4b5f24f commit 7e6bf6d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
12 changes: 3 additions & 9 deletions src/schemathesis/schemas.py
Expand Up @@ -147,9 +147,7 @@ def clone( # pylint: disable=too-many-arguments
validate_schema=validate_schema, # type: ignore
)

def _get_response_schema(
self, definition: Dict[str, Any], scope: str
) -> Tuple[List[str], Optional[Dict[str, Any]]]:
def get_response_schema(self, definition: Dict[str, Any], scope: str) -> Tuple[List[str], Optional[Dict[str, Any]]]:
"""Extract response schema from `responses`."""
raise NotImplementedError

Expand Down Expand Up @@ -338,9 +336,7 @@ def parameter_to_json_schema(self, data: Dict[str, Any]) -> Dict[str, Any]:
if not (key == "required" and not isinstance(value, list))
}

def _get_response_schema(
self, definition: Dict[str, Any], scope: str
) -> Tuple[List[str], Optional[Dict[str, Any]]]:
def get_response_schema(self, definition: Dict[str, Any], scope: str) -> Tuple[List[str], Optional[Dict[str, Any]]]:
scopes, definition = self.resolver.resolve_in_scope(deepcopy(definition), scope)
schema = definition.get("schema")
if not schema:
Expand Down Expand Up @@ -432,9 +428,7 @@ def parameter_to_json_schema(self, data: Dict[str, Any]) -> Dict[str, Any]:
# "schema" field is required for all parameters in Open API 3.0
return super().parameter_to_json_schema(data["schema"])

def _get_response_schema(
self, definition: Dict[str, Any], scope: str
) -> Tuple[List[str], Optional[Dict[str, Any]]]:
def get_response_schema(self, definition: Dict[str, Any], scope: str) -> Tuple[List[str], Optional[Dict[str, Any]]]:
scopes, definition = self.resolver.resolve_in_scope(deepcopy(definition), scope)
options = iter(definition.get("content", {}).values())
option = next(options, None)
Expand Down
4 changes: 2 additions & 2 deletions src/schemathesis/specs/openapi/checks.py
Expand Up @@ -72,7 +72,7 @@ def response_schema_conformance(response: GenericResponse, case: "Case") -> None
else:
# No response defined for the received response status code
return
scopes, schema = case.endpoint.schema._get_response_schema(definition, case.endpoint.definition.scope)
scopes, schema = case.endpoint.schema.get_response_schema(definition, case.endpoint.definition.scope)
if not schema:
return
if isinstance(response, requests.Response):
Expand All @@ -92,7 +92,7 @@ def response_schema_conformance(response: GenericResponse, case: "Case") -> None
def in_scopes(resolver: jsonschema.RefResolver, scopes: List[str]) -> Generator[None, None, None]:
"""Push all available scopes into the resolver.
There could be an additional scope change during schema resolving in `_get_response_schema`, so in total there
There could be an additional scope change during schema resolving in `get_response_schema`, so in total there
could be a stack of two scopes maximum. This context manager handles both cases (1 or 2 scope changes) in the same
way.
"""
Expand Down

0 comments on commit 7e6bf6d

Please sign in to comment.