feat(evidence): project skill evidence from confirmed assessments
This commit is contained in:
1 parent
4761508f13
commit
c2a8d17195
94 files changed
+10077
-151
No files matched your search
@@ -472,6 +472,96 @@ class AssessmentContractTest(unittest.TestCase):
|
||||
)
|
||||
self.assertFalse(decision.get("additionalProperties", True))
|
||||
|
||||
def test_evidence_is_closed_and_no_organization_operation_reaches_raw_assessment_data(self) -> None:
|
||||
own = self.paths["/api/v1/me/evidence"]["get"]
|
||||
organization = self.paths[
|
||||
"/api/v1/organizations/{org_id}/candidate-cards/{candidate_handle}/evidence"
|
||||
]["get"]
|
||||
self.assertEqual(own["operationId"], "ListMyEvidence")
|
||||
self.assertEqual(organization["operationId"], "GetOrganizationCandidateEvidence")
|
||||
for operation in (own, organization):
|
||||
self.assertEqual(operation["security"], [{"sessionCookie": []}])
|
||||
self.assertEqual({"200", "400", "401", "403", "default"} - set(operation["responses"]), set())
|
||||
self.assertIn("Cache-Control", operation["responses"]["200"]["headers"])
|
||||
self.assertEqual({"404", "429"} - set(organization["responses"]), set())
|
||||
self.assertTrue(any(parameter.get("$ref", "").endswith("/PageCursor") for parameter in own["parameters"]))
|
||||
|
||||
self.assertEqual(self.schemas["EvidenceKind"]["enum"], ["claim", "measurement"])
|
||||
trust = self.schemas["EvidenceTrustLevel"]
|
||||
self.assertEqual((trust["minimum"], trust["maximum"]), (0, 3))
|
||||
for name in (
|
||||
"EvidenceFact", "EvidenceSource", "EvidenceResult", "EvidenceFactList",
|
||||
"OrganizationEvidenceFact", "OrganizationEvidence",
|
||||
):
|
||||
schema = self.schemas[name]
|
||||
self.assertFalse(schema.get("additionalProperties", True), name)
|
||||
self.assertEqual(set(schema["required"]), set(schema["properties"]), name)
|
||||
# One event is one fact: the tags are a non-empty set inside the fact.
|
||||
skills = self.schemas["EvidenceFact"]["properties"]["skills"]
|
||||
self.assertTrue(skills["uniqueItems"])
|
||||
self.assertEqual(skills["minItems"], 1)
|
||||
# An organization reads the skill, grade, trust, year, and the basis and
|
||||
# calibration of one fact for each category: no identifier, no source,
|
||||
# no exact time.
|
||||
self.assertEqual(
|
||||
set(self.schemas["OrganizationEvidenceFact"]["properties"]),
|
||||
{"skill", "grade", "trust", "basis", "calibration_status", "observed_year"},
|
||||
)
|
||||
self.assertEqual(self.schemas["OrganizationEvidence"]["properties"]["items"]["maxItems"], 9)
|
||||
|
||||
raw_properties = {
|
||||
"answer", "answers", "answer_key", "reference_answer", "raw_score", "basic_score", "pass_points",
|
||||
"scored_items", "uncertainty", "weak_domains", "practice_results", "signals", "events",
|
||||
"item_instance_id", "seed", "variant", "hidden_checks", "category_decision", "band", "reasons",
|
||||
"attempt_id",
|
||||
}
|
||||
|
||||
def reachable(value: Any, found: set[str]) -> None:
|
||||
if isinstance(value, dict):
|
||||
reference = value.get("$ref", "")
|
||||
if reference.startswith("#/components/schemas/"):
|
||||
name = reference.rsplit("/", 1)[-1]
|
||||
if name not in found:
|
||||
found.add(name)
|
||||
reachable(self.schemas[name], found)
|
||||
for child in value.values():
|
||||
reachable(child, found)
|
||||
elif isinstance(value, list):
|
||||
for child in value:
|
||||
reachable(child, found)
|
||||
|
||||
def property_names(value: Any, found: set[str]) -> None:
|
||||
if isinstance(value, dict):
|
||||
for key, child in value.items():
|
||||
if key == "properties" and isinstance(child, dict):
|
||||
found.update(child)
|
||||
property_names(child, found)
|
||||
elif isinstance(value, list):
|
||||
for child in value:
|
||||
property_names(child, found)
|
||||
|
||||
walked = 0
|
||||
for path, path_item in self.paths.items():
|
||||
if not (path.startswith("/api/v1/organizations") or path == "/api/v1/me/evidence"):
|
||||
continue
|
||||
walked += 1
|
||||
schemas: set[str] = set()
|
||||
reachable(path_item, schemas)
|
||||
names: set[str] = set()
|
||||
property_names(path_item, names)
|
||||
for schema_name in schemas:
|
||||
property_names(self.schemas[schema_name], names)
|
||||
self.assertFalse(
|
||||
schema_name.startswith(("Assessment", "Practice", "ItemContent"))
|
||||
or "Signal" in schema_name
|
||||
or "Review" in schema_name,
|
||||
f"{path} reaches the assessment schema {schema_name}",
|
||||
)
|
||||
self.assertEqual(raw_properties.intersection(names), set(), path)
|
||||
if path == "/api/v1/me/evidence":
|
||||
self.assertTrue({"EvidenceFact", "EvidenceResult"} <= schemas, "the walk must reach the evidence schemas")
|
||||
self.assertGreaterEqual(walked, 10)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user