@@ -3610,3 +3610,59 @@ def test_main_jsonschema_reserved_field_name_pydantic(output_file: Path) -> None
36103610 "3.11" ,
36113611 ],
36123612 )
3613+
3614+
3615+ @pytest .mark .benchmark
3616+ @LEGACY_BLACK_SKIP
3617+ def test_main_bundled_schema_with_id_local_file (output_file : Path ) -> None :
3618+ """Test bundled schema with $id using local file input (Issue #1798)."""
3619+ run_main_and_assert (
3620+ input_path = JSON_SCHEMA_DATA_PATH / "bundled_schema_with_id.json" ,
3621+ output_path = output_file ,
3622+ input_file_type = "jsonschema" ,
3623+ assert_func = assert_file_content ,
3624+ expected_file = "bundled_schema_with_id.py" ,
3625+ extra_args = [
3626+ "--output-model-type" ,
3627+ "pydantic_v2.BaseModel" ,
3628+ ],
3629+ )
3630+
3631+
3632+ @pytest .mark .benchmark
3633+ @LEGACY_BLACK_SKIP
3634+ def test_main_bundled_schema_with_id_url (mocker : MockerFixture , output_file : Path ) -> None :
3635+ """Test bundled schema with $id using URL input produces same output as local file."""
3636+ schema_path = JSON_SCHEMA_DATA_PATH / "bundled_schema_with_id.json"
3637+
3638+ mock_response = mocker .Mock ()
3639+ mock_response .text = schema_path .read_text ()
3640+
3641+ httpx_get_mock = mocker .patch (
3642+ "httpx.get" ,
3643+ return_value = mock_response ,
3644+ )
3645+
3646+ run_main_url_and_assert (
3647+ url = "https://cdn.example.com/schemas/bundled_schema_with_id.json" ,
3648+ output_path = output_file ,
3649+ input_file_type = "jsonschema" ,
3650+ assert_func = assert_file_content ,
3651+ expected_file = "bundled_schema_with_id.py" ,
3652+ extra_args = [
3653+ "--output-model-type" ,
3654+ "pydantic_v2.BaseModel" ,
3655+ ],
3656+ transform = lambda s : s .replace (
3657+ "# filename: https://cdn.example.com/schemas/bundled_schema_with_id.json" ,
3658+ "# filename: bundled_schema_with_id.json" ,
3659+ ),
3660+ )
3661+
3662+ httpx_get_mock .assert_called_once_with (
3663+ "https://cdn.example.com/schemas/bundled_schema_with_id.json" ,
3664+ headers = None ,
3665+ verify = True ,
3666+ follow_redirects = True ,
3667+ params = None ,
3668+ )
0 commit comments