mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-17 14:18:00 +00:00
Added mailboxes as local data sources (#1022)
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
This commit is contained in:
1 parent
93be539e50
commit
c4400c0ff6
343 files changed
+26051
-3122
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Text.Json;
|
||||
|
||||
using AIStudio.Tools.ToolCallingSystem;
|
||||
@@ -11,7 +12,8 @@ namespace AIStudio.Tests.Tools.ToolCalling;
|
||||
/// The web search tests cover strings, positive integers, and a single choice through the
|
||||
/// arguments of that tool. What is left are a required string which arrives empty and a list of
|
||||
/// choices, which the web search does not have: a data source a model names has to be one the
|
||||
/// tool offered, and the refusal has to say which ones those are.
|
||||
/// tool offered, and the refusal has to say which ones those are. The mail tools add booleans,
|
||||
/// dates, and single lines which go into a search.
|
||||
/// </remarks>
|
||||
[TestFixture]
|
||||
public sealed class ToolArgumentReaderTests
|
||||
@@ -88,8 +90,76 @@ public sealed class ToolArgumentReaderTests
|
||||
Assert.That(message, Does.Contain($"but one was \"{id}\"."), "Data sources are named by their GUIDs; a shortened one would leave the model guessing.");
|
||||
}
|
||||
|
||||
[TestCase("true", true)]
|
||||
[TestCase("false", false)]
|
||||
public void ABooleanComesThroughAsItIs(string value, bool expected)
|
||||
{
|
||||
Assert.That(ToolArgumentReader.ReadOptionalBoolean(Arguments($$"""{"is_unread":{{value}}}"""), "is_unread", WHEN_LEFT_OUT), Is.EqualTo(expected));
|
||||
}
|
||||
|
||||
[TestCase("\"true\"")]
|
||||
[TestCase("1")]
|
||||
[TestCase("\"yes\"")]
|
||||
public void AnythingButABooleanIsRefused(string value)
|
||||
{
|
||||
var message = Refusal(() => ToolArgumentReader.ReadOptionalBoolean(Arguments($$"""{"is_unread":{{value}}}"""), "is_unread", WHEN_LEFT_OUT));
|
||||
|
||||
Assert.That(message, Does.Contain("'is_unread' must be true or false").And.Contain($"Leave it out {WHEN_LEFT_OUT}."));
|
||||
}
|
||||
|
||||
[TestCase("2026-09-01", "2026-09-01T00:00:00+02:00")]
|
||||
[TestCase("2026-09-01T14:30", "2026-09-01T14:30:00+02:00")]
|
||||
[TestCase("2026-09-01T14:30:15", "2026-09-01T14:30:15+02:00")]
|
||||
[TestCase("2026-09-01T14:30:00+05:00", "2026-09-01T14:30:00+05:00")]
|
||||
[TestCase("2026-09-01T14:30:00Z", "2026-09-01T14:30:00+00:00")]
|
||||
public void ADateWithoutAnOffsetIsReadInTheTimeZoneOfTheUser(string value, string expected)
|
||||
{
|
||||
var pointInTime = ToolArgumentReader.ReadOptionalDateTime(Arguments($$"""{"after":"{{value}}"}"""), "after", UserTimeZone(), WHEN_LEFT_OUT);
|
||||
var expectedPointInTime = DateTimeOffset.Parse(expected, CultureInfo.InvariantCulture);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(pointInTime, Is.EqualTo(expectedPointInTime));
|
||||
Assert.That(pointInTime?.Offset, Is.EqualTo(expectedPointInTime.Offset), "The same instant with another offset would hide which zone was assumed.");
|
||||
});
|
||||
}
|
||||
|
||||
[TestCase("\"yesterday\"")]
|
||||
[TestCase("\"01.09.2026\"")]
|
||||
[TestCase("\"2026-9-1\"")]
|
||||
[TestCase("\"2026-02-30\"")]
|
||||
[TestCase("20260901")]
|
||||
public void ADateInAnotherFormIsRefused(string value)
|
||||
{
|
||||
var message = Refusal(() => ToolArgumentReader.ReadOptionalDateTime(Arguments($$"""{"after":{{value}}}"""), "after", UserTimeZone(), WHEN_LEFT_OUT));
|
||||
|
||||
Assert.That(message, Does.Contain("'after' must be a date such as 2026-09-01").And.Contain($"Leave it out {WHEN_LEFT_OUT}."));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ALineComesThroughTrimmed()
|
||||
{
|
||||
Assert.That(ToolArgumentReader.ReadOptionalLine(Arguments("""{"from":" alice@example.org "}"""), "from", 20, WHEN_LEFT_OUT), Is.EqualTo("alice@example.org"));
|
||||
}
|
||||
|
||||
[TestCase("\"\"", "must not be empty")]
|
||||
[TestCase("\" \"", "must not be empty")]
|
||||
[TestCase("\"alice@example.org and bob@example.org\"", "must be at most 20 characters long, but had 37")]
|
||||
[TestCase("\"alice\\nbob\"", "must not contain control characters")]
|
||||
public void AnEmptyOrLongOrBrokenLineIsRefused(string value, string expectedReason)
|
||||
{
|
||||
var message = Refusal(() => ToolArgumentReader.ReadOptionalLine(Arguments($$"""{"from":{{value}}}"""), "from", 20, WHEN_LEFT_OUT));
|
||||
|
||||
Assert.That(message, Does.Contain($"'from' {expectedReason}").And.Contain($"Leave it out {WHEN_LEFT_OUT}."), "In a search, an empty line would match everything. Whatever was wrong, leaving the argument out is always a way out.");
|
||||
}
|
||||
|
||||
private static JsonElement Arguments(string json) => JsonSerializer.Deserialize<JsonElement>(json);
|
||||
|
||||
/// <summary>
|
||||
/// A time zone two hours ahead of UTC, all year round, so that no test depends on the computer or on daylight saving time.
|
||||
/// </summary>
|
||||
private static TimeZoneInfo UserTimeZone() => TimeZoneInfo.CreateCustomTimeZone("AI Studio test zone", TimeSpan.FromHours(2), "AI Studio test zone", "AI Studio test zone");
|
||||
|
||||
/// <summary>
|
||||
/// Runs a reader which has to refuse its argument and returns what it said.
|
||||
/// </summary>
|
||||
|
||||
Reference in new issue
Block a user