Skip to content

Commit b52c9e3

Browse files
committed
first round of recordings
1 parent 0a6b648 commit b52c9e3

File tree

62 files changed

+10447
-87
lines changed

Some content is hidden

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

62 files changed

+10447
-87
lines changed

src/Custom/VectorStores/CreateVectorStoreOperation.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@ namespace OpenAI.VectorStores;
1212
[Experimental("OPENAI001")]
1313
public partial class CreateVectorStoreOperation : OperationResult
1414
{
15+
protected CreateVectorStoreOperation() : base(default!)
16+
{
17+
_parentClient = default!;
18+
_endpoint = default!;
19+
_vectorStoreId = default!;
20+
}
21+
1522
internal CreateVectorStoreOperation(
1623
VectorStoreClient parentClient,
1724
Uri endpoint,

tests/Assistants/Assistants.VectorStoresTests.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.ClientModel.TestFramework;
2+
using Microsoft.Extensions.Logging;
23
using NUnit.Framework;
34
using OpenAI.Files;
45
using OpenAI.VectorStores;
@@ -7,6 +8,7 @@
78
using System.ClientModel.Primitives;
89
using System.Collections.Generic;
910
using System.Linq;
11+
using System.Runtime.CompilerServices;
1012
using System.Text.Json;
1113
using System.Threading;
1214
using System.Threading.Tasks;
@@ -18,7 +20,7 @@ namespace OpenAI.Tests.VectorStores;
1820

1921
[ClientTestFixture]
2022
[Category("Assistants")]
21-
public class VectorStoresTests : SyncAsyncTestBase
23+
public class VectorStoresTests : RecordedTestBase<OpenAITestEnvironment>
2224
{
2325
private readonly List<CreateBatchFileJobOperation> _jobsToCancel = [];
2426
private readonly List<VectorStoreFileAssociation> _associationsToRemove = [];
@@ -27,10 +29,10 @@ public class VectorStoresTests : SyncAsyncTestBase
2729

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

30-
private static VectorStoreClient GetTestClient() => GetTestClient<VectorStoreClient>(TestScenario.VectorStores);
32+
private VectorStoreClient GetTestClient() => CreateProxyFromClient(GetTestClient<VectorStoreClient>(TestScenario.VectorStores), null);
3133

3234
public VectorStoresTests(bool isAsync)
33-
: base(isAsync)
35+
: base(isAsync, RecordedTestMode.Record)
3436
{
3537
}
3638

@@ -669,6 +671,10 @@ protected void Cleanup()
669671
/// <exception cref="NotImplementedException"> The provided instance type isn't supported. </exception>
670672
private void Validate<T>(T target)
671673
{
674+
if (target is IProxiedOperationResult result)
675+
{
676+
target = (T)result.Original;
677+
}
672678
if (target is CreateBatchFileJobOperation job)
673679
{
674680
Assert.That(job.BatchId, Is.Not.Null);

tests/OpenAI.Tests.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
</ItemGroup>
1616
<ItemGroup>
1717
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="8.0.0" />
18+
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.7" />
19+
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="9.0.7" />
1820
<PackageReference Include="NUnit" Version="3.13.2" />
1921
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2" />
2022
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
@@ -30,4 +32,11 @@
3032
<ItemGroup>
3133
<ProjectReference Include="..\..\azure-sdk-for-net\sdk\core\Microsoft.ClientModel.TestFramework\src\Microsoft.ClientModel.TestFramework.csproj" />
3234
</ItemGroup>
35+
36+
<ItemGroup>
37+
<AssemblyAttribute Include="System.Reflection.AssemblyMetadataAttribute">
38+
<_Parameter1>SourcePath</_Parameter1>
39+
<_Parameter2>$(MSBuildProjectDirectory)</_Parameter2>
40+
</AssemblyAttribute>
41+
</ItemGroup>
3342
</Project>

tests/Responses/ResponsesTests.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Microsoft.ClientModel.TestFramework;
2+
using Microsoft.Extensions.Options;
23
using Microsoft.VisualStudio.TestPlatform.ObjectModel;
34
using NUnit.Framework;
45
using OpenAI.Files;
@@ -22,9 +23,9 @@ namespace OpenAI.Tests.Responses;
2223
[TestFixture(false)]
2324
[Parallelizable(ParallelScope.Fixtures)]
2425
[Category("Responses")]
25-
public partial class ResponsesTests : SyncAsyncTestBase
26+
public partial class ResponsesTests : OpenAIRecordedTestBase
2627
{
27-
public ResponsesTests(bool isAsync) : base(isAsync)
28+
public ResponsesTests(bool isAsync) : base(isAsync, RecordedTestMode.Record)
2829
{
2930
}
3031

@@ -75,7 +76,8 @@ private void Validate<T>(T input) where T : class
7576
[Test]
7677
public async Task FileSearch()
7778
{
78-
OpenAIFileClient fileClient = GetTestClient<OpenAIFileClient>(TestScenario.Files);
79+
OpenAIFileClient fileClient = GetProxiedOpenAIClient<OpenAIFileClient>(TestScenario.Files);
80+
7981
OpenAIFile testFile = await fileClient.UploadFileAsync(
8082
BinaryData.FromString("""
8183
Travis's favorite food is pizza.
@@ -84,7 +86,8 @@ public async Task FileSearch()
8486
FileUploadPurpose.UserData);
8587
Validate(testFile);
8688

87-
VectorStoreClient vscClient = GetTestClient<VectorStoreClient>(TestScenario.VectorStores);
89+
VectorStoreClient vscClient = GetProxiedOpenAIClient<VectorStoreClient>(TestScenario.VectorStores);
90+
8891
CreateVectorStoreOperation createStoreOp = await vscClient.CreateVectorStoreAsync(
8992
waitUntilCompleted: true,
9093
new VectorStoreCreationOptions()
@@ -530,7 +533,7 @@ public async Task FileInputFromIdWorks()
530533
BinaryData.FromBytes(File.ReadAllBytes(filePath)),
531534
"test_favorite_foods.pdf",
532535
FileUploadPurpose.UserData);
533-
Validate(newFileToUse);
536+
Validate(newFileToUse);
534537

535538
ResponseItem messageItem = ResponseItem.CreateUserMessageItem(
536539
[
@@ -904,5 +907,5 @@ public async Task CanCancelBackgroundResponses()
904907
"""),
905908
false);
906909

907-
private static OpenAIResponseClient GetTestClient(string overrideModel = null) => GetTestClient<OpenAIResponseClient>(TestScenario.Responses, overrideModel);
910+
private OpenAIResponseClient GetTestClient(string overrideModel = null, OpenAIClientOptions options = null) => GetProxiedOpenAIClient<OpenAIResponseClient>(TestScenario.Responses, overrideModel, options);
908911
}

0 commit comments

Comments
 (0)