Skip to content

Commit 232d9c6

Browse files
authored
Enhance remote reference parsing test with mock HTTP response (#2659)
1 parent 493d02e commit 232d9c6

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

tests/parser/test_openapi.py

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,9 +524,42 @@ def test_openapi_parser_parse_array_enum(tmp_path: Path, monkeypatch: pytest.Mon
524524
assert_output(parser.parse(), expected_file)
525525

526526

527-
def test_openapi_parser_parse_remote_ref(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
527+
def test_openapi_parser_parse_remote_ref(tmp_path: Path, monkeypatch: pytest.MonkeyPatch, mocker: Any) -> None:
528528
"""Test parsing OpenAPI with remote references."""
529529
monkeypatch.chdir(tmp_path)
530+
531+
remote_schema = """
532+
schemas:
533+
Problem:
534+
properties:
535+
detail:
536+
description: A human readable explanation specific to this occurrence of the problem.
537+
type: string
538+
instance:
539+
description: An absolute URI that identifies the specific occurrence of the problem.
540+
format: uri
541+
type: string
542+
status:
543+
description: The HTTP status code generated by the origin server for this occurrence of the problem.
544+
exclusiveMaximum: true
545+
format: int32
546+
maximum: 600
547+
minimum: 100
548+
type: integer
549+
title:
550+
description: A short, summary of the problem type.
551+
type: string
552+
type:
553+
default: about:blank
554+
description: An absolute URI that identifies the problem type.
555+
format: uri
556+
type: string
557+
type: object
558+
"""
559+
mock_response = mocker.Mock()
560+
mock_response.text = remote_schema
561+
mocker.patch("httpx.get", return_value=mock_response)
562+
530563
parser = OpenAPIParser(
531564
data_model_field_type=DataModelFieldBase,
532565
source=(DATA_PATH / "refs.yaml").read_text(),

0 commit comments

Comments
 (0)