Skip to content

Commit

Permalink
test: Fixed CreateImage_Base64 test.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Jul 10, 2024
1 parent 59e52d5 commit 3bb0d7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/libs/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</ItemGroup>

<PropertyGroup Label="Nuget">
<Version>3.0.0-alpha.4</Version>
<Version>3.0.0</Version>
<GeneratePackageOnBuild Condition=" '$(Configuration)' == 'Release' ">true</GeneratePackageOnBuild>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<Authors>tryAGI and contributors</Authors>
Expand Down
46 changes: 22 additions & 24 deletions src/tests/OpenAI.IntegrationTests/Tests.Images.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,26 @@ public async Task CreateImage_Url()
});
}

// [TestMethod]
// public async Task CreateImage_Base64()
// {
// var api = GetAuthorizedApi();
// var response = await api.CreateImageAsync(new CreateImageRequest
// {
// Prompt = "a white siamese cat",
// N = 1,
// Size = CreateImageRequestSize._256x256,
// Response_format = CreateImageRequestResponse_format.B64_json,
// User = "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Base64",
// });
// var base64 = response.Data.ElementAt(0).B64_json;
// base64.Should().NotBeEmpty();
//
// var bytes = Convert.FromBase64String(base64!);
// var path = Path.Combine(Path.GetTempPath(), "cat.png");
// await File.WriteAllBytesAsync(path, bytes);
//
// Process.Start(new ProcessStartInfo(path)
// {
// UseShellExecute = true,
// });
// }
[TestMethod]
public async Task CreateImage_Base64()
{
var api = GetAuthorizedApi();
var response = await api.Images.CreateImageAsync(
prompt: "a white siamese cat",
n: 1,
size: CreateImageRequestSize._256x256,
responseFormat: CreateImageRequestResponseFormat.B64Json,
user: "tryAGI.OpenAI.IntegrationTests.Tests.CreateImage_Base64");
var base64 = response.Data.ElementAt(0).B64Json;
base64.Should().NotBeEmpty();

var bytes = Convert.FromBase64String(base64!);
var path = Path.Combine(Path.GetTempPath(), "cat.png");
await File.WriteAllBytesAsync(path, bytes);

Process.Start(new ProcessStartInfo(path)
{
UseShellExecute = true,
});
}
}

0 comments on commit 3bb0d7b

Please sign in to comment.