CI / quality (push) Canceled after 0s
Wraps over-long lines, sorts imports, drops an unused local, and bumps the agent submodule for its own import-sort fix so make check passes.
100 lines
3.2 KiB
Python
100 lines
3.2 KiB
Python
from gewu.adapters.sqlite_ingest_reviews import SQLiteIngestReviewStore
|
|
from gewu.domain.contracts import (
|
|
IngestReviewCreate,
|
|
JevFacetOptionScore,
|
|
JevFacetResolution,
|
|
JevFacetScore,
|
|
Locator,
|
|
)
|
|
|
|
|
|
def test_review_store_round_trips_jev_facet_arrays_and_idempotent_create(tmp_path) -> None:
|
|
store = SQLiteIngestReviewStore(tmp_path / "reviews.sqlite3")
|
|
item = IngestReviewCreate(
|
|
review_id="review-satie-label-1",
|
|
project_id="dome-performance",
|
|
run_id="run-satie-label-1",
|
|
source_revision_id="source-revision-satie-1",
|
|
extraction_id="a" * 64,
|
|
locator=Locator(
|
|
kind="pdf_page_span",
|
|
block_id="block-satie-1",
|
|
start=0,
|
|
end=5,
|
|
page=1,
|
|
),
|
|
excerpt="quote",
|
|
lens="technical",
|
|
summary="Normalize a SATIE spatial-audio tag",
|
|
relevance_rationale="The candidate term should reuse the project vocabulary.",
|
|
candidate_facet_labels=(
|
|
{
|
|
"facet": "tags",
|
|
"value": "spatial sound",
|
|
"definition": (
|
|
"Audio techniques that place sound in immersive "
|
|
"spatial configurations."
|
|
),
|
|
},
|
|
),
|
|
)
|
|
scores = (JevFacetScore(facet="tags", value="spatial sound", probability=0.94),)
|
|
resolutions = (
|
|
JevFacetResolution(
|
|
facet="tags",
|
|
value="spatial sound",
|
|
fit_probability=0.94,
|
|
selected_label_id="tag-spatial-audio",
|
|
selected_label="spatial audio",
|
|
selected_new_label=False,
|
|
new_probability=0.04,
|
|
choice_confidence=0.93,
|
|
option_probabilities=(
|
|
JevFacetOptionScore(
|
|
label_id="tag-spatial-audio",
|
|
label="spatial audio",
|
|
probability=0.93,
|
|
),
|
|
JevFacetOptionScore(
|
|
label_id=None,
|
|
label="spatial sound",
|
|
probability=0.07,
|
|
),
|
|
),
|
|
rank=1,
|
|
added_to_project=False,
|
|
),
|
|
)
|
|
|
|
created = store.create(
|
|
item,
|
|
submitted_by="agent-pilot",
|
|
jev_relation_probability=0.97,
|
|
jev_lens="technical",
|
|
jev_lens_confidence=0.98,
|
|
jev_model="typesafe/jev-1.13",
|
|
jev_facet_scores=scores,
|
|
jev_facet_resolutions=resolutions,
|
|
)
|
|
|
|
assert created.jev_facet_scores == scores
|
|
assert created.jev_facet_resolutions == resolutions
|
|
assert created.jev_facet_resolutions[0].selected_label == "spatial audio"
|
|
assert store.get(item.review_id) == created
|
|
assert store.list_items(
|
|
item.project_id, status="needs-user-review", limit=10, offset=0
|
|
) == [created]
|
|
assert (
|
|
store.create(
|
|
item,
|
|
submitted_by="agent-pilot",
|
|
jev_relation_probability=0.97,
|
|
jev_lens="technical",
|
|
jev_lens_confidence=0.98,
|
|
jev_model="typesafe/jev-1.13",
|
|
jev_facet_scores=scores,
|
|
jev_facet_resolutions=resolutions,
|
|
)
|
|
== created
|
|
)
|