diff --git a/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md b/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md new file mode 100644 index 00000000000..a686e9de33b --- /dev/null +++ b/.chronus/changes/add-python-single-discriminator-no-subtypes-tests-2026-6-4-23-29-0.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add sync and async mock_api tests for the single-discriminator no-subtypes Spector scenario from http-specs. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index 81826b56021..8580e7f3a1c 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -1,12 +1,12 @@ { "name": "@typespec/http-client-python", - "version": "0.30.0", + "version": "0.30.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-python", - "version": "0.30.0", + "version": "0.30.1", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.12.0", "@typespec/events": "~0.82.0", "@typespec/http": "^1.12.0", - "@typespec/http-specs": "0.1.0-alpha.37", + "@typespec/http-specs": "0.1.0-alpha.38-dev.1", "@typespec/openapi": "^1.12.0", "@typespec/rest": "~0.82.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2529,24 +2529,24 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.37", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.37.tgz", - "integrity": "sha512-XOIr51yuGVGMjr83OlpaeXWv2CSV+nnFZl8+Evws/M3DZfpQhMmbl7bSVYu378kCjFCw2JNLlob9e3fzJxaNdg==", + "version": "0.1.0-alpha.38-dev.1", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.38-dev.1.tgz", + "integrity": "sha512-FqvLW1nM5P0WBvA5TTghgrrxPYLPsjFA4fN4V4mKumuBDG4ty3+KjBpJvFZE3GVCIsXQqP+sF08YzC5nG3iV+g==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.14", - "@typespec/spector": "^0.1.0-alpha.25" + "@typespec/spec-api": "^0.1.0-alpha.14 || >= 0.1.0-dev.0", + "@typespec/spector": "^0.1.0-alpha.25 || >= 0.1.0-dev.0" }, "engines": { "node": ">=22.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.12.0", - "@typespec/http": "^1.12.0", - "@typespec/rest": "^0.82.0", - "@typespec/versioning": "^0.82.0", - "@typespec/xml": "^0.82.0" + "@typespec/compiler": "^1.12.0 || >= 1.13.0-dev.12", + "@typespec/http": "^1.12.0 || >= 1.13.0-dev.0", + "@typespec/rest": "^0.82.0 || >= 0.83.0-dev.0", + "@typespec/versioning": "^0.82.0 || >= 0.83.0-dev.0", + "@typespec/xml": "^0.82.0 || >= 0.83.0-dev.0" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 51ef3714e9c..b83efff03fa 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -115,7 +115,7 @@ "@typespec/sse": "~0.82.0", "@typespec/streams": "~0.82.0", "@typespec/xml": "~0.82.0", - "@typespec/http-specs": "0.1.0-alpha.37", + "@typespec/http-specs": "0.1.0-alpha.38-dev.1", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8", diff --git a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py index e6ddd9c44fc..5c7a211edbe 100644 --- a/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py +++ b/packages/http-client-python/tests/mock_api/shared/asynctests/test_typetest_model_inheritance_single_discriminator_async.py @@ -6,7 +6,7 @@ import pytest import pytest_asyncio from typetest.model.singlediscriminator.aio import SingleDiscriminatorClient -from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur +from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur, Fish @pytest_asyncio.fixture @@ -63,6 +63,16 @@ async def test_get_wrong_discriminator(client): assert await client.get_wrong_discriminator() == Bird(wingspan=1, kind="wrongKind") +@pytest.mark.asyncio +async def test_get_no_subtypes_model(client): + assert await client.get_no_subtypes_model() == Fish(kind="salmon", size=10) + + +@pytest.mark.asyncio +async def test_put_no_subtypes_model(client): + await client.put_no_subtypes_model(Fish(kind="salmon", size=10)) + + @pytest.mark.asyncio async def test_get_legacy_model(client): assert await client.get_legacy_model() == Dinosaur(size=20, kind="t-rex") diff --git a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py index 86435d5486d..d83894d6750 100644 --- a/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py +++ b/packages/http-client-python/tests/mock_api/shared/test_typetest_model_inheritance_single_discriminator.py @@ -5,7 +5,7 @@ # -------------------------------------------------------------------------- import pytest from typetest.model.singlediscriminator import SingleDiscriminatorClient -from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur +from typetest.model.singlediscriminator.models import Sparrow, Eagle, Bird, Dinosaur, Fish @pytest.fixture @@ -56,5 +56,13 @@ def test_get_wrong_discriminator(client): assert client.get_wrong_discriminator() == Bird(wingspan=1, kind="wrongKind") +def test_get_no_subtypes_model(client): + assert client.get_no_subtypes_model() == Fish(kind="salmon", size=10) + + +def test_put_no_subtypes_model(client): + client.put_no_subtypes_model(Fish(kind="salmon", size=10)) + + def test_get_legacy_model(client): assert client.get_legacy_model() == Dinosaur(size=20, kind="t-rex")