Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8bdad4e
ignore failing tests
m-redding Sep 5, 2025
e717cca
move to nunit 4 patterns
m-redding Aug 15, 2025
3416acf
upgrade nunit
m-redding Aug 15, 2025
632549a
first set of tests moved to ClientTestBase (auto sync/async)
m-redding Sep 8, 2025
30f13c7
next set to ClientTestBase
m-redding Sep 8, 2025
16509f5
Merge branch 'main' into addtestframeworktake2
m-redding Sep 8, 2025
a044e6e
last few test files
m-redding Sep 9, 2025
5088ce1
Merge branch 'openai:main' into addtestframeworktake2
m-redding Sep 9, 2025
a0b2c35
move to dev feed version
m-redding Sep 9, 2025
d56bcb8
Merge branch 'openai:main' into addtestframeworktake2
m-redding Sep 12, 2025
74beb44
Merge branch 'addtestframeworktake2' of https://github.com/m-redding/…
m-redding Sep 12, 2025
c4e8c20
add batch/chat tests
m-redding Sep 16, 2025
08cf150
update
m-redding Sep 16, 2025
4325136
Merge branch 'openai:main' into addtestframeworktake2
m-redding Sep 16, 2025
30ea2d0
add chat tests
m-redding Sep 16, 2025
849cbde
add audio tests
m-redding Sep 16, 2025
db74b03
containers, assistants, responses
m-redding Sep 16, 2025
82379a2
models and moderations
m-redding Sep 16, 2025
a95f905
remaining tests
m-redding Sep 17, 2025
cbcd651
be more flexible in test environment
m-redding Sep 17, 2025
ab821f7
changes for pipeline
m-redding Sep 17, 2025
127459c
feedback
m-redding Sep 18, 2025
7442234
bump test proxy and test framework versions
m-redding Sep 22, 2025
a777478
update recordings
m-redding Sep 25, 2025
1f1109c
more recordings updates
m-redding Sep 25, 2025
1f27832
update more recordings
m-redding Sep 26, 2025
d5c5bd0
Merge branch 'main' into addtestframeworktake2
m-redding Sep 26, 2025
565db7d
merge conflicts and new recordings
m-redding Sep 26, 2025
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
1 change: 1 addition & 0 deletions examples/Responses/Example02_SimpleResponseStreaming.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace OpenAI.Examples;

public partial class ResponseExamples
{
[Ignore("Test org cannot use streaming")]
[Test]
public void Example02_SimpleResponseStreaming()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace OpenAI.Examples;

public partial class ResponseExamples
{
[Ignore("Test org cannot use streaming")]
[Test]
public async Task Example02_SimpleResponseStreamingAsync()
{
Expand Down
280 changes: 101 additions & 179 deletions tests/Assistants/Assistants.VectorStoresTests.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/Assistants/AssistantsSmokeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void ResponseFormatEquality()
Assert.That((AssistantResponseFormat)null != AssistantResponseFormat.CreateTextFormat());
Assert.That(AssistantResponseFormat.CreateTextFormat() != null);
Assert.That(AssistantResponseFormat.CreateTextFormat(), Is.Not.EqualTo(null));
Assert.That(null, Is.Not.EqualTo(AssistantResponseFormat.CreateTextFormat()));
Assert.That(AssistantResponseFormat.CreateTextFormat(), Is.Not.Null);

AssistantResponseFormat jsonSchemaFormat = AssistantResponseFormat.CreateJsonSchemaFormat(
name: "test_schema",
Expand Down
65 changes: 24 additions & 41 deletions tests/Assistants/AssistantsTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Microsoft.ClientModel.TestFramework;

Check failure on line 1 in tests/Assistants/AssistantsTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Assistants;
using OpenAI.Files;
using OpenAI.Tests.Utility;
Expand Down Expand Up @@ -598,11 +599,10 @@
Assert.That(messages[0].Content[0].Text.ToLowerInvariant(), Does.Contain("tacos"));
}

[AsyncOnly]
[Test]
public async Task StreamingRunWorksAsync()
{
AssertAsyncOnly();

AssistantClient client = GetTestClient();
Assistant assistant = await client.CreateAssistantAsync("gpt-4o-mini");
Validate(assistant);
Expand Down Expand Up @@ -648,11 +648,10 @@
Print(">>> Done <<<");
}

[SyncOnly]
[Test]
public void StreamingRunWorks()
{
AssertSyncOnly();

AssistantClient client = GetTestClient();
Assistant assistant = client.CreateAssistant("gpt-4o-mini");
Validate(assistant);
Expand Down Expand Up @@ -698,11 +697,10 @@
Print(">>> Done <<<");
}

[AsyncOnly]
[TestCase]
public async Task StreamingToolCallAsync()
{
AssertAsyncOnly();

AssistantClient client = GetTestClient();
FunctionToolDefinition getWeatherTool = new("get_current_weather")
{
Expand Down Expand Up @@ -761,11 +759,10 @@
} while (run?.Status.IsTerminal == false);
}

[SyncOnly]
[TestCase]
public void StreamingToolCall()
{
AssertSyncOnly();

AssistantClient client = GetTestClient();
FunctionToolDefinition getWeatherTool = new("get_current_weather")
{
Expand Down Expand Up @@ -1027,11 +1024,10 @@
});
}

[SyncOnly]
[Test]
public void FileSearchStreamingWorksSync()
{
AssertSyncOnly();

const string fileContent = """
The favorite food of several people:
- Summanus Ferdinand: tacos
Expand Down Expand Up @@ -1118,11 +1114,10 @@
Assert.That(message, Does.Contain("cake"));
}

[AsyncOnly]
[Test]
public async Task FileSearchStreamingWorksAsync()
{
AssertAsyncOnly();

const string fileContent = """
The favorite food of several people:
- Summanus Ferdinand: tacos
Expand Down Expand Up @@ -1211,11 +1206,10 @@
Assert.That(message, Does.Contain("cake"));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanEnumerateAssistantsAsync()
{
AssertAsyncOnly();

const int TestAssistantCount = 10;

AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -1256,11 +1250,10 @@
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
}

[SyncOnly]
[Test]
public void Pagination_CanEnumerateAssistants()
{
AssertSyncOnly();

const int TestAssistantCount = 10;

AssistantClient client = GetTestClient();
Expand Down Expand Up @@ -1301,11 +1294,10 @@
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanPageThroughAssistantCollectionAsync()
{
AssertAsyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1359,11 +1351,10 @@
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[SyncOnly]
[Test]
public void Pagination_CanPageThroughAssistantCollection()
{
AssertSyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1427,11 +1418,10 @@
return els.Select(el => ModelReaderWriter.Read<Assistant>(BinaryData.FromString(el.GetRawText())));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync()
{
AssertAsyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1495,11 +1485,10 @@
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[SyncOnly]
[Test]
public void Pagination_CanRehydrateAssistantPageCollectionFromBytes()
{
AssertSyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1564,11 +1553,10 @@
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsync()
{
AssertAsyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1643,11 +1631,10 @@
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[SyncOnly]
[Test]
public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken()
{
AssertSyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1721,11 +1708,10 @@
Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocolAsync()
{
AssertAsyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1760,7 +1746,7 @@
// functions correctly as the convenience return type.
await foreach (Assistant assistant in assistants)
{
Assert.AreEqual(createdAssistants[count++].Id, assistant.Id);
Assert.That(assistant.Id, Is.EqualTo(createdAssistants[count++].Id));

if (count >= createdAssistants.Count)
{
Expand All @@ -1771,11 +1757,10 @@
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
}

[SyncOnly]
[Test]
public void Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocol()
{
AssertSyncOnly();

const int TestAssistantCount = 10;
const int TestPageSizeLimit = 2;

Expand Down Expand Up @@ -1810,7 +1795,7 @@
// functions correctly as the convenience return type.
foreach (Assistant assistant in assistants)
{
Assert.AreEqual(createdAssistants[count++].Id, assistant.Id);
Assert.That(assistant.Id, Is.EqualTo(createdAssistants[count++].Id));

if (count >= createdAssistants.Count)
{
Expand All @@ -1821,11 +1806,10 @@
Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount));
}

[AsyncOnly]
[Test]
public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync()
{
AssertAsyncOnly();

AssistantClient client = GetTestClient();
Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions()
{
Expand Down Expand Up @@ -1893,14 +1877,13 @@
.ToListAsync();
}

CollectionAssert.AreEqual(runSteps, rehydratedRunSteps);
Assert.That(rehydratedRunSteps, Is.EqualTo(runSteps).AsCollection);
}

[SyncOnly]
[Test]
public void Pagination_CanRehydrateRunStepPageCollectionFromBytes()
{
AssertSyncOnly();

AssistantClient client = GetTestClient();
Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions()
{
Expand Down Expand Up @@ -1967,7 +1950,7 @@
.ToList();
}

CollectionAssert.AreEqual(runSteps, rehydratedRunSteps);
Assert.That(rehydratedRunSteps, Is.EqualTo(runSteps).AsCollection);
}

[Test]
Expand Down
1 change: 1 addition & 0 deletions tests/Audio/GenerateSpeechMockTests.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.ClientModel;
using System.Threading;
using Microsoft.ClientModel.TestFramework;

Check failure on line 4 in tests/Audio/GenerateSpeechMockTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
Expand Down
3 changes: 2 additions & 1 deletion tests/Audio/GenerateSpeechTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Microsoft.ClientModel.TestFramework;

Check failure on line 1 in tests/Audio/GenerateSpeechTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
using System;
Expand Down
7 changes: 4 additions & 3 deletions tests/Audio/TranscriptionMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ClientModel.TestFramework;

Check failure on line 7 in tests/Audio/TranscriptionMockTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using Microsoft.ClientModel.TestFramework.Mocks;

Check failure on line 8 in tests/Audio/TranscriptionMockTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
Expand Down Expand Up @@ -160,12 +162,11 @@

private OpenAIClientOptions GetClientOptionsWithMockResponse(int status, string content)
{
MockPipelineResponse response = new MockPipelineResponse(status);
response.SetContent(content);
MockPipelineResponse response = new MockPipelineResponse(status).WithContent(content);

return new OpenAIClientOptions()
{
Transport = new MockPipelineTransport(response)
Transport = new MockPipelineTransport(_ => response)
};
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Audio/TranscriptionTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Microsoft.ClientModel.TestFramework;

Check failure on line 1 in tests/Audio/TranscriptionTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
using System;
Expand Down Expand Up @@ -180,7 +181,6 @@

Assert.That(segment.Id, Is.EqualTo(i));
Assert.That(segment.EndTime, Is.GreaterThanOrEqualTo(segment.StartTime));
Assert.That(segment.TokenIds, Is.Not.Null);
Assert.That(segment.TokenIds.Length, Is.GreaterThan(0));

Assert.That(segment.AverageLogProbability, Is.LessThan(-0.001f).Or.GreaterThan(0.001f));
Expand Down
7 changes: 4 additions & 3 deletions tests/Audio/TranslationMockTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.ClientModel.TestFramework;

Check failure on line 7 in tests/Audio/TranslationMockTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using Microsoft.ClientModel.TestFramework.Mocks;

Check failure on line 8 in tests/Audio/TranslationMockTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
Expand Down Expand Up @@ -136,12 +138,11 @@

private OpenAIClientOptions GetClientOptionsWithMockResponse(int status, string content = null)
{
MockPipelineResponse response = new MockPipelineResponse(status);
response.SetContent(content ?? "{}");
MockPipelineResponse response = new MockPipelineResponse(status).WithContent(content ?? "{}");

return new OpenAIClientOptions()
{
Transport = new MockPipelineTransport(response)
Transport = new MockPipelineTransport(_ => response)
};
}

Expand Down
3 changes: 2 additions & 1 deletion tests/Audio/TranslationTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using NUnit.Framework;
using Microsoft.ClientModel.TestFramework;

Check failure on line 1 in tests/Audio/TranslationTests.cs

View workflow job for this annotation

GitHub Actions / Build

The type or namespace name 'ClientModel' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
using NUnit.Framework;
using OpenAI.Audio;
using OpenAI.Tests.Utility;
using System;
Expand Down
Loading