Skip to main content

Module test_utils

Module test_utils 

Source
Available on crate feature test-utils only.
Expand description

Test utilities for deterministic completion-model tests.

Structs§

AppendFailingMemory
Memory backend that loads empty history and always fails on append.
BarrierMockToolIndex
A vector index that waits at a barrier before returning one tool ID.
CapturedHttpRequest
Request data captured by RecordingHttpClient.
CountingMemory
Memory backend that records load and append calls while delegating storage to InMemoryConversationMemory.
FailingMemory
Memory backend that always fails on load and no-ops append and clear.
Foo
Document fixture returned by MockVectorStoreIndex in pipeline tests.
MockAddTool
A mock tool that adds x and y.
MockBarrierTool
A mock tool that waits at a barrier before returning "done".
MockCompletionModel
A cloneable scripted CompletionModel for tests.
MockControlledTool
A mock tool that notifies when started and waits for an explicit finish signal.
MockEmbeddingModel
A deterministic EmbeddingModel that returns a fixed vector for each input document.
MockExampleTool
A mock tool named example_tool that returns "Example answer".
MockImageGeneratorTool
A mock tool named generate_test_image that returns a 1x1 red PNG image payload.
MockImageOutputTool
A mock tool that returns image JSON as a string.
MockModelLister
A ModelLister that returns a preconfigured list of models.
MockMultiTextDocument
A test document that contributes multiple text fragments to an embedding request.
MockObjectOutputTool
A mock tool that returns a JSON object.
MockOperationArgs
Arguments for arithmetic mock tools.
MockPromptModel
A prompt model that echoes user text with a stable prefix.
MockResponse
Raw mock response used by completion and streaming test utilities.
MockStreamingClient
A mock HTTP client that returns pre-built SSE bytes from send_streaming.
MockStringOutputTool
A mock tool that returns a multiline string.
MockSubtractTool
A mock tool that subtracts y from x.
MockTextDocument
A test document that contributes one text fragment to an embedding request.
MockToolError
Shared error type for mock tools.
MockToolIndex
A vector index that returns a predefined list of tool IDs from top_n_ids.
MockTurn
A scripted non-streaming mock completion turn.
MockVectorStoreIndex
A vector index that always returns one JSON document containing {"foo":"bar"}.
RecordingHttpClient
An HttpClientExt implementation that records unary requests and returns a fixed response.
SequencedStreamingHttpClient
An HttpClientExt implementation that returns one scripted stream of byte chunks from send_streaming.

Enums§

MockError
Scripted error returned by MockCompletionModel.
MockHttpResponse
Response scripted for RecordingHttpClient.
MockStreamEvent
Scripted streaming event yielded by MockCompletionModel.

Functions§

mock_math_toolset
Create a ToolSet containing MockAddTool and MockSubtractTool.