Skip to content

Commit

Permalink
Merge pull request #3 from MarketSquare/delay_loading_of_paths_in_driver
Browse files Browse the repository at this point in the history
Delay loading of paths in driver
  • Loading branch information
robinmackaij authored Mar 15, 2024
2 parents 4e1fc3f + 75de782 commit eb4d837
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 19 deletions.
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}

0 comments on commit eb4d837

Please sign in to comment.