Files
MajoorWaldi 5e54d55182 feat(index): Implement batch indexing helpers and utilities
- Added entry preparation helpers for batch indexing in `index_prepare_ops.py`.
- Introduced runtime helper functions for index persistence in `index_runtime_helpers.py`.
- Created utility functions for batching, journal lookups, state hashing, and stats initialization in `scan_batch_utils.py`.
- Developed batch failure diagnosis helpers in `scan_diagnostics.py`.
- Implemented high-level scan/index orchestration helpers in `scan_orchestrator.py`.
- Added storage and state helpers for scan/index operations in `scan_storage_ops.py`.
- Extracted streaming scan helpers from `scanner.py` into `scan_streaming.py`.
- Added unit tests for file system walker and scan batch utilities.
2026-02-25 11:43:13 +01:00

57 lines
1.5 KiB
Python

from mjr_am_backend.features.index.scan_batch_utils import should_skip_by_journal
def test_should_skip_by_journal_false_when_not_incremental() -> None:
assert not should_skip_by_journal(
incremental=False,
journal_state_hash="abc",
state_hash="abc",
fast=True,
existing_id=1,
has_rich_meta_set={1},
)
def test_should_skip_by_journal_false_when_hash_mismatch() -> None:
assert not should_skip_by_journal(
incremental=True,
journal_state_hash="abc",
state_hash="def",
fast=True,
existing_id=1,
has_rich_meta_set={1},
)
def test_should_skip_by_journal_true_in_fast_mode_with_matching_hash() -> None:
assert should_skip_by_journal(
incremental=True,
journal_state_hash="abc",
state_hash="abc",
fast=True,
existing_id=0,
has_rich_meta_set=set(),
)
def test_should_skip_by_journal_true_when_existing_has_rich_metadata() -> None:
assert should_skip_by_journal(
incremental=True,
journal_state_hash="abc",
state_hash="abc",
fast=False,
existing_id=42,
has_rich_meta_set={42},
)
def test_should_skip_by_journal_false_when_not_fast_and_no_rich_metadata() -> None:
assert not should_skip_by_journal(
incremental=True,
journal_state_hash="abc",
state_hash="abc",
fast=False,
existing_id=42,
has_rich_meta_set=set(),
)