Beispiel #1
0
    def test_parse_request_json_body_no_data(self):
        from openapi_python_client.parser.openapi import Endpoint, Schemas

        body = oai.RequestBody.construct(content={})
        schemas = Schemas()

        result = Endpoint.parse_request_json_body(body=body, schemas=schemas, parent_name="parent", config=MagicMock())

        assert result == (None, schemas)
Beispiel #2
0
    def test_parse_request_json_body(self, mocker):
        from openapi_python_client.parser.openapi import Endpoint, Schemas

        schema = mocker.MagicMock()
        body = oai.RequestBody.construct(
            content={"application/json": oai.MediaType.construct(media_type_schema=schema)}
        )
        property_from_data = mocker.patch(f"{MODULE_NAME}.property_from_data")
        schemas = Schemas()
        config = MagicMock()

        result = Endpoint.parse_request_json_body(body=body, schemas=schemas, parent_name="parent", config=config)

        property_from_data.assert_called_once_with(
            name="json_body", required=True, data=schema, schemas=schemas, parent_name="parent", config=config
        )
        assert result == property_from_data.return_value