class documentation

class GeminiTestServer: (source)

Constructor: GeminiTestServer(responses)

View In Hierarchy

Scripts Gemini model responses so workflows run without real API calls.

Pass canned response bodies built with text_response / function_call_response. Each model call — including each turn of an automatic-function-calling loop and each generate_content_stream call — consumes the next response in order. Build a plugin with plugin and register it on your worker; inspect requests afterwards to assert exactly what the integration sent.

Only model calls (client.models) are scripted. File, interaction, and agent operations are not; mock those on a genai.Client directly if a test needs them.

Method __init__ Initialize with the response bodies to serve, in order.
Method plugin Return a GoogleGenAIPlugin whose model calls serve the script.
Instance Variable requests Undocumented
Method _next Undocumented
Instance Variable _index Undocumented
Instance Variable _responses Undocumented
def __init__(self, responses: Sequence[str]): (source)

Initialize with the response bodies to serve, in order.

def plugin(self) -> GoogleGenAIPlugin: (source)

Return a GoogleGenAIPlugin whose model calls serve the script.

The real plugin activities run; only the underlying HTTP layer is replaced, so request formatting and the AFC loop are exercised exactly as in production.

Undocumented

def _next(self) -> str: (source)

Undocumented

Undocumented

_responses = (source)

Undocumented