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