db620d33df
CodeQL / Analyze (csharp) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
dotnet-build-and-test / dotnet-test-functions (push) Has been cancelled
dotnet-build-and-test / paths-filter (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Debug, windows-latest, net9.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, ubuntu-latest, net8.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-build (Release, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, ubuntu-latest, net10.0) (push) Has been cancelled
dotnet-build-and-test / dotnet-test (Release, integration, true, windows-latest, net472) (push) Has been cancelled
dotnet-build-and-test / dotnet-foundry-hosted-it (push) Has been cancelled
dotnet-build-and-test / dotnet-build-and-test-check (push) Has been cancelled
dotnet-build-and-test / Integration Test Report (push) Has been cancelled
69 lines
2.6 KiB
Python
69 lines
2.6 KiB
Python
# Copyright (c) Microsoft. All rights reserved.
|
|
|
|
from __future__ import annotations
|
|
|
|
from unittest.mock import AsyncMock
|
|
|
|
from agent_framework_azure_contentunderstanding._models import (
|
|
DocumentEntry,
|
|
DocumentStatus,
|
|
FileSearchConfig,
|
|
)
|
|
|
|
|
|
class TestDocumentEntry:
|
|
def test_construction(self) -> None:
|
|
entry: DocumentEntry = {
|
|
"status": DocumentStatus.READY,
|
|
"filename": "invoice.pdf",
|
|
"media_type": "application/pdf",
|
|
"analyzer_id": "prebuilt-documentSearch",
|
|
"analyzed_at": "2026-01-01T00:00:00+00:00",
|
|
"analysis_duration_s": 1.23,
|
|
"upload_duration_s": None,
|
|
"result": "---\nsource: invoice.pdf\n---\n# Title",
|
|
"error": None,
|
|
}
|
|
assert entry["status"] == DocumentStatus.READY
|
|
assert entry["filename"] == "invoice.pdf"
|
|
assert entry["analyzer_id"] == "prebuilt-documentSearch"
|
|
assert entry["analysis_duration_s"] == 1.23
|
|
assert entry["upload_duration_s"] is None
|
|
assert isinstance(entry["result"], str)
|
|
|
|
def test_failed_entry(self) -> None:
|
|
entry: DocumentEntry = {
|
|
"status": DocumentStatus.FAILED,
|
|
"filename": "bad.pdf",
|
|
"media_type": "application/pdf",
|
|
"analyzer_id": "prebuilt-documentSearch",
|
|
"analyzed_at": "2026-01-01T00:00:00+00:00",
|
|
"analysis_duration_s": 0.5,
|
|
"upload_duration_s": None,
|
|
"result": None,
|
|
"error": "Service unavailable",
|
|
}
|
|
assert entry["status"] == DocumentStatus.FAILED
|
|
assert entry["error"] == "Service unavailable"
|
|
assert entry["result"] is None
|
|
|
|
|
|
class TestFileSearchConfig:
|
|
def test_required_fields(self) -> None:
|
|
backend = AsyncMock()
|
|
tool = {"type": "file_search", "vector_store_ids": ["vs_123"]}
|
|
config = FileSearchConfig(backend=backend, vector_store_id="vs_123", file_search_tool=tool)
|
|
assert config.backend is backend
|
|
assert config.vector_store_id == "vs_123"
|
|
assert config.file_search_tool is tool
|
|
|
|
def test_from_openai_factory(self) -> None:
|
|
from agent_framework_azure_contentunderstanding._file_search import OpenAIFileSearchBackend
|
|
|
|
client = AsyncMock()
|
|
tool = {"type": "file_search", "vector_store_ids": ["vs_abc"]}
|
|
config = FileSearchConfig.from_openai(client, vector_store_id="vs_abc", file_search_tool=tool)
|
|
assert isinstance(config.backend, OpenAIFileSearchBackend)
|
|
assert config.vector_store_id == "vs_abc"
|
|
assert config.file_search_tool is tool
|