Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions tests/Assistants/Assistants.VectorStoresTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.ClientModel.TestFramework;
using Microsoft.ClientModel.TestFramework;
using NUnit.Framework;
using OpenAI.Files;
using OpenAI.Tests.Utility;
Expand Down Expand Up @@ -27,15 +27,15 @@ public class VectorStoresTests : OpenAIRecordedTestBase

private static readonly DateTimeOffset s_2024 = new(2024, 1, 1, 0, 0, 0, TimeSpan.Zero);

private VectorStoreClient GetTestClient() => GetProxiedOpenAIClient<VectorStoreClient>(TestScenario.VectorStores);
public enum ChunkingStrategyKind { Auto, Static }

public VectorStoresTests(bool isAsync)
: base(isAsync)
{
TestTimeoutInSeconds = 45;
}

[Test]
[RecordedTest]
public async Task CanCreateGetAndDeleteVectorStores()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -105,7 +105,7 @@ public async Task CanCreateGetAndDeleteVectorStores()
});
}

[Test]
[RecordedTest]
public async Task CanEnumerateVectorStores()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -149,7 +149,7 @@ public async Task CanEnumerateVectorStores()
Assert.That(lastIdSeen, Is.EqualTo(0));
}

[Test]
[RecordedTest]
public async Task CanAssociateFiles()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -194,7 +194,7 @@ public async Task CanAssociateFiles()
Assert.That(count, Is.EqualTo(2));
}

[Test]
[RecordedTest]
public async Task Pagination_CanRehydrateVectorStoreFileCollection()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -273,7 +273,7 @@ public async Task Pagination_CanRehydrateVectorStoreFileCollection()
Assert.That(pageCount, Is.EqualTo(2));
}

[Test]
[RecordedTest]
public async Task CanPaginateGetVectorStoreFilesInBatch()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -350,7 +350,7 @@ public async Task CanPaginateGetVectorStoreFilesInBatch()
Assert.That(itemsInPages, Is.EqualTo(10));
}

[Test]
[RecordedTest]
public async Task CanTestGetVectorStoreFilesInBatchCollectionOptions()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -453,7 +453,7 @@ public async Task CanTestGetVectorStoreFilesInBatchCollectionOptions()
}
}

[Test]
[RecordedTest]
public async Task CanRehydrateGetVectorStoreFilesInBatchPagination()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -527,7 +527,7 @@ private static IEnumerable<VectorStoreFile> GetVectorStoreFilesFromPage(ClientRe
return els.Select(el => ModelReaderWriter.Read<VectorStoreFile>(BinaryData.FromString(el.GetRawText())));
}

[Test]
[RecordedTest]
public async Task CanUseBatchIngestion()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -565,9 +565,7 @@ public async Task CanUseBatchIngestion()
}
}

public enum ChunkingStrategyKind { Auto, Static }

[Test]
[RecordedTest]
[TestCase(ChunkingStrategyKind.Auto)]
[TestCase(ChunkingStrategyKind.Static)]
public async Task CanApplyChunkingStrategy(ChunkingStrategyKind strategyKind)
Expand Down Expand Up @@ -624,7 +622,7 @@ public async Task CanApplyChunkingStrategy(ChunkingStrategyKind strategyKind)
}
}

[Test]
[RecordedTest]
public async Task CanGetVectorStores()
{
VectorStoreClient client = GetTestClient();
Expand Down Expand Up @@ -768,6 +766,8 @@ private void Validate<T>(T target)
throw new NotImplementedException($"{nameof(Validate)} helper not implemented for: {typeof(T)}");
}
}

private VectorStoreClient GetTestClient() => GetProxiedOpenAIClient<VectorStoreClient>(TestScenario.VectorStores);
}

#pragma warning restore OPENAI001
38 changes: 19 additions & 19 deletions tests/Assistants/AssistantsTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.ClientModel.TestFramework;
using Microsoft.ClientModel.TestFramework;
using NUnit.Framework;
using NUnit.Framework.Internal;
using OpenAI.Assistants;
Expand Down Expand Up @@ -84,7 +84,7 @@ protected void Cleanup()
_vectorStoreIdsToDelete.Clear();
}

[Test]
[RecordedTest]
public async Task BasicAssistantOperationsWork()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -139,7 +139,7 @@ public async Task BasicAssistantOperationsWork()
Assert.That(listedAssistant.Metadata.TryGetValue(s_cleanupMetadataKey, out string newMetadataValue) && newMetadataValue == "goodbye!");
}

[Test]
[RecordedTest]
public async Task BasicThreadOperationsWork()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -174,7 +174,7 @@ public async Task BasicThreadOperationsWork()
Assert.That(thread.Metadata.TryGetValue("threadMetadata", out threadMetadataValue) && threadMetadataValue == "newThreadMetadataValue");
}

[Test]
[RecordedTest]
public async Task BasicMessageOperationsWork()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -222,7 +222,7 @@ public async Task BasicMessageOperationsWork()
Assert.That(messages[0].Metadata.TryGetValue("messageMetadata", out metadataValue) && metadataValue == "newValue");
}

[Test]
[RecordedTest]
public async Task ThreadWithInitialMessagesWorks()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -260,7 +260,7 @@ public async Task ThreadWithInitialMessagesWorks()
Assert.That(messages[1].Content[1].ImageUri.AbsoluteUri, Is.EqualTo("https://test.openai.com/image.png"));
}

[Test]
[RecordedTest]
public async Task ThreadWithImageDetailWorks()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -295,7 +295,7 @@ public async Task ThreadWithImageDetailWorks()
Assert.That(messages[0].Content[1].ImageUri.AbsoluteUri, Is.EqualTo("https://test.openai.com/image.png"));
}

[Test]
[RecordedTest]
public async Task BasicRunOperationsWork()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -342,7 +342,7 @@ public async Task BasicRunOperationsWork()
Assert.That(messages[1].Id, Is.EqualTo(message.Id));
}

[Test]
[RecordedTest]
public async Task BasicRunStepFunctionalityWorks()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -429,7 +429,7 @@ public async Task BasicRunStepFunctionalityWorks()
});
}

[Test]
[RecordedTest]
public async Task SettingResponseFormatWorks()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -458,7 +458,7 @@ public async Task SettingResponseFormatWorks()
Assert.That(run.ResponseFormat == AssistantResponseFormat.CreateJsonObjectFormat());
}

[Test]
[RecordedTest]
public async Task FunctionToolsWork()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -537,7 +537,7 @@ public async Task FunctionToolsWork()
Assert.That(messages[0].Content[0].Text.ToLowerInvariant(), Does.Contain("tacos"));
}

[Test]
[RecordedTest]
public async Task StreamingRunWorks()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -646,7 +646,7 @@ public async Task StreamingToolCall()
} while (run?.Status.IsTerminal == false);
}

[Test]
[RecordedTest]
public async Task FileSearchWorks()
{
// First, we need to upload a simple test file.
Expand Down Expand Up @@ -847,7 +847,7 @@ This file describes the favorite foods of several people.
});
}

[Test]
[RecordedTest]
public async Task FileSearchStreamingWorks()
{
const string fileContent = """
Expand Down Expand Up @@ -942,7 +942,7 @@ public async Task FileSearchStreamingWorks()
Assert.That(message, Does.Contain("cake"));
}

[Test]
[RecordedTest]
public async Task Pagination_CanEnumerateAssistantsAsync()
{
const int TestAssistantCount = 10;
Expand Down Expand Up @@ -985,7 +985,7 @@ public async Task Pagination_CanEnumerateAssistantsAsync()
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
}

[Test]
[RecordedTest]
public async Task Pagination_CanPageThroughAssistantCollection()
{
const int TestAssistantCount = 10;
Expand Down Expand Up @@ -1050,7 +1050,7 @@ private static IEnumerable<Assistant> GetAssistantsFromPage(ClientResult page)
return els.Select(el => ModelReaderWriter.Read<Assistant>(BinaryData.FromString(el.GetRawText())));
}

[Test]
[RecordedTest]
public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytes()
{
const int TestAssistantCount = 10;
Expand Down Expand Up @@ -1122,7 +1122,7 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytes()
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[Test]
[RecordedTest]
public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
{
const int TestAssistantCount = 10;
Expand Down Expand Up @@ -1204,7 +1204,7 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[Test]
[RecordedTest]
public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes()
{
AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -1293,7 +1293,7 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes()
Assert.That(rehydratedRunSteps, Is.EqualTo(runSteps).AsCollection);
}

[Test]
[RecordedTest]
public async Task MessagesWithRoles()
{
AssistantClient client = GetTestClient();
Expand Down
6 changes: 3 additions & 3 deletions tests/Audio/GenerateSpeechTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.ClientModel.TestFramework;
using Microsoft.ClientModel.TestFramework;
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
Expand All @@ -16,7 +16,7 @@ public GenerateSpeechTests(bool isAsync) : base(isAsync)
{
}

[Test]
[RecordedTest]
public async Task BasicTextToSpeechWorks()
{
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_TTS);
Expand All @@ -27,7 +27,7 @@ public async Task BasicTextToSpeechWorks()
await ValidateGeneratedAudio(audio, "hello");
}

[Test]
[RecordedTest]
[TestCase(null)]
[TestCase("mp3")]
[TestCase("opus")]
Expand Down
18 changes: 9 additions & 9 deletions tests/Audio/TranscriptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.ClientModel.TestFramework;
using Microsoft.ClientModel.TestFramework;
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
Expand Down Expand Up @@ -26,7 +26,7 @@ public enum AudioSourceKind
UsingFilePath,
}

[Test]
[RecordedTest]
[TestCase(AudioSourceKind.UsingStream)]
[TestCase(AudioSourceKind.UsingFilePath)]
public async Task TranscriptionWorks(AudioSourceKind audioSourceKind)
Expand All @@ -51,7 +51,7 @@ public async Task TranscriptionWorks(AudioSourceKind audioSourceKind)
Assert.That(transcription.Text.ToLowerInvariant(), Contains.Substring("hello"));
}

[Test]
[RecordedTest]
[TestCase(AudioTimestampGranularities.Default)]
[TestCase(AudioTimestampGranularities.Word)]
[TestCase(AudioTimestampGranularities.Segment)]
Expand Down Expand Up @@ -122,7 +122,7 @@ public async Task TimestampsWork(AudioTimestampGranularities granularityFlags)
}
}

[Test]
[RecordedTest]
[TestCase("text")]
[TestCase("json")]
[TestCase("verbose_json")]
Expand Down Expand Up @@ -185,7 +185,7 @@ public async Task TranscriptionFormatsWork(string responseFormat)
}
}

[Test]
[RecordedTest]
public async Task IncludesWork()
{
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_Gpt_4o_Mini_Transcribe);
Expand All @@ -203,7 +203,7 @@ public async Task IncludesWork()
Assert.That(transcription.TranscriptionTokenLogProbabilities[0].Utf8Bytes.ToArray(), Is.Not.Null.And.Not.Empty);
}

[Test]
[RecordedTest]
public async Task StreamingIncludesWork()
{
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_Gpt_4o_Mini_Transcribe);
Expand Down Expand Up @@ -237,7 +237,7 @@ in client.TranscribeAudioStreamingAsync(
Assert.That(streamedDeltaLogProbs, Has.Count.GreaterThan(0));
}

[Test]
[RecordedTest]
public async Task BadTranscriptionRequest()
{
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_Whisper);
Expand All @@ -264,7 +264,7 @@ public async Task BadTranscriptionRequest()
Assert.That(caughtException.Message?.ToLower(), Contains.Substring("invalid language"));
}

[Test]
[RecordedTest]
[TestCase(AudioSourceKind.UsingStream)]
[TestCase(AudioSourceKind.UsingFilePath)]
public async Task StreamingTranscriptionWorks(AudioSourceKind audioSourceKind)
Expand Down Expand Up @@ -309,7 +309,7 @@ public async Task StreamingTranscriptionWorks(AudioSourceKind audioSourceKind)
inputStream?.Dispose();
}

[Test]
[RecordedTest]
[TestCase(AudioSourceKind.UsingStream)]
[TestCase(AudioSourceKind.UsingFilePath)]
public void StreamingTranscriptionThrowsForWhisperModel(AudioSourceKind audioSourceKind)
Expand Down
Loading