diff --git a/src/OpenApiDriver/openapi_reader.py b/src/OpenApiDriver/openapi_reader.py index 5d0e823..eb709a7 100644 --- a/src/OpenApiDriver/openapi_reader.py +++ b/src/OpenApiDriver/openapi_reader.py @@ -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_ = [ diff --git a/src/OpenApiDriver/openapidriver.py b/src/OpenApiDriver/openapidriver.py index 0869f51..a42f39c 100644 --- a/src/OpenApiDriver/openapidriver.py +++ b/src/OpenApiDriver/openapidriver.py @@ -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, diff --git a/src/OpenApiLibCore/openapi_libcore.py b/src/OpenApiLibCore/openapi_libcore.py index bab053c..39f96d1 100644 --- a/src/OpenApiLibCore/openapi_libcore.py +++ b/src/OpenApiLibCore/openapi_libcore.py @@ -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: diff --git a/tests/driver/unittests/test_openapidriver.py b/tests/driver/unittests/test_openapidriver.py deleted file mode 100644 index 8ab716d..0000000 --- a/tests/driver/unittests/test_openapidriver.py +++ /dev/null @@ -1,14 +0,0 @@ -import unittest - -from OpenApiDriver import OpenApiDriver - - -class TestInit(unittest.TestCase): - def test_load_from_invalid_source(self): - self.assertRaises( - Exception, OpenApiDriver, source="http://localhost:8000/openapi.doc" - ) - - -if __name__ == "__main__": - unittest.main() diff --git a/tests/files/schema_with_allof.yaml b/tests/files/schema_with_allof.yaml index 8a164f8..41cb46c 100644 --- a/tests/files/schema_with_allof.yaml +++ b/tests/files/schema_with_allof.yaml @@ -43,7 +43,7 @@ paths: requestBody: description: this is a description content: - application/json: + application/hal+json: schema: allOf: - $ref: '#/components/schemas/MediaMetadata' diff --git a/tests/libcore/suites/test_schema_variations.robot b/tests/libcore/suites/test_schema_variations.robot index 1fb53da..201e2f0 100644 --- a/tests/libcore/suites/test_schema_variations.robot +++ b/tests/libcore/suites/test_schema_variations.robot @@ -16,6 +16,7 @@ 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} @@ -23,4 +24,4 @@ Test Get Request Data For Schema With allOf 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}