From ca09412bffb65d67a6e3373e5c1d486654b8b900 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 09:12:12 +0000 Subject: [PATCH 1/3] Initial plan From cf35699c9a4d0bb0c9df4d40717375157c906c7d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 23 Jun 2026 09:25:13 +0000 Subject: [PATCH 2/3] Add mock API tests for encode/duration lossy scenarios Add sync and async tests for the Encode_Duration_Lossy_intSeconds and Encode_Duration_Lossy_intMilliseconds Spector scenarios (from PR #10835) in both azure and unbranded test flavors. Bump @typespec/http-specs to 0.1.0-alpha.39-dev.2 which includes the lossy duration scenarios. Co-authored-by: msyyc <70930885+msyyc@users.noreply.github.com> --- .../add-lossy-duration-tests-2026-6-23-9-24-23.md | 7 +++++++ packages/http-client-python/package-lock.json | 12 ++++++------ packages/http-client-python/package.json | 2 +- .../azure/asynctests/test_encode_duration_async.py | 6 ++++++ .../tests/mock_api/azure/test_encode_duration.py | 5 +++++ .../asynctests/test_encode_duration_async.py | 6 ++++++ .../tests/mock_api/unbranded/test_encode_duration.py | 5 +++++ 7 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 .chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md diff --git a/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md b/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md new file mode 100644 index 00000000000..02b4074bc77 --- /dev/null +++ b/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md @@ -0,0 +1,7 @@ +--- +changeKind: internal +packages: + - "@typespec/http-client-python" +--- + +Add mock API test cases for encode/duration lossy scenarios (int32-seconds and int32-milliseconds) verifying that durations with fractional precision are serialized as integers. diff --git a/packages/http-client-python/package-lock.json b/packages/http-client-python/package-lock.json index c52d0cbd43f..01d5631147f 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.32.0", + "version": "0.33.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@typespec/http-client-python", - "version": "0.32.0", + "version": "0.33.0", "hasInstallScript": true, "license": "MIT", "dependencies": { @@ -29,7 +29,7 @@ "@typespec/compiler": "^1.13.0", "@typespec/events": "~0.83.0", "@typespec/http": "^1.13.0", - "@typespec/http-specs": "0.1.0-alpha.39-dev.1", + "@typespec/http-specs": "0.1.0-alpha.39-dev.2", "@typespec/openapi": "^1.13.0", "@typespec/rest": "~0.83.0", "@typespec/spec-api": "0.1.0-alpha.14", @@ -2529,9 +2529,9 @@ } }, "node_modules/@typespec/http-specs": { - "version": "0.1.0-alpha.39-dev.1", - "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.39-dev.1.tgz", - "integrity": "sha512-m/e9UYChxZfOcdzD2rEywQYkTqPJDTA8p3gpzrHj5WenfXWU0XA0aKxTIOcm+mj0wvxTfdpP0wFVtcT/dinxbA==", + "version": "0.1.0-alpha.39-dev.2", + "resolved": "https://registry.npmjs.org/@typespec/http-specs/-/http-specs-0.1.0-alpha.39-dev.2.tgz", + "integrity": "sha512-NsxuimkS12gB6RF3j2yGf48bV/LzG0JQbtrZbiGy00RxOAZV59L7gYp852ij6fYN37Uv8P31KHcGM6wIAduAyg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/packages/http-client-python/package.json b/packages/http-client-python/package.json index 2ff9151aefc..65f08273ff0 100644 --- a/packages/http-client-python/package.json +++ b/packages/http-client-python/package.json @@ -119,7 +119,7 @@ "@typespec/sse": "~0.83.0", "@typespec/streams": "~0.83.0", "@typespec/xml": "~0.83.0", - "@typespec/http-specs": "0.1.0-alpha.39-dev.1", + "@typespec/http-specs": "0.1.0-alpha.39-dev.2", "@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/azure/asynctests/test_encode_duration_async.py b/packages/http-client-python/tests/mock_api/azure/asynctests/test_encode_duration_async.py index 6e2dd00b4b0..0e17bd7abc7 100644 --- a/packages/http-client-python/tests/mock_api/azure/asynctests/test_encode_duration_async.py +++ b/packages/http-client-python/tests/mock_api/azure/asynctests/test_encode_duration_async.py @@ -110,6 +110,12 @@ async def test_property(client: DurationClient): assert result.value == datetime.timedelta(milliseconds=210000) +@pytest.mark.asyncio +async def test_lossy(client: DurationClient): + await client.lossy.int_seconds(input=datetime.timedelta(seconds=36.25)) + await client.lossy.int_milliseconds(input=datetime.timedelta(milliseconds=36250.25)) + + @pytest.mark.asyncio async def test_header(client: DurationClient): await client.header.default(duration=datetime.timedelta(days=40)) diff --git a/packages/http-client-python/tests/mock_api/azure/test_encode_duration.py b/packages/http-client-python/tests/mock_api/azure/test_encode_duration.py index 78d5ae4f066..e7ef13f5085 100644 --- a/packages/http-client-python/tests/mock_api/azure/test_encode_duration.py +++ b/packages/http-client-python/tests/mock_api/azure/test_encode_duration.py @@ -105,6 +105,11 @@ def test_property(client: DurationClient): assert result.value == datetime.timedelta(milliseconds=210000) +def test_lossy(client: DurationClient): + client.lossy.int_seconds(input=datetime.timedelta(seconds=36.25)) + client.lossy.int_milliseconds(input=datetime.timedelta(milliseconds=36250.25)) + + def test_header(client: DurationClient): client.header.default(duration=datetime.timedelta(days=40)) client.header.iso8601(duration=datetime.timedelta(days=40)) diff --git a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_encode_duration_async.py b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_encode_duration_async.py index bb99138d88d..0171b5ffaec 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_encode_duration_async.py +++ b/packages/http-client-python/tests/mock_api/unbranded/asynctests/test_encode_duration_async.py @@ -110,6 +110,12 @@ async def test_property(client: DurationClient): assert result.value == datetime.timedelta(milliseconds=210000) +@pytest.mark.asyncio +async def test_lossy(client: DurationClient): + await client.lossy.int_seconds(input=datetime.timedelta(seconds=36.25)) + await client.lossy.int_milliseconds(input=datetime.timedelta(milliseconds=36250.25)) + + @pytest.mark.asyncio async def test_header(client: DurationClient): await client.header.default(duration=datetime.timedelta(days=40)) diff --git a/packages/http-client-python/tests/mock_api/unbranded/test_encode_duration.py b/packages/http-client-python/tests/mock_api/unbranded/test_encode_duration.py index 0f9e6a1a593..b1a1e0ec2fc 100644 --- a/packages/http-client-python/tests/mock_api/unbranded/test_encode_duration.py +++ b/packages/http-client-python/tests/mock_api/unbranded/test_encode_duration.py @@ -105,6 +105,11 @@ def test_property(client: DurationClient): assert result.value == datetime.timedelta(milliseconds=210000) +def test_lossy(client: DurationClient): + client.lossy.int_seconds(input=datetime.timedelta(seconds=36.25)) + client.lossy.int_milliseconds(input=datetime.timedelta(milliseconds=36250.25)) + + def test_header(client: DurationClient): client.header.default(duration=datetime.timedelta(days=40)) client.header.iso8601(duration=datetime.timedelta(days=40)) From 7480c798b835856867dc18684b99a07debb805aa Mon Sep 17 00:00:00 2001 From: Yuchao Yan Date: Wed, 24 Jun 2026 11:44:27 +0800 Subject: [PATCH 3/3] Update add-lossy-duration-tests-2026-6-23-9-24-23.md --- .chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md b/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md index 02b4074bc77..c7682bfa634 100644 --- a/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md +++ b/.chronus/changes/add-lossy-duration-tests-2026-6-23-9-24-23.md @@ -4,4 +4,4 @@ packages: - "@typespec/http-client-python" --- -Add mock API test cases for encode/duration lossy scenarios (int32-seconds and int32-milliseconds) verifying that durations with fractional precision are serialized as integers. +Add mock API test cases for encode/duration lossy scenarios (int32-seconds and int32-milliseconds) verifying that durations with fractional precision are serialized as integers