record cassettes against new fixtures, fix stale assertions
This commit is contained in:
parent
ed36cc2230
commit
710276ffd8
10 changed files with 16846 additions and 1646 deletions
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -265,7 +265,11 @@ async def test_storage_options_thread_through_to_job_extra(jobs, sync):
|
|||
poller = _periodic(source, cfg, jobs, sync)
|
||||
await poller._sweep_once()
|
||||
queued = await jobs.list_jobs(source_id="bucket")
|
||||
assert queued[0].extra == {"storage_options": {"endpoint": "http://seaweed:8333"}}
|
||||
# _otel is also threaded into extra so the worker's `ingester.job` span
|
||||
# can nest under the sweep that enqueued it; assert the source-specific
|
||||
# keys we care about and ignore the trace context payload.
|
||||
assert queued[0].extra is not None
|
||||
assert queued[0].extra["storage_options"] == {"endpoint": "http://seaweed:8333"}
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
|
@ -282,7 +286,8 @@ async def test_http_headers_thread_through_to_job_extra(jobs, sync):
|
|||
poller = _periodic(source, cfg, jobs, sync)
|
||||
await poller._sweep_once()
|
||||
queued = await jobs.list_jobs(source_id="auth")
|
||||
assert queued[0].extra == {"headers": {"Authorization": "Bearer abc"}}
|
||||
assert queued[0].extra is not None
|
||||
assert queued[0].extra["headers"] == {"Authorization": "Bearer abc"}
|
||||
|
||||
|
||||
# --- PollerManager lifecycle ---
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ as unchanged. Catches the FS-specific bug where revision was lost in the
|
|||
pipeline and every periodic sweep re-enqueued every file forever.
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
import pytest
|
||||
|
||||
from haiku.rag.client import HaikuRAG
|
||||
|
|
@ -11,7 +13,13 @@ from haiku.rag.ingester.sources.base import SourceEventKind
|
|||
from haiku.rag.ingester.sources.fs import FSSource
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
def vcr_cassette_dir():
|
||||
return str(Path(__file__).parent.parent / "cassettes" / "test_revision_round_trip")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.vcr()
|
||||
async def test_fs_ingest_writes_source_revision_to_metadata(temp_db_path, tmp_path):
|
||||
file_path = tmp_path / "doc.md"
|
||||
file_path.write_text("hello")
|
||||
|
|
@ -24,6 +32,7 @@ async def test_fs_ingest_writes_source_revision_to_metadata(temp_db_path, tmp_pa
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.vcr()
|
||||
async def test_fs_second_sweep_emits_unchanged_after_ingest(temp_db_path, tmp_path):
|
||||
"""The full round-trip: ingest a file, build a sync_state-shaped snapshot
|
||||
from document.metadata, hand it to FSSource.discover() — must see
|
||||
|
|
@ -46,6 +55,7 @@ async def test_fs_second_sweep_emits_unchanged_after_ingest(temp_db_path, tmp_pa
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.vcr()
|
||||
async def test_fs_second_sweep_emits_upsert_when_file_changes(temp_db_path, tmp_path):
|
||||
"""Counterpart to the unchanged test: a file modified after ingest still
|
||||
triggers UPSERT. Ensures the round-trip doesn't accidentally over-skip."""
|
||||
|
|
@ -72,6 +82,7 @@ async def test_fs_second_sweep_emits_upsert_when_file_changes(temp_db_path, tmp_
|
|||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.vcr()
|
||||
async def test_fs_head_short_circuit_skips_fetch_for_unchanged_revision(
|
||||
temp_db_path, tmp_path, monkeypatch
|
||||
):
|
||||
|
|
|
|||
|
|
@ -89,8 +89,10 @@ class TestClientAnalysisIntegration:
|
|||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.vcr()
|
||||
async def test_analyze_search_and_extract(self, allow_model_requests, temp_db_path):
|
||||
pdf_path = Path("tests/data/doclaynet.pdf")
|
||||
async def test_analyze_search_and_extract(
|
||||
self, allow_model_requests, temp_db_path, doclaynet_first_page_pdf
|
||||
):
|
||||
pdf_path = doclaynet_first_page_pdf
|
||||
config = AppConfig()
|
||||
config.processing.conversion_options.do_ocr = False
|
||||
|
||||
|
|
@ -122,6 +124,11 @@ class TestClientAnalysisIntegration:
|
|||
for label in expected_labels
|
||||
if label in answer_lower or label.replace("-", " ") in answer_lower
|
||||
]
|
||||
assert len(found_labels) >= 6, (
|
||||
f"Expected at least 6 labels, found {len(found_labels)}: {found_labels}"
|
||||
# Page 0 of the DocLayNet paper (title + abstract) names fewer
|
||||
# element types than the older single-page sample did. The
|
||||
# assertion still checks that analyze() pulled real content out
|
||||
# of the doc; ≥3 of the canonical 11 labels is a reasonable
|
||||
# floor for a single-page extract.
|
||||
assert len(found_labels) >= 3, (
|
||||
f"Expected at least 3 labels, found {len(found_labels)}: {found_labels}"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -522,20 +522,20 @@ async def test_expand_context_no_base64_images(temp_db_path):
|
|||
|
||||
|
||||
@pytest.mark.vcr()
|
||||
async def test_expand_context_no_base64_images_docling_local(temp_db_path):
|
||||
async def test_expand_context_no_base64_images_docling_local(
|
||||
temp_db_path, doclaynet_first_page_pdf
|
||||
):
|
||||
"""Ensure expanded context from real PDF does not contain base64 image data.
|
||||
|
||||
Tests end-to-end with doclaynet.pdf using docling-local converter.
|
||||
Tests end-to-end with a single page of doclaynet.pdf using docling-local converter.
|
||||
"""
|
||||
from pathlib import Path
|
||||
|
||||
config = AppConfig()
|
||||
config.processing.converter = "docling-local"
|
||||
config.processing.chunker = "docling-local"
|
||||
config.processing.conversion_options.do_ocr = False
|
||||
|
||||
async with HaikuRAG(temp_db_path, config=config, create=True) as client:
|
||||
pdf_path = Path(__file__).parent / "data" / "doclaynet.pdf"
|
||||
pdf_path = doclaynet_first_page_pdf
|
||||
result = await client.create_document_from_source(pdf_path)
|
||||
doc = result if not isinstance(result, list) else result[0]
|
||||
assert doc.id is not None
|
||||
|
|
|
|||
Loading…
Reference in a new issue