Skip to content

Commit 631af2f

Browse files
committed
Update image tests to use gpt-image-1-mini
1 parent c54cebd commit 631af2f

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

src/tests/OpenAI.IntegrationTests/Tests.Images.cs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,50 @@ namespace tryAGI.OpenAI.IntegrationTests;
55
public partial class Tests
66
{
77
[TestMethod]
8-
public async Task CreateImage_Url()
8+
public async Task CreateImage_Png()
99
{
1010
var api = GetAuthorizedApi();
1111
var response = await api.Images.CreateImageAsync(
1212
prompt: "a white siamese cat",
13+
model: CreateImageRequestModel.GptImage1Mini,
1314
n: 1,
14-
size: CreateImageRequestSize.x256x256,
15-
responseFormat: CreateImageRequestResponseFormat.Url,
16-
user: "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Url");
17-
response.Data?.ElementAt(0).Url.Should().NotBeNullOrEmpty();
15+
quality: CreateImageRequestQuality.Low,
16+
size: CreateImageRequestSize.x1024x1024,
17+
outputFormat: CreateImageRequestOutputFormat.Png,
18+
user: "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Png");
19+
var base64 = response.Data?.ElementAt(0).B64Json;
20+
base64.Should().NotBeEmpty();
21+
response.OutputFormat.Should().Be(ImagesResponseOutputFormat.Png);
22+
23+
var bytes = Convert.FromBase64String(base64);
24+
var path = Path.Combine(Path.GetTempPath(), "cat.png");
25+
await File.WriteAllBytesAsync(path, bytes);
1826

19-
Process.Start(new ProcessStartInfo(response.Data?.ElementAt(0).Url!)
27+
Process.Start(new ProcessStartInfo(path)
2028
{
2129
UseShellExecute = true,
2230
});
2331
}
2432

2533
[TestMethod]
26-
public async Task CreateImage_Base64()
34+
public async Task CreateImage_Jpeg()
2735
{
2836
var api = GetAuthorizedApi();
2937
var response = await api.Images.CreateImageAsync(
3038
prompt: "a white siamese cat",
39+
model: CreateImageRequestModel.GptImage1Mini,
3140
n: 1,
32-
size: CreateImageRequestSize.x256x256,
33-
responseFormat: CreateImageRequestResponseFormat.B64Json,
34-
user: "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Base64");
41+
quality: CreateImageRequestQuality.Low,
42+
size: CreateImageRequestSize.x1024x1024,
43+
outputFormat: CreateImageRequestOutputFormat.Jpeg,
44+
outputCompression: 80,
45+
user: "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Jpeg");
3546
var base64 = response.Data?.ElementAt(0).B64Json;
3647
base64.Should().NotBeEmpty();
48+
response.OutputFormat.Should().Be(ImagesResponseOutputFormat.Jpeg);
3749

3850
var bytes = Convert.FromBase64String(base64);
39-
var path = Path.Combine(Path.GetTempPath(), "cat.png");
51+
var path = Path.Combine(Path.GetTempPath(), "cat.jpg");
4052
await File.WriteAllBytesAsync(path, bytes);
4153

4254
Process.Start(new ProcessStartInfo(path)

0 commit comments

Comments
 (0)