Vancouver.ToolTest (Vancouver v0.3.0)

View Source

Conveniences for testing Vancouver tools.

Summary

Functions

Asserts that the response was successful, and that audio content was returned.

Creates a valid request body for a tool call request.

Asserts that the response was an error, and returns the error text.

Asserts that the response was successful, and that image content was returned.

Asserts that the response was successful, and that JSON content was returned.

Asserts that the response was successful, and that text content was returned.

Functions

audio_response(conn)

@spec audio_response(Plug.Conn.t()) :: map()

Asserts that the response was successful, and that audio content was returned.

Examples

content = audio_response(conn)
assert content["data"] == "base64-audio-data"
assert content["mimeType"] == "audio/wav"

build_call_request(tool_name, arguments)

@spec build_call_request(String.t(), map()) :: map()

Creates a valid request body for a tool call request.

Examples

body = build_call_request("calculate_sum", %{"a" => 1, "b" => 2})

error_response(conn)

@spec error_response(Plug.Conn.t()) :: String.t()

Asserts that the response was an error, and returns the error text.

Examples

assert error_response(conn) == "An error occurred"

image_response(conn)

@spec image_response(Plug.Conn.t()) :: map()

Asserts that the response was successful, and that image content was returned.

Examples

content = image_response(conn)
assert content["data"] == "base64-image-data"
assert content["mimeType"] == "image/png"

json_response(conn)

@spec json_response(Plug.Conn.t()) :: term()

Asserts that the response was successful, and that JSON content was returned.

Examples

assert json_response(conn) == %{"key" => "value"}

text_response(conn)

@spec text_response(Plug.Conn.t()) :: String.t()

Asserts that the response was successful, and that text content was returned.

Examples

assert text_response(conn) == "Hello, world!"