235 lines
8.1 KiB
C#
Generated
235 lines
8.1 KiB
C#
Generated
// 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: plugin_api.</summary>
|
|
public class PluginApiTests
|
|
{
|
|
private static readonly JsonSerializerOptions ConfigOptions = new() { Converters = { new JsonStringEnumConverter(JsonNamingPolicy.SnakeCaseLower) }, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault };
|
|
|
|
[Fact]
|
|
public void Test_RegisterDocumentExtractorTraitBridge()
|
|
{
|
|
// register_document_extractor: trait bridge
|
|
KreuzbergLib.RegisterDocumentExtractor(DocumentExtractorBridge.Register(new TestStub_RegisterDocumentExtractorTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_RegisterEmbeddingBackendTraitBridge()
|
|
{
|
|
// register_embedding_backend: trait bridge
|
|
KreuzbergLib.RegisterEmbeddingBackend(EmbeddingBackendBridge.Register(new TestStub_RegisterEmbeddingBackendTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_RegisterOcrBackendTraitBridge()
|
|
{
|
|
// register_ocr_backend: trait bridge
|
|
KreuzbergLib.RegisterOcrBackend(OcrBackendBridge.Register(new TestStub_RegisterOcrBackendTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_RegisterPostProcessorTraitBridge()
|
|
{
|
|
// register_post_processor: trait bridge
|
|
KreuzbergLib.RegisterPostProcessor(PostProcessorBridge.Register(new TestStub_RegisterPostProcessorTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_RegisterRendererTraitBridge()
|
|
{
|
|
// register_renderer: trait bridge
|
|
KreuzbergLib.RegisterRenderer(RendererBridge.Register(new TestStub_RegisterRendererTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_RegisterValidatorTraitBridge()
|
|
{
|
|
// register_validator: trait bridge
|
|
KreuzbergLib.RegisterValidator(ValidatorBridge.Register(new TestStub_RegisterValidatorTraitBridge()));
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_UnregisterDocumentExtractorAfterRegister()
|
|
{
|
|
// unregister_document_extractor
|
|
KreuzbergLib.UnregisterDocumentExtractor("test-extractor");
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_UnregisterEmbeddingBackendAfterRegister()
|
|
{
|
|
// unregister_embedding_backend
|
|
KreuzbergLib.UnregisterEmbeddingBackend("test-embedding-backend");
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_UnregisterPostProcessorAfterRegister()
|
|
{
|
|
// unregister_post_processor
|
|
KreuzbergLib.UnregisterPostProcessor("test-processor");
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_UnregisterRendererAfterRegister()
|
|
{
|
|
// unregister_renderer
|
|
KreuzbergLib.UnregisterRenderer("test-renderer");
|
|
}
|
|
|
|
[Fact]
|
|
public void Test_UnregisterValidatorAfterRegister()
|
|
{
|
|
// unregister_validator
|
|
KreuzbergLib.UnregisterValidator("test-validator");
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterDocumentExtractorTraitBridge : IDocumentExtractor
|
|
{
|
|
public string Name => "register_document_extractor_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public string ExtractBytes(byte[] content, string mimeType, ExtractionConfig config)
|
|
=> "";
|
|
public string ExtractFile(string path, string mimeType, ExtractionConfig config)
|
|
=> "";
|
|
public List<string> SupportedMimeTypes()
|
|
=> [];
|
|
public int Priority()
|
|
=> 0;
|
|
public bool CanHandle(string path, string mimeType)
|
|
=> false;
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterEmbeddingBackendTraitBridge : IEmbeddingBackend
|
|
{
|
|
public string Name => "register_embedding_backend_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public ulong Dimensions()
|
|
=> 0;
|
|
public List<List<float>> Embed(List<string> texts)
|
|
=> [];
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterOcrBackendTraitBridge : IOcrBackend
|
|
{
|
|
public string Name => "register_ocr_backend_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public ExtractionResult ProcessImage(byte[] imageBytes, OcrConfig config)
|
|
=> new ExtractionResult();
|
|
public ExtractionResult ProcessImageFile(string path, OcrConfig config)
|
|
=> new ExtractionResult();
|
|
public bool SupportsLanguage(string lang)
|
|
=> false;
|
|
public OcrBackendType BackendType()
|
|
=> OcrBackendType.Tesseract;
|
|
public List<string> SupportedLanguages()
|
|
=> [];
|
|
public bool SupportsTableDetection()
|
|
=> false;
|
|
public bool SupportsDocumentProcessing()
|
|
=> false;
|
|
public ExtractionResult ProcessDocument(string path, OcrConfig config)
|
|
=> new ExtractionResult();
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterPostProcessorTraitBridge : IPostProcessor
|
|
{
|
|
public string Name => "register_post_processor_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public void Process(ExtractionResult result, ExtractionConfig config) { }
|
|
public ProcessingStage ProcessingStage()
|
|
=> ProcessingStage.Early;
|
|
public bool ShouldProcess(ExtractionResult result, ExtractionConfig config)
|
|
=> false;
|
|
public ulong EstimatedDurationMs(ExtractionResult result)
|
|
=> 0;
|
|
public int Priority()
|
|
=> 0;
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterRendererTraitBridge : IRenderer
|
|
{
|
|
public string Name => "register_renderer_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public string Render(string doc)
|
|
=> "";
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
|
|
private class TestStub_RegisterValidatorTraitBridge : IValidator
|
|
{
|
|
public string Name => "register_validator_trait_bridge";
|
|
public string Version => "1.0.0";
|
|
|
|
public void Validate(ExtractionResult result, ExtractionConfig config) { }
|
|
public bool ShouldValidate(ExtractionResult result, ExtractionConfig config)
|
|
=> false;
|
|
public int Priority()
|
|
=> 0;
|
|
public void Initialize() { }
|
|
public void Shutdown() { }
|
|
public string Description()
|
|
=> "";
|
|
public string Author()
|
|
=> "";
|
|
}
|
|
|
|
}
|
|
}
|