Skip to content

Commit bef01b5

Browse files
authored
Change the Test attribute of recorded tests to RecordedTest (#773)
* Changed the `Test` attribute of recorded tests to `RecordedTest` * Fixed the name of the `ChatStoreToolTests` class by renaming it to `ChatStoreTests` * Re-recorded the image variation tests because they were not currently passing. * Misc. refactoring.
1 parent 0a6582e commit bef01b5

File tree

77 files changed

+2053
-1403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+2053
-1403
lines changed

tests/Assistants/Assistants.VectorStoresTests.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.ClientModel.TestFramework;
1+
using Microsoft.ClientModel.TestFramework;
22
using NUnit.Framework;
33
using OpenAI.Files;
44
using OpenAI.Tests.Utility;
@@ -27,15 +27,15 @@ public class VectorStoresTests : OpenAIRecordedTestBase
2727

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

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

3232
public VectorStoresTests(bool isAsync)
3333
: base(isAsync)
3434
{
3535
TestTimeoutInSeconds = 45;
3636
}
3737

38-
[Test]
38+
[RecordedTest]
3939
public async Task CanCreateGetAndDeleteVectorStores()
4040
{
4141
VectorStoreClient client = GetTestClient();
@@ -105,7 +105,7 @@ public async Task CanCreateGetAndDeleteVectorStores()
105105
});
106106
}
107107

108-
[Test]
108+
[RecordedTest]
109109
public async Task CanEnumerateVectorStores()
110110
{
111111
VectorStoreClient client = GetTestClient();
@@ -149,7 +149,7 @@ public async Task CanEnumerateVectorStores()
149149
Assert.That(lastIdSeen, Is.EqualTo(0));
150150
}
151151

152-
[Test]
152+
[RecordedTest]
153153
public async Task CanAssociateFiles()
154154
{
155155
VectorStoreClient client = GetTestClient();
@@ -194,7 +194,7 @@ public async Task CanAssociateFiles()
194194
Assert.That(count, Is.EqualTo(2));
195195
}
196196

197-
[Test]
197+
[RecordedTest]
198198
public async Task Pagination_CanRehydrateVectorStoreFileCollection()
199199
{
200200
VectorStoreClient client = GetTestClient();
@@ -273,7 +273,7 @@ public async Task Pagination_CanRehydrateVectorStoreFileCollection()
273273
Assert.That(pageCount, Is.EqualTo(2));
274274
}
275275

276-
[Test]
276+
[RecordedTest]
277277
public async Task CanPaginateGetVectorStoreFilesInBatch()
278278
{
279279
VectorStoreClient client = GetTestClient();
@@ -350,7 +350,7 @@ public async Task CanPaginateGetVectorStoreFilesInBatch()
350350
Assert.That(itemsInPages, Is.EqualTo(10));
351351
}
352352

353-
[Test]
353+
[RecordedTest]
354354
public async Task CanTestGetVectorStoreFilesInBatchCollectionOptions()
355355
{
356356
VectorStoreClient client = GetTestClient();
@@ -453,7 +453,7 @@ public async Task CanTestGetVectorStoreFilesInBatchCollectionOptions()
453453
}
454454
}
455455

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

530-
[Test]
530+
[RecordedTest]
531531
public async Task CanUseBatchIngestion()
532532
{
533533
VectorStoreClient client = GetTestClient();
@@ -565,9 +565,7 @@ public async Task CanUseBatchIngestion()
565565
}
566566
}
567567

568-
public enum ChunkingStrategyKind { Auto, Static }
569-
570-
[Test]
568+
[RecordedTest]
571569
[TestCase(ChunkingStrategyKind.Auto)]
572570
[TestCase(ChunkingStrategyKind.Static)]
573571
public async Task CanApplyChunkingStrategy(ChunkingStrategyKind strategyKind)
@@ -624,7 +622,7 @@ public async Task CanApplyChunkingStrategy(ChunkingStrategyKind strategyKind)
624622
}
625623
}
626624

627-
[Test]
625+
[RecordedTest]
628626
public async Task CanGetVectorStores()
629627
{
630628
VectorStoreClient client = GetTestClient();
@@ -768,6 +766,8 @@ private void Validate<T>(T target)
768766
throw new NotImplementedException($"{nameof(Validate)} helper not implemented for: {typeof(T)}");
769767
}
770768
}
769+
770+
private VectorStoreClient GetTestClient() => GetProxiedOpenAIClient<VectorStoreClient>(TestScenario.VectorStores);
771771
}
772772

773773
#pragma warning restore OPENAI001

tests/Assistants/AssistantsTests.cs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.ClientModel.TestFramework;
1+
using Microsoft.ClientModel.TestFramework;
22
using NUnit.Framework;
33
using NUnit.Framework.Internal;
44
using OpenAI.Assistants;
@@ -84,7 +84,7 @@ protected void Cleanup()
8484
_vectorStoreIdsToDelete.Clear();
8585
}
8686

87-
[Test]
87+
[RecordedTest]
8888
public async Task BasicAssistantOperationsWork()
8989
{
9090
AssistantClient client = GetTestClient();
@@ -139,7 +139,7 @@ public async Task BasicAssistantOperationsWork()
139139
Assert.That(listedAssistant.Metadata.TryGetValue(s_cleanupMetadataKey, out string newMetadataValue) && newMetadataValue == "goodbye!");
140140
}
141141

142-
[Test]
142+
[RecordedTest]
143143
public async Task BasicThreadOperationsWork()
144144
{
145145
AssistantClient client = GetTestClient();
@@ -174,7 +174,7 @@ public async Task BasicThreadOperationsWork()
174174
Assert.That(thread.Metadata.TryGetValue("threadMetadata", out threadMetadataValue) && threadMetadataValue == "newThreadMetadataValue");
175175
}
176176

177-
[Test]
177+
[RecordedTest]
178178
public async Task BasicMessageOperationsWork()
179179
{
180180
AssistantClient client = GetTestClient();
@@ -222,7 +222,7 @@ public async Task BasicMessageOperationsWork()
222222
Assert.That(messages[0].Metadata.TryGetValue("messageMetadata", out metadataValue) && metadataValue == "newValue");
223223
}
224224

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

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

298-
[Test]
298+
[RecordedTest]
299299
public async Task BasicRunOperationsWork()
300300
{
301301
AssistantClient client = GetTestClient();
@@ -342,7 +342,7 @@ public async Task BasicRunOperationsWork()
342342
Assert.That(messages[1].Id, Is.EqualTo(message.Id));
343343
}
344344

345-
[Test]
345+
[RecordedTest]
346346
public async Task BasicRunStepFunctionalityWorks()
347347
{
348348
AssistantClient client = GetTestClient();
@@ -429,7 +429,7 @@ public async Task BasicRunStepFunctionalityWorks()
429429
});
430430
}
431431

432-
[Test]
432+
[RecordedTest]
433433
public async Task SettingResponseFormatWorks()
434434
{
435435
AssistantClient client = GetTestClient();
@@ -458,7 +458,7 @@ public async Task SettingResponseFormatWorks()
458458
Assert.That(run.ResponseFormat == AssistantResponseFormat.CreateJsonObjectFormat());
459459
}
460460

461-
[Test]
461+
[RecordedTest]
462462
public async Task FunctionToolsWork()
463463
{
464464
AssistantClient client = GetTestClient();
@@ -537,7 +537,7 @@ public async Task FunctionToolsWork()
537537
Assert.That(messages[0].Content[0].Text.ToLowerInvariant(), Does.Contain("tacos"));
538538
}
539539

540-
[Test]
540+
[RecordedTest]
541541
public async Task StreamingRunWorks()
542542
{
543543
AssistantClient client = GetTestClient();
@@ -646,7 +646,7 @@ public async Task StreamingToolCall()
646646
} while (run?.Status.IsTerminal == false);
647647
}
648648

649-
[Test]
649+
[RecordedTest]
650650
public async Task FileSearchWorks()
651651
{
652652
// First, we need to upload a simple test file.
@@ -847,7 +847,7 @@ This file describes the favorite foods of several people.
847847
});
848848
}
849849

850-
[Test]
850+
[RecordedTest]
851851
public async Task FileSearchStreamingWorks()
852852
{
853853
const string fileContent = """
@@ -942,7 +942,7 @@ public async Task FileSearchStreamingWorks()
942942
Assert.That(message, Does.Contain("cake"));
943943
}
944944

945-
[Test]
945+
[RecordedTest]
946946
public async Task Pagination_CanEnumerateAssistantsAsync()
947947
{
948948
const int TestAssistantCount = 10;
@@ -985,7 +985,7 @@ public async Task Pagination_CanEnumerateAssistantsAsync()
985985
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
986986
}
987987

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

1053-
[Test]
1053+
[RecordedTest]
10541054
public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytes()
10551055
{
10561056
const int TestAssistantCount = 10;
@@ -1122,7 +1122,7 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytes()
11221122
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
11231123
}
11241124

1125-
[Test]
1125+
[RecordedTest]
11261126
public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
11271127
{
11281128
const int TestAssistantCount = 10;
@@ -1204,7 +1204,7 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
12041204
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
12051205
}
12061206

1207-
[Test]
1207+
[RecordedTest]
12081208
public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes()
12091209
{
12101210
AssistantClient client = GetTestClient();
@@ -1293,7 +1293,7 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytes()
12931293
Assert.That(rehydratedRunSteps, Is.EqualTo(runSteps).AsCollection);
12941294
}
12951295

1296-
[Test]
1296+
[RecordedTest]
12971297
public async Task MessagesWithRoles()
12981298
{
12991299
AssistantClient client = GetTestClient();

tests/Audio/GenerateSpeechTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.ClientModel.TestFramework;
1+
using Microsoft.ClientModel.TestFramework;
22
using NUnit.Framework;
33
using OpenAI.Audio;
44
using OpenAI.Tests.Utility;
@@ -16,7 +16,7 @@ public GenerateSpeechTests(bool isAsync) : base(isAsync)
1616
{
1717
}
1818

19-
[Test]
19+
[RecordedTest]
2020
public async Task BasicTextToSpeechWorks()
2121
{
2222
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_TTS);
@@ -27,7 +27,7 @@ public async Task BasicTextToSpeechWorks()
2727
await ValidateGeneratedAudio(audio, "hello");
2828
}
2929

30-
[Test]
30+
[RecordedTest]
3131
[TestCase(null)]
3232
[TestCase("mp3")]
3333
[TestCase("opus")]

tests/Audio/TranscriptionTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.ClientModel.TestFramework;
1+
using Microsoft.ClientModel.TestFramework;
22
using NUnit.Framework;
33
using OpenAI.Audio;
44
using OpenAI.Tests.Utility;
@@ -26,7 +26,7 @@ public enum AudioSourceKind
2626
UsingFilePath,
2727
}
2828

29-
[Test]
29+
[RecordedTest]
3030
[TestCase(AudioSourceKind.UsingStream)]
3131
[TestCase(AudioSourceKind.UsingFilePath)]
3232
public async Task TranscriptionWorks(AudioSourceKind audioSourceKind)
@@ -51,7 +51,7 @@ public async Task TranscriptionWorks(AudioSourceKind audioSourceKind)
5151
Assert.That(transcription.Text.ToLowerInvariant(), Contains.Substring("hello"));
5252
}
5353

54-
[Test]
54+
[RecordedTest]
5555
[TestCase(AudioTimestampGranularities.Default)]
5656
[TestCase(AudioTimestampGranularities.Word)]
5757
[TestCase(AudioTimestampGranularities.Segment)]
@@ -122,7 +122,7 @@ public async Task TimestampsWork(AudioTimestampGranularities granularityFlags)
122122
}
123123
}
124124

125-
[Test]
125+
[RecordedTest]
126126
[TestCase("text")]
127127
[TestCase("json")]
128128
[TestCase("verbose_json")]
@@ -185,7 +185,7 @@ public async Task TranscriptionFormatsWork(string responseFormat)
185185
}
186186
}
187187

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

206-
[Test]
206+
[RecordedTest]
207207
public async Task StreamingIncludesWork()
208208
{
209209
AudioClient client = GetProxiedOpenAIClient<AudioClient>(TestScenario.Audio_Gpt_4o_Mini_Transcribe);
@@ -237,7 +237,7 @@ in client.TranscribeAudioStreamingAsync(
237237
Assert.That(streamedDeltaLogProbs, Has.Count.GreaterThan(0));
238238
}
239239

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

267-
[Test]
267+
[RecordedTest]
268268
[TestCase(AudioSourceKind.UsingStream)]
269269
[TestCase(AudioSourceKind.UsingFilePath)]
270270
public async Task StreamingTranscriptionWorks(AudioSourceKind audioSourceKind)
@@ -309,7 +309,7 @@ public async Task StreamingTranscriptionWorks(AudioSourceKind audioSourceKind)
309309
inputStream?.Dispose();
310310
}
311311

312-
[Test]
312+
[RecordedTest]
313313
[TestCase(AudioSourceKind.UsingStream)]
314314
[TestCase(AudioSourceKind.UsingFilePath)]
315315
public void StreamingTranscriptionThrowsForWhisperModel(AudioSourceKind audioSourceKind)

0 commit comments

Comments
 (0)