diff --git a/.chronus/changes/python-float-duration-tests-2026-3-10-1-21-39.md b/.chronus/changes/python-float-duration-tests-2026-3-10-1-21-39.md new file mode 100644 index 00000000000..187e7215a3c --- /dev/null +++ b/.chronus/changes/python-float-duration-tests-2026-3-10-1-21-39.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add test cases for float duration encode scenarios in query and header params, covering `float_milliseconds`, `float64_milliseconds`, `float_seconds_larger_unit`, and `float_milliseconds_larger_unit` with whole-number float values (e.g. `35625.0`) that require numeric comparison. diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_encode_duration_async.py b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_encode_duration_async.py index 0fca0371948..92a2ebe6a5b 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_encode_duration_async.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/asynctests/test_encode_duration_async.py @@ -30,6 +30,10 @@ async def test_query(client: DurationClient): await client.query.int32_seconds_array(input=[36, 47]) await client.query.float_seconds(input=35.625) await client.query.float64_seconds(input=35.625) + await client.query.float_milliseconds(input=35625.0) + await client.query.float64_milliseconds(input=35625.0) + await client.query.float_seconds_larger_unit(input=150.0) + await client.query.float_milliseconds_larger_unit(input=210000.0) @pytest.mark.asyncio @@ -61,3 +65,7 @@ async def test_header(client: DurationClient): await client.header.int32_seconds(duration=36) await client.header.float_seconds(duration=35.625) await client.header.float64_seconds(duration=35.625) + await client.header.float_milliseconds(duration=35625.0) + await client.header.float64_milliseconds(duration=35625.0) + await client.header.float_seconds_larger_unit(duration=150.0) + await client.header.float_milliseconds_larger_unit(duration=210000.0) diff --git a/packages/http-client-python/generator/test/azure/mock_api_tests/test_encode_duration.py b/packages/http-client-python/generator/test/azure/mock_api_tests/test_encode_duration.py index db0e29416f4..12bddc921f7 100644 --- a/packages/http-client-python/generator/test/azure/mock_api_tests/test_encode_duration.py +++ b/packages/http-client-python/generator/test/azure/mock_api_tests/test_encode_duration.py @@ -29,6 +29,10 @@ def test_query(client: DurationClient): client.query.int32_seconds_array(input=[36, 47]) client.query.float_seconds(input=35.625) client.query.float64_seconds(input=35.625) + client.query.float_milliseconds(input=35625.0) + client.query.float64_milliseconds(input=35625.0) + client.query.float_seconds_larger_unit(input=150.0) + client.query.float_milliseconds_larger_unit(input=210000.0) def test_property(client: DurationClient): @@ -58,3 +62,7 @@ def test_header(client: DurationClient): client.header.int32_seconds(duration=36) client.header.float_seconds(duration=35.625) client.header.float64_seconds(duration=35.625) + client.header.float_milliseconds(duration=35625.0) + client.header.float64_milliseconds(duration=35625.0) + client.header.float_seconds_larger_unit(duration=150.0) + client.header.float_milliseconds_larger_unit(duration=210000.0) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_encode_duration_async.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_encode_duration_async.py index f14c436a8f8..25804f6a3a4 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_encode_duration_async.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/asynctests/test_encode_duration_async.py @@ -30,6 +30,10 @@ async def test_query(client: DurationClient): await client.query.int32_seconds_array(input=[36, 47]) await client.query.float_seconds(input=35.625) await client.query.float64_seconds(input=35.625) + await client.query.float_milliseconds(input=35625.0) + await client.query.float64_milliseconds(input=35625.0) + await client.query.float_seconds_larger_unit(input=150.0) + await client.query.float_milliseconds_larger_unit(input=210000.0) @pytest.mark.asyncio @@ -61,3 +65,7 @@ async def test_header(client: DurationClient): await client.header.int32_seconds(duration=36) await client.header.float_seconds(duration=35.625) await client.header.float64_seconds(duration=35.625) + await client.header.float_milliseconds(duration=35625.0) + await client.header.float64_milliseconds(duration=35625.0) + await client.header.float_seconds_larger_unit(duration=150.0) + await client.header.float_milliseconds_larger_unit(duration=210000.0) diff --git a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_encode_duration.py b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_encode_duration.py index 6025a3670da..87b038bb68c 100644 --- a/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_encode_duration.py +++ b/packages/http-client-python/generator/test/unbranded/mock_api_tests/test_encode_duration.py @@ -29,6 +29,10 @@ def test_query(client: DurationClient): client.query.int32_seconds_array(input=[36, 47]) client.query.float_seconds(input=35.625) client.query.float64_seconds(input=35.625) + client.query.float_milliseconds(input=35625.0) + client.query.float64_milliseconds(input=35625.0) + client.query.float_seconds_larger_unit(input=150.0) + client.query.float_milliseconds_larger_unit(input=210000.0) def test_property(client: DurationClient): @@ -58,3 +62,7 @@ def test_header(client: DurationClient): client.header.int32_seconds(duration=36) client.header.float_seconds(duration=35.625) client.header.float64_seconds(duration=35.625) + client.header.float_milliseconds(duration=35625.0) + client.header.float64_milliseconds(duration=35625.0) + client.header.float_seconds_larger_unit(duration=150.0) + client.header.float_milliseconds_larger_unit(duration=210000.0) diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index f4a84d1c7c6..0972d615f3a 100644 --- a/packages/http-client-python/package-lock.json +++ b/packages/http-client-python/package-lock.json @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.9.0", "@typespec/events": "~0.79.0", "@typespec/http": "^1.9.0", - "@typespec/http-specs": "0.1.0-alpha.33-dev.2", + "@typespec/http-specs": "0.1.0-alpha.33-dev.6", "@typespec/openapi": "^1.9.0", "@typespec/rest": "~0.79.0", "@typespec/spec-api": "0.1.0-alpha.12", @@ -2492,25 +2492,25 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.33-dev.2", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.33-dev.2.tgz", - "integrity": "sha512-Ex7PVBJgJAmNLKMbp9jA6+fXalcau3Rf+J7N8XMwCICvz6yFcRJKF07/NsM3Doc87e43VovnrJb2I2tb7LSuDw==", + "version": "0.1.0-alpha.33-dev.6", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.33-dev.6.tgz", + "integrity": "sha512-uFBNBO2s6ETxHhpwqOBq5YAIoHFkaFhXvpbW/hEAi7MH3SzsnRClt9Z+e9l+bmEtcGld4b17O0lwWFYd9XduGA==", "dev": true, "license": "MIT", "dependencies": { - "@typespec/spec-api": "^0.1.0-alpha.12 || >=0.1.0-alpha.13-dev <0.1.0-alpha.13", - "@typespec/spector": "^0.1.0-alpha.23 || >=0.1.0-alpha.24-dev <0.1.0-alpha.24", + "@typespec/spec-api": "^0.1.0-alpha.12 || >= 0.1.0-alpha.13-dev.1", + "@typespec/spector": "^0.1.0-alpha.23 || >= 0.1.0-alpha.24-dev.4", "deep-equal": "^2.2.0" }, "engines": { "node": ">=16.0.0" }, "peerDependencies": { - "@typespec/compiler": "^1.9.0", - "@typespec/http": "^1.9.0", - "@typespec/rest": "^0.79.0 || >=0.80.0-dev <0.80.0", - "@typespec/versioning": "^0.79.0 || >=0.80.0-dev <0.80.0", - "@typespec/xml": "^0.79.0 || >=0.80.0-dev <0.80.0" + "@typespec/compiler": "^1.9.0 || >= 1.10.0-dev.15", + "@typespec/http": "^1.9.1 || >= 1.10.0-dev.5", + "@typespec/rest": "^0.79.0 || >= 0.80.0-dev.2", + "@typespec/versioning": "^0.79.0 || >= 0.80.0-dev.3", + "@typespec/xml": "^0.79.0 || >= 0.80.0-dev.2" } }, "node_modules/@typespec/openapi": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 2752851f089..41bd1bb9fa7 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -94,7 +94,7 @@ "@typespec/sse": "~0.79.0", "@typespec/streams": "~0.79.0", "@typespec/xml": "~0.79.0", - "@typespec/http-specs": "0.1.0-alpha.33-dev.2", + "@typespec/http-specs": "0.1.0-alpha.33-dev.6", "@types/js-yaml": "~4.0.5", "@types/node": "~25.0.2", "@types/semver": "7.5.8",