microsoft / microsoft/typespec

Mock server generation for Python emitter

Open
#7,719 0 comments 0 reactions 0 assignees View on GitHub
emitter:client:python
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Go's emitter has a `generate-fakes` option to generate a mock server. In the SDK, these are used to produce `fake` subpackages for libraries: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes. It would be worth investigating whether this is something we'd want to support in Python.

For context, customers have opened multiple issues in the Python SDK to ask about how to mock SDK clients in tests. This is typically done by mocking the transport layer, but mocking transport responses can be difficult for users that are only familiar with the client layer. With a fake server that can map generated client methods to custom mock implementations that return clearer responses, mocking could be much more intuitive.

If we pursue this approach, we'd likely want to include the mock server as a namespace in the SDK package so that the server versions correctly with the SDK. For that reason, an important consideration is how much size a generated mock server would add to a given library.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.