Skip to content

[python] Add @responseAsBool Spector test cases and fix ConstantType response generation#10577

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-4339
Draft

[python] Add @responseAsBool Spector test cases and fix ConstantType response generation#10577
Copilot wants to merge 2 commits intomainfrom
copilot/add-test-case-for-pull-4339

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 30, 2026

Adds Python mock API test coverage for the azure/client-generator-core/response-as-bool Spector scenario (TCGC @responseAsBool decorator), which was missing from the test suite.

Changes

  • Dependency bump: @azure-tools/azure-http-specs0.1.0-alpha.40-dev.11 to pull in the response-as-bool spec

  • Generator fix (builder_serializer.py): In DPG mode, when a response type is a ConstantType, the generator was emitting _deserialize(Literal[True], response.json()). HEAD responses have no body, so response.json() raises JSONDecodeError. The fix short-circuits to deserialized = True / deserialized = False directly:

    # Before (broken for HEAD with @responseAsBool)
    deserialized = _deserialize(Literal[True], response.json())
    
    # After
    deserialized = True
  • New tests (test_azure_client_generator_core_response_as_bool.py + async counterpart): covers both scenarios defined by the spec:

    • exists() → HEAD 204 → True
    • not_exists() → HEAD 404 → False

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • dl.google.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https --ignore-workspace (dns block)
  • https://api.github.com/repos/Azure/typespec-azure/pulls/4339/files
    • Triggering command: /home/REDACTED/work/_temp/ghcca-node/node/bin/node /home/REDACTED/work/_temp/ghcca-node/node/bin/node --enable-source-maps /home/REDACTED/work/_temp/copilot-developer-action-main/dist/index.js (http block)
  • iojs.org
    • Triggering command: /usr/bin/curl curl -q --fail --compressed -L -s REDACTED -o - (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

@microsoft-github-policy-service microsoft-github-policy-service Bot added the emitter:client:python Issue for the Python client emitter: @typespec/http-client-python label Apr 30, 2026
Copilot AI changed the title [WIP] Add test case for Azure typespec pull request 4339 [python] Add @responseAsBool Spector test cases and fix ConstantType response generation Apr 30, 2026
Copilot AI requested a review from msyyc April 30, 2026 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

emitter:client:python Issue for the Python client emitter: @typespec/http-client-python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[python] add test case for https://github.com/Azure/typespec-azure/pull/4339

2 participants