Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay loading of paths in driver #3

Merged
merged 4 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/OpenApiDriver/openapi_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class OpenApiReader(AbstractReaderClass):
def get_data_from_source(self) -> List[TestCaseData]:
test_data: List[TestCaseData] = []

paths = getattr(self, "paths")
read_paths_method = getattr(self, "read_paths_method")
paths: Dict[str, Any] = read_paths_method()
self._filter_paths(paths)

ignored_responses_ = [
Expand Down
4 changes: 2 additions & 2 deletions src/OpenApiDriver/openapidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,11 @@ def __init__( # pylint: disable=too-many-arguments, too-many-locals, dangerous-
proxies=proxies,
)

paths = self.openapi_spec["paths"]
read_paths_method = self.read_paths
DataDriver.__init__(
self,
reader_class=OpenApiReader,
paths=paths,
read_paths_method=read_paths_method,
included_paths=included_paths,
ignored_paths=ignored_paths,
ignored_responses=ignored_responses,
Expand Down
3 changes: 3 additions & 0 deletions src/OpenApiLibCore/openapi_libcore.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,9 @@ def _openapi_spec(self) -> Dict[str, Any]:
parser = self._load_parser()
return parser.specification

def read_paths(self) -> Dict[str, Any]:
return self.openapi_spec["paths"]

def _load_parser(self) -> ResolvingParser:
try:

Expand Down
14 changes: 0 additions & 14 deletions tests/driver/unittests/test_openapidriver.py

This file was deleted.

2 changes: 1 addition & 1 deletion tests/files/schema_with_allof.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ paths:
requestBody:
description: this is a description
content:
application/json:
application/hal+json:
schema:
allOf:
- $ref: '#/components/schemas/MediaMetadata'
Expand Down
3 changes: 2 additions & 1 deletion tests/libcore/suites/test_schema_variations.robot
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ Test Get Request Data For Schema With allOf
${dict}= Create Dictionary
${list}= Create List
${list_of_dict}= Create List ${dict}
${expected_headers}= Create Dictionary content-type=application/hal+json
Length Should Be ${request_data.dto.isan} 36
Length Should Be ${request_data.dto.published} 10
Should Be Equal ${request_data.dto.tags} ${list_of_dict}
Length Should Be ${request_data.dto_schema} 4
Length Should Be ${request_data.dto_schema.get("properties")} 4
Should Be Equal ${request_data.parameters} ${list}
Should Be Equal ${request_data.params} ${dict}
Should Be Equal ${request_data.headers} ${dict}
Should Be Equal ${request_data.headers} ${expected_headers}
Loading