This commit is contained in:
110
e2e/csharp/tests/BatchTests.cs
generated
Normal file
110
e2e/csharp/tests/BatchTests.cs
generated
Normal file
@@ -0,0 +1,110 @@
|
||||
// This file is auto-generated by alef — DO NOT EDIT.
|
||||
// alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
|
||||
// To regenerate: alef generate
|
||||
// To verify freshness: alef verify --exit-code
|
||||
// Issues & docs: https://github.com/kreuzberg-dev/alef
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Threading.Tasks;
|
||||
using Xunit;
|
||||
using Kreuzberg;
|
||||
using static Kreuzberg.KreuzbergLib;
|
||||
|
||||
namespace Kreuzberg
|
||||
{
|
||||
/// <summary>E2e tests for category: batch.</summary>
|
||||
public class BatchTests
|
||||
{
|
||||
private static readonly JsonSerializerOptions ConfigOptions = new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault };
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchBytesInvalidMime()
|
||||
{
|
||||
// batch_extract_bytes_sync invalid MIME
|
||||
var result = KreuzbergLib.BatchExtractBytesSync(new List<BatchBytesItem>() { new BatchBytesItem { Content = new byte[] { (byte)72, (byte)101, (byte)108, (byte)108, (byte)111 }, MimeType = "application/x-nonexistent" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test_BatchExtractBytesHappy()
|
||||
{
|
||||
// batch_extract_bytes: happy path with mixed inputs
|
||||
var result = await KreuzbergLib.BatchExtractBytesAsync(new List<BatchBytesItem>() { new BatchBytesItem { Content = new byte[] { (byte)72, (byte)101, (byte)108, (byte)108, (byte)111, (byte)44, (byte)32, (byte)119, (byte)111, (byte)114, (byte)108, (byte)100, (byte)33 }, MimeType = "text/plain" }, new BatchBytesItem { Content = new byte[] { (byte)60, (byte)104, (byte)116, (byte)109, (byte)108, (byte)62, (byte)60, (byte)98, (byte)111, (byte)100, (byte)121, (byte)62, (byte)84, (byte)101, (byte)115, (byte)116, (byte)60, (byte)47, (byte)98, (byte)111, (byte)100, (byte)121, (byte)62, (byte)60, (byte)47, (byte)104, (byte)116, (byte)109, (byte)108, (byte)62 }, MimeType = "text/html" } }, null);
|
||||
Assert.True(result.Count >= 1, "expected at least 1 elements");
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test_BatchExtractBytesMixedFormat()
|
||||
{
|
||||
// batch_extract_bytes: handles unsupported MIME gracefully
|
||||
var result = await KreuzbergLib.BatchExtractBytesAsync(new List<BatchBytesItem>() { new BatchBytesItem { Content = new byte[] { (byte)80, (byte)68, (byte)70, (byte)32, (byte)112, (byte)108, (byte)97, (byte)99, (byte)101, (byte)104, (byte)111, (byte)108, (byte)100, (byte)101, (byte)114 }, MimeType = "application/x-unknown" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchExtractBytesSyncEmptyList()
|
||||
{
|
||||
// batch_extract_bytes_sync: empty batch
|
||||
var result = KreuzbergLib.BatchExtractBytesSync(new List<BatchBytesItem>() { }, null);
|
||||
Assert.Equal(0, result.Count);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchExtractBytesSyncInvalidMime()
|
||||
{
|
||||
// batch_extract_bytes_sync: unsupported MIME
|
||||
var result = KreuzbergLib.BatchExtractBytesSync(new List<BatchBytesItem>() { new BatchBytesItem { Content = new byte[] { (byte)100, (byte)97, (byte)116, (byte)97 }, MimeType = "application/x-unknown" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test_BatchFileAsyncBasic()
|
||||
{
|
||||
// Extract text from multiple files asynchronously
|
||||
var result = await KreuzbergLib.BatchExtractFilesAsync(new List<BatchFileItem>() { new BatchFileItem { Path = "pdf/fake_memo.pdf" }, new BatchFileItem { Path = "text/fake_text.txt" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Test_BatchFileAsyncNotFound()
|
||||
{
|
||||
// batch_extract_file async nonexistent
|
||||
var result = await KreuzbergLib.BatchExtractFilesAsync(new List<BatchFileItem>() { new BatchFileItem { Path = "/nonexistent/a.pdf" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchFileNotFound()
|
||||
{
|
||||
// batch_extract_file_sync nonexistent
|
||||
var result = KreuzbergLib.BatchExtractFilesSync(new List<BatchFileItem>() { new BatchFileItem { Path = "/nonexistent/a.pdf" }, new BatchFileItem { Path = "/nonexistent/b.txt" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchFilePartial()
|
||||
{
|
||||
// batch_extract_file_sync mixed
|
||||
var result = KreuzbergLib.BatchExtractFilesSync(new List<BatchFileItem>() { new BatchFileItem { Path = "text/plain.txt" }, new BatchFileItem { Path = "/nonexistent/missing.pdf" } }, null);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Test_BatchFileSyncBasic()
|
||||
{
|
||||
// Extract text from multiple files synchronously
|
||||
var result = KreuzbergLib.BatchExtractFilesSync(new List<BatchFileItem>() { new BatchFileItem { Path = "pdf/fake_memo.pdf" }, new BatchFileItem { Path = "text/fake_text.txt" } }, null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user