112 lines
2.9 KiB
Python
112 lines
2.9 KiB
Python
"""The five LEAD review projects init from starter criteria."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import pytest
|
|
|
|
from prisma.project import init
|
|
from prisma.tools import parse_extraction_fields
|
|
from zot.db import Db
|
|
from zot.schema import create_db
|
|
|
|
FIELDS = {
|
|
"lead-history": (
|
|
"target_id",
|
|
"origin",
|
|
"assumptions",
|
|
"supporting_evidence",
|
|
"critiques",
|
|
"changes_to_lead",
|
|
"status_in_lead",
|
|
"page_refs",
|
|
),
|
|
"lead-limits": (
|
|
"target_id",
|
|
"limit_type",
|
|
"statement",
|
|
"formula",
|
|
"empirical_value",
|
|
"computable_expression",
|
|
"page_refs",
|
|
),
|
|
"lead-scan": (
|
|
"item_type",
|
|
"item_date",
|
|
"summary",
|
|
"target_ids",
|
|
"aacods",
|
|
"chassis_meaning",
|
|
),
|
|
"lead-precursors": (
|
|
"design",
|
|
"data_source",
|
|
"population",
|
|
"n",
|
|
"setting",
|
|
"country",
|
|
"years",
|
|
"factor_definition",
|
|
"outcome_target_id",
|
|
"proxy_closeness",
|
|
"lead_time",
|
|
"grain",
|
|
"effect_measure",
|
|
"effect_value",
|
|
"effect_ci",
|
|
"adjusted_for",
|
|
"c_statistic",
|
|
"calibration",
|
|
"risk_of_bias",
|
|
"observable_public",
|
|
"observable_claims",
|
|
),
|
|
"lead-external": (
|
|
"series_or_event",
|
|
"dates",
|
|
"geography",
|
|
"source",
|
|
"mechanism",
|
|
"magnitude",
|
|
),
|
|
}
|
|
|
|
ENUMS = {
|
|
"lead-history": {"status_in_lead": ["adopted", "modified", "dropped"]},
|
|
"lead-limits": {"limit_type": ["accuracy", "movability", "fairness", "incentive"]},
|
|
"lead-scan": {"item_type": ["policy", "method", "data", "model", "industry"]},
|
|
"lead-precursors": {"grain": ["beneficiary", "provider", "ACO", "area"]},
|
|
}
|
|
|
|
|
|
def _db(tmp_path) -> str:
|
|
path = str(tmp_path / "z.sqlite")
|
|
con = create_db(path)
|
|
con.close()
|
|
return path
|
|
|
|
|
|
def test_each_lead_starter_inits(tmp_path):
|
|
with Db(_db(tmp_path)) as db:
|
|
for name, fields in FIELDS.items():
|
|
project = init(db, name)
|
|
assert project.name == name
|
|
props = parse_extraction_fields(project.extraction_template)
|
|
assert set(props) == set(fields)
|
|
for field, members in ENUMS.get(name, {}).items():
|
|
assert props[field]["enum"] == [*members, ""]
|
|
with pytest.raises(ValueError):
|
|
init(db, "nope")
|
|
|
|
|
|
def test_criteria_pin_suspecting_and_temporal_order(tmp_path):
|
|
with Db(_db(tmp_path)) as db:
|
|
limits = init(db, "lead-limits")
|
|
precursors = init(db, "lead-precursors")
|
|
for project in (limits, precursors):
|
|
assert "code uplift" in project.criteria
|
|
assert "care" in project.criteria
|
|
assert "status" in project.criteria
|
|
assert "cross-sectional" in precursors.criteria
|
|
assert "temporal order" in precursors.criteria
|
|
assert "cross-sectional-no-time-order" in precursors.reasons
|