|
1 | | -using NUnit.Framework; |
| 1 | +using Microsoft.ClientModel.TestFramework; |
| 2 | +using NUnit.Framework; |
2 | 3 | using OpenAI.Assistants; |
3 | 4 | using OpenAI.Files; |
4 | | -using OpenAI.Tests.Utility; |
5 | 5 | using OpenAI.VectorStores; |
6 | 6 | using System; |
7 | 7 | using System.ClientModel; |
@@ -598,11 +598,10 @@ public async Task FunctionToolsWork() |
598 | 598 | Assert.That(messages[0].Content[0].Text.ToLowerInvariant(), Does.Contain("tacos")); |
599 | 599 | } |
600 | 600 |
|
| 601 | + [AsyncOnly] |
601 | 602 | [Test] |
602 | 603 | public async Task StreamingRunWorksAsync() |
603 | 604 | { |
604 | | - AssertAsyncOnly(); |
605 | | - |
606 | 605 | AssistantClient client = GetTestClient(); |
607 | 606 | Assistant assistant = await client.CreateAssistantAsync("gpt-4o-mini"); |
608 | 607 | Validate(assistant); |
@@ -648,11 +647,10 @@ AsyncCollectionResult<StreamingUpdate> streamingResult |
648 | 647 | Print(">>> Done <<<"); |
649 | 648 | } |
650 | 649 |
|
| 650 | + [SyncOnly] |
651 | 651 | [Test] |
652 | 652 | public void StreamingRunWorks() |
653 | 653 | { |
654 | | - AssertSyncOnly(); |
655 | | - |
656 | 654 | AssistantClient client = GetTestClient(); |
657 | 655 | Assistant assistant = client.CreateAssistant("gpt-4o-mini"); |
658 | 656 | Validate(assistant); |
@@ -698,11 +696,10 @@ CollectionResult<StreamingUpdate> streamingResult |
698 | 696 | Print(">>> Done <<<"); |
699 | 697 | } |
700 | 698 |
|
| 699 | + [AsyncOnly] |
701 | 700 | [TestCase] |
702 | 701 | public async Task StreamingToolCallAsync() |
703 | 702 | { |
704 | | - AssertAsyncOnly(); |
705 | | - |
706 | 703 | AssistantClient client = GetTestClient(); |
707 | 704 | FunctionToolDefinition getWeatherTool = new("get_current_weather") |
708 | 705 | { |
@@ -761,11 +758,10 @@ public async Task StreamingToolCallAsync() |
761 | 758 | } while (run?.Status.IsTerminal == false); |
762 | 759 | } |
763 | 760 |
|
| 761 | + [SyncOnly] |
764 | 762 | [TestCase] |
765 | 763 | public void StreamingToolCall() |
766 | 764 | { |
767 | | - AssertSyncOnly(); |
768 | | - |
769 | 765 | AssistantClient client = GetTestClient(); |
770 | 766 | FunctionToolDefinition getWeatherTool = new("get_current_weather") |
771 | 767 | { |
@@ -1027,11 +1023,10 @@ This file describes the favorite foods of several people. |
1027 | 1023 | }); |
1028 | 1024 | } |
1029 | 1025 |
|
| 1026 | + [SyncOnly] |
1030 | 1027 | [Test] |
1031 | 1028 | public void FileSearchStreamingWorksSync() |
1032 | 1029 | { |
1033 | | - AssertSyncOnly(); |
1034 | | - |
1035 | 1030 | const string fileContent = """ |
1036 | 1031 | The favorite food of several people: |
1037 | 1032 | - Summanus Ferdinand: tacos |
@@ -1118,11 +1113,10 @@ public void FileSearchStreamingWorksSync() |
1118 | 1113 | Assert.That(message, Does.Contain("cake")); |
1119 | 1114 | } |
1120 | 1115 |
|
| 1116 | + [AsyncOnly] |
1121 | 1117 | [Test] |
1122 | 1118 | public async Task FileSearchStreamingWorksAsync() |
1123 | 1119 | { |
1124 | | - AssertAsyncOnly(); |
1125 | | - |
1126 | 1120 | const string fileContent = """ |
1127 | 1121 | The favorite food of several people: |
1128 | 1122 | - Summanus Ferdinand: tacos |
@@ -1211,11 +1205,10 @@ public async Task FileSearchStreamingWorksAsync() |
1211 | 1205 | Assert.That(message, Does.Contain("cake")); |
1212 | 1206 | } |
1213 | 1207 |
|
| 1208 | + [AsyncOnly] |
1214 | 1209 | [Test] |
1215 | 1210 | public async Task Pagination_CanEnumerateAssistantsAsync() |
1216 | 1211 | { |
1217 | | - AssertAsyncOnly(); |
1218 | | - |
1219 | 1212 | const int TestAssistantCount = 10; |
1220 | 1213 |
|
1221 | 1214 | AssistantClient client = GetTestClient(); |
@@ -1256,11 +1249,10 @@ public async Task Pagination_CanEnumerateAssistantsAsync() |
1256 | 1249 | Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount)); |
1257 | 1250 | } |
1258 | 1251 |
|
| 1252 | + [SyncOnly] |
1259 | 1253 | [Test] |
1260 | 1254 | public void Pagination_CanEnumerateAssistants() |
1261 | 1255 | { |
1262 | | - AssertSyncOnly(); |
1263 | | - |
1264 | 1256 | const int TestAssistantCount = 10; |
1265 | 1257 |
|
1266 | 1258 | AssistantClient client = GetTestClient(); |
@@ -1301,11 +1293,10 @@ public void Pagination_CanEnumerateAssistants() |
1301 | 1293 | Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount)); |
1302 | 1294 | } |
1303 | 1295 |
|
| 1296 | + [AsyncOnly] |
1304 | 1297 | [Test] |
1305 | 1298 | public async Task Pagination_CanPageThroughAssistantCollectionAsync() |
1306 | 1299 | { |
1307 | | - AssertAsyncOnly(); |
1308 | | - |
1309 | 1300 | const int TestAssistantCount = 10; |
1310 | 1301 | const int TestPageSizeLimit = 2; |
1311 | 1302 |
|
@@ -1359,11 +1350,10 @@ public async Task Pagination_CanPageThroughAssistantCollectionAsync() |
1359 | 1350 | Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit)); |
1360 | 1351 | } |
1361 | 1352 |
|
| 1353 | + [SyncOnly] |
1362 | 1354 | [Test] |
1363 | 1355 | public void Pagination_CanPageThroughAssistantCollection() |
1364 | 1356 | { |
1365 | | - AssertSyncOnly(); |
1366 | | - |
1367 | 1357 | const int TestAssistantCount = 10; |
1368 | 1358 | const int TestPageSizeLimit = 2; |
1369 | 1359 |
|
@@ -1427,11 +1417,10 @@ private static IEnumerable<Assistant> GetAssistantsFromPage(ClientResult page) |
1427 | 1417 | return els.Select(el => ModelReaderWriter.Read<Assistant>(BinaryData.FromString(el.GetRawText()))); |
1428 | 1418 | } |
1429 | 1419 |
|
| 1420 | + [AsyncOnly] |
1430 | 1421 | [Test] |
1431 | 1422 | public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync() |
1432 | 1423 | { |
1433 | | - AssertAsyncOnly(); |
1434 | | - |
1435 | 1424 | const int TestAssistantCount = 10; |
1436 | 1425 | const int TestPageSizeLimit = 2; |
1437 | 1426 |
|
@@ -1495,11 +1484,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromBytesAsync() |
1495 | 1484 | Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit)); |
1496 | 1485 | } |
1497 | 1486 |
|
| 1487 | + [SyncOnly] |
1498 | 1488 | [Test] |
1499 | 1489 | public void Pagination_CanRehydrateAssistantPageCollectionFromBytes() |
1500 | 1490 | { |
1501 | | - AssertSyncOnly(); |
1502 | | - |
1503 | 1491 | const int TestAssistantCount = 10; |
1504 | 1492 | const int TestPageSizeLimit = 2; |
1505 | 1493 |
|
@@ -1564,11 +1552,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromBytes() |
1564 | 1552 | Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit)); |
1565 | 1553 | } |
1566 | 1554 |
|
| 1555 | + [AsyncOnly] |
1567 | 1556 | [Test] |
1568 | 1557 | public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsync() |
1569 | 1558 | { |
1570 | | - AssertAsyncOnly(); |
1571 | | - |
1572 | 1559 | const int TestAssistantCount = 10; |
1573 | 1560 | const int TestPageSizeLimit = 2; |
1574 | 1561 |
|
@@ -1643,11 +1630,10 @@ public async Task Pagination_CanRehydrateAssistantPageCollectionFromPageTokenAsy |
1643 | 1630 | Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit)); |
1644 | 1631 | } |
1645 | 1632 |
|
| 1633 | + [SyncOnly] |
1646 | 1634 | [Test] |
1647 | 1635 | public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken() |
1648 | 1636 | { |
1649 | | - AssertSyncOnly(); |
1650 | | - |
1651 | 1637 | const int TestAssistantCount = 10; |
1652 | 1638 | const int TestPageSizeLimit = 2; |
1653 | 1639 |
|
@@ -1721,11 +1707,10 @@ public void Pagination_CanRehydrateAssistantPageCollectionFromPageToken() |
1721 | 1707 | Assert.That(pageCount, Is.GreaterThanOrEqualTo(TestAssistantCount / TestPageSizeLimit)); |
1722 | 1708 | } |
1723 | 1709 |
|
| 1710 | + [AsyncOnly] |
1724 | 1711 | [Test] |
1725 | 1712 | public async Task Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocolAsync() |
1726 | 1713 | { |
1727 | | - AssertAsyncOnly(); |
1728 | | - |
1729 | 1714 | const int TestAssistantCount = 10; |
1730 | 1715 | const int TestPageSizeLimit = 2; |
1731 | 1716 |
|
@@ -1771,11 +1756,10 @@ public async Task Pagination_CanCastAssistantPageCollectionToConvenienceFromProt |
1771 | 1756 | Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount)); |
1772 | 1757 | } |
1773 | 1758 |
|
| 1759 | + [SyncOnly] |
1774 | 1760 | [Test] |
1775 | 1761 | public void Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocol() |
1776 | 1762 | { |
1777 | | - AssertSyncOnly(); |
1778 | | - |
1779 | 1763 | const int TestAssistantCount = 10; |
1780 | 1764 | const int TestPageSizeLimit = 2; |
1781 | 1765 |
|
@@ -1821,11 +1805,10 @@ public void Pagination_CanCastAssistantPageCollectionToConvenienceFromProtocol() |
1821 | 1805 | Assert.That(count, Is.GreaterThanOrEqualTo(TestAssistantCount)); |
1822 | 1806 | } |
1823 | 1807 |
|
| 1808 | + [AsyncOnly] |
1824 | 1809 | [Test] |
1825 | 1810 | public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync() |
1826 | 1811 | { |
1827 | | - AssertAsyncOnly(); |
1828 | | - |
1829 | 1812 | AssistantClient client = GetTestClient(); |
1830 | 1813 | Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions() |
1831 | 1814 | { |
@@ -1896,11 +1879,10 @@ public async Task Pagination_CanRehydrateRunStepPageCollectionFromBytesAsync() |
1896 | 1879 | CollectionAssert.AreEqual(runSteps, rehydratedRunSteps); |
1897 | 1880 | } |
1898 | 1881 |
|
| 1882 | + [SyncOnly] |
1899 | 1883 | [Test] |
1900 | 1884 | public void Pagination_CanRehydrateRunStepPageCollectionFromBytes() |
1901 | 1885 | { |
1902 | | - AssertSyncOnly(); |
1903 | | - |
1904 | 1886 | AssistantClient client = GetTestClient(); |
1905 | 1887 | Assistant assistant = client.CreateAssistant("gpt-4o", new AssistantCreationOptions() |
1906 | 1888 | { |
|
0 commit comments